From 68697c7b068f626254d698438a081943185c0bb6 Mon Sep 17 00:00:00 2001 From: Fangh Date: Thu, 29 Feb 2024 22:13:47 +0100 Subject: [PATCH] fix(GameManager): onroomupdate --- .../AddressableAssetsData/link.xml | 25 ------------------- .../AddressableAssetsData/link.xml.meta | 7 ------ Assets/Scripts/GameManager.cs | 8 +++--- 3 files changed, 4 insertions(+), 36 deletions(-) delete mode 100644 Assets/Localization/AddressableAssetsData/link.xml delete mode 100644 Assets/Localization/AddressableAssetsData/link.xml.meta diff --git a/Assets/Localization/AddressableAssetsData/link.xml b/Assets/Localization/AddressableAssetsData/link.xml deleted file mode 100644 index 6676355..0000000 --- a/Assets/Localization/AddressableAssetsData/link.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Assets/Localization/AddressableAssetsData/link.xml.meta b/Assets/Localization/AddressableAssetsData/link.xml.meta deleted file mode 100644 index 7b4479e..0000000 --- a/Assets/Localization/AddressableAssetsData/link.xml.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 1348ae8b4f67ed743a4d30604cebfa9d -TextScriptImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Assets/Scripts/GameManager.cs b/Assets/Scripts/GameManager.cs index 38f383a..30476d3 100644 --- a/Assets/Scripts/GameManager.cs +++ b/Assets/Scripts/GameManager.cs @@ -207,11 +207,11 @@ public void PlayerValidateNameAndServerRoom(string _name, string _code) else { myOnlineRoom = realtimeDB.Child("rooms").Child(_code); + //subscribe to it + myOnlineRoom.ValueChanged += OnRoomUpdate; //if room exists, join it JoinRoom(() => { - //subscribe to it - myOnlineRoom.ValueChanged += OnRoomUpdate; myRoom.currentState = (int)GameState.WaitingForOtherPlayersToJoin; players.Add(currentPlayer); @@ -307,8 +307,6 @@ public void StartGame() /// private void OnRoomUpdate(object sender, ValueChangedEventArgs e) { - GameState lastState = (GameState)myRoom.currentState; - try { if (e?.Snapshot?.GetRawJsonValue() != null) @@ -328,6 +326,8 @@ private void OnRoomUpdate(object sender, ValueChangedEventArgs e) return; } + GameState lastState = (GameState)myRoom.currentState; + Debug.Log($"lasState = {lastState}. Currentstep = {(GameState)myRoom.currentState}", this); if (myRoom.currentState != (int)lastState) {