From 5164182edbdd0d4afe8dbc749b73ac3991639aa0 Mon Sep 17 00:00:00 2001 From: LadyEbony Date: Sat, 22 Aug 2020 17:31:57 -0700 Subject: [PATCH] small fixes --- Assets/RealCode/GameBoard.cs | 30 ++++++++++++++++------------ Assets/RealCode/GameBoardInstance.cs | 22 ++++++++++++-------- Assets/RealCode/GameBoardRender.cs | 4 ++++ Assets/RealCode/Menu/LobbySetup.cs | 1 + 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/Assets/RealCode/GameBoard.cs b/Assets/RealCode/GameBoard.cs index 2db4999..bd747bf 100644 --- a/Assets/RealCode/GameBoard.cs +++ b/Assets/RealCode/GameBoard.cs @@ -772,6 +772,8 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize { render.SetAnimation(); + render.RenderName(); + render.SetComboLevel(Combo); render.SetScoreValue(score); @@ -790,6 +792,20 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize { Register(); } + public void ResetGame() { + trashCursorHead = 0; + incomingTrash = 0; + score = 0; + + nextActivator = TilesUntilActivator; + nextSpecial = ActivatorsUntilSpecial; + delayState = DelayState.None; + timeInState = 0; + + CurrentDrop = 0; + NextDrop = 0; + } + public void Setup(){ board = BoardStateExtension.Initialize(); @@ -802,19 +818,7 @@ public class GameBoard : EntityBase, IAutoSerialize, IAutoDeserialize { lastActivatorColor = TileInfo.CreateRandomActivatorTile().color; // Texel - Ooops we forgot to clear these - trashCursorHead = 0; - incomingTrash = 0; - score = 0; - - render.RenderName(); - - nextActivator = TilesUntilActivator; - nextSpecial = ActivatorsUntilSpecial; - delayState = DelayState.None; - timeInState = 0; - - CurrentDrop = 0; - NextDrop = 0; + ResetGame(); } public void StartGame(){ diff --git a/Assets/RealCode/GameBoardInstance.cs b/Assets/RealCode/GameBoardInstance.cs index bdd82be..86ce47f 100644 --- a/Assets/RealCode/GameBoardInstance.cs +++ b/Assets/RealCode/GameBoardInstance.cs @@ -66,8 +66,7 @@ public class GameBoardInstance : MonoBehaviour { case 1: case -2: GameTransition.Instance.state = GameState.Lobby; - player1.Clear(); - player2.Clear(); + ClearGame(); break; // rematch case 2: @@ -76,19 +75,27 @@ public class GameBoardInstance : MonoBehaviour { // disconnected case -3: GameTransition.Instance.state = GameState.Menu; - player1.Clear(); - player2.Clear(); + ClearGame(); break; default: break; } } } + public void ResetGame(){ + player1.ResetGame(); + player2.ResetGame(); + } + + public void ClearGame(){ + player1.Clear(); + player2.Clear(); + } + public void SetupGame(){ System.Action callback; - player1.Clear(); - player2.Clear(); + ClearGame(); if (NetworkManager.inRoom){ var players = NetworkManager.net.CurrentRoom.Players.Values.OrderBy(p => p.ID); @@ -164,8 +171,7 @@ public class GameBoardInstance : MonoBehaviour { player1.Stop(); player2.Stop(); - player1.Clear(); - player2.Clear(); + ClearGame(); if (NetworkManager.inRoom){ NetworkManager.net.OpLeaveRoom(); diff --git a/Assets/RealCode/GameBoardRender.cs b/Assets/RealCode/GameBoardRender.cs index 3f4605c..e308cba 100644 --- a/Assets/RealCode/GameBoardRender.cs +++ b/Assets/RealCode/GameBoardRender.cs @@ -55,6 +55,10 @@ public class GameBoardRender : MonoBehaviour { index = board.delayState == GameBoard.DelayState.Loss ? 2 : 1; } } + // lobby edge case + else if (GameTransition.Instance.state == GameState.Lobby){ + index = 0; + } // lol no nothing else return; diff --git a/Assets/RealCode/Menu/LobbySetup.cs b/Assets/RealCode/Menu/LobbySetup.cs index 11ca5fc..241f47d 100644 --- a/Assets/RealCode/Menu/LobbySetup.cs +++ b/Assets/RealCode/Menu/LobbySetup.cs @@ -26,6 +26,7 @@ public class LobbySetup : MonoBehaviour { public void Setup(){ PlayerProperties.CreatePlayerHashtable(); + GameBoardInstance.instance.ResetGame(); } // Update is called once per frame