EndSamePlayer new players

This commit is contained in:
Marine 2024-01-28 02:52:40 +01:00
parent b04804c677
commit fc103f8fab

View File

@ -312,14 +312,31 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e)
} }
switch (myRoom.currentState) switch (myRoom.currentState)
{ {
case (int)GameState.EnteringName:
{
if (EndGame.activeInHierarchy)
{
EndGame.SetActive(false);
HomeConnection.SetActive(true);
}
break;
}
case (int)GameState.WaitingForOtherPlayersToJoin: case (int)GameState.WaitingForOtherPlayersToJoin:
{ {
CheckIfIAmTheFirst(myRoom.GetPlayerList()); if (!HomeConnection.activeInHierarchy)
UpdateDisplayedListUser(myRoom.GetPlayerList()); {
CheckIfIAmTheFirst(myRoom.GetPlayerList());
UpdateDisplayedListUser(myRoom.GetPlayerList());
}
break; break;
} }
case (int)GameState.Explanation: case (int)GameState.Explanation:
{ {
if (EndGame.activeInHierarchy)
{
EndGame.SetActive(false);
}
WaitingRoom.SetActive(false); WaitingRoom.SetActive(false);
BeforeStart.SetActive(true); BeforeStart.SetActive(true);
endOfExplanationDate = DateTime.Now.AddSeconds(3); endOfExplanationDate = DateTime.Now.AddSeconds(3);
@ -390,6 +407,39 @@ public void OnClickSubmitSignIn()
string roomCode = roomCodeField.text; string roomCode = roomCodeField.text;
PlayerValidateNameAndServerRoom(playerName, roomCode); PlayerValidateNameAndServerRoom(playerName, roomCode);
} }
public void onClickSamePlayers()
{
myRoom.currentState = (int)GameState.Explanation;
myRoom.currentQuestion = 2;
myRoom.questions = null;
string json = JsonUtility.ToJson(myRoom);
myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task =>
{
if (task.IsFaulted)
{
Debug.LogException(task.Exception);
}
});
}
public void onClickNewPlayers()
{
myRoom.currentState = (int)GameState.EnteringName;
myRoom.currentQuestion = 0;
myRoom.questions = null;
myRoom.players = null;
string json = JsonUtility.ToJson(myRoom);
myOnlineRoom.SetRawJsonValueAsync(json).ContinueWithOnMainThread(task =>
{
if (task.IsFaulted)
{
Debug.LogException(task.Exception);
}
});
}
} }
public enum GameState public enum GameState