feat: enable end buttons only for first player
This commit is contained in:
parent
70b9bee50a
commit
3b6d8a8453
@ -39,6 +39,10 @@ public class GameManager : MonoBehaviour
|
||||
[Header("MakeProposition Component")]
|
||||
public TextMeshProUGUI counterMakeProposition;
|
||||
|
||||
[Header("EndGame Components")]
|
||||
[SerializeField] private GameObject endGameFirstPlayer;
|
||||
[SerializeField] private GameObject endGameOtherPlayers;
|
||||
|
||||
[Header("Pages")]
|
||||
public GameObject HomeConnection;
|
||||
public GameObject WaitingRoom;
|
||||
@ -313,8 +317,11 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
|
||||
{
|
||||
case (int)GameState.WaitingForOtherPlayersToJoin:
|
||||
{
|
||||
CheckIfIAmTheFirst(myRoom.GetPlayerList());
|
||||
UpdateDisplayedListUser(myRoom.GetPlayerList());
|
||||
if(CheckIfIAmTheFirst(myRoom.GetPlayerList()))
|
||||
{
|
||||
submitStartGame.SetActive(true);
|
||||
}
|
||||
UpdateDisplayedListUser(myRoom.GetOrderedPlayerList());
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -382,6 +389,8 @@ private void OnNewGameState()
|
||||
|
||||
VotePicture.SetActive(false);
|
||||
WaitingOtherPlayers.SetActive(false);
|
||||
endGameFirstPlayer.SetActive(CheckIfIAmTheFirst(myRoom.GetPlayerList()));
|
||||
endGameOtherPlayers.SetActive(CheckIfIAmTheFirst(myRoom.GetPlayerList()));
|
||||
EndGame.SetActive(true);
|
||||
}
|
||||
break;
|
||||
@ -416,7 +425,12 @@ private void UpdateDisplayedListUser(List<Player> players)
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckIfIAmTheFirst(List<Player> players)
|
||||
/// <summary>
|
||||
/// return true if you are the fist player
|
||||
/// </summary>
|
||||
/// <param name="players"></param>
|
||||
/// <returns></returns>
|
||||
private bool CheckIfIAmTheFirst(List<Player> players)
|
||||
{
|
||||
bool isFirst = false;
|
||||
if (players.Count > 1)
|
||||
@ -429,11 +443,7 @@ private void CheckIfIAmTheFirst(List<Player> players)
|
||||
isFirst = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFirst)
|
||||
{
|
||||
submitStartGame.SetActive(true);
|
||||
}
|
||||
return isFirst;
|
||||
}
|
||||
public void SendCurrentState(GameState state, Action callback_oncCurrentStateSent)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user