From 5afd8972fc941a65d250e2de4dac3b09313f6ff4 Mon Sep 17 00:00:00 2001 From: Ashby Issac Date: Mon, 2 Feb 2026 19:49:16 +0530 Subject: [PATCH] Fix: Data when reaching finishing point. --- Assets/Scripts/Gameplay/GameplayManager.cs | 15 +++++++-------- Assets/Scripts/Tile/TilesManager.cs | 2 +- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Assets/Scripts/Gameplay/GameplayManager.cs b/Assets/Scripts/Gameplay/GameplayManager.cs index 29ef5b6..5e3c752 100644 --- a/Assets/Scripts/Gameplay/GameplayManager.cs +++ b/Assets/Scripts/Gameplay/GameplayManager.cs @@ -319,7 +319,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome == 0) { - UpdateActivePlayersAndSetDisplay(); + UpdateActivePlayersAndSetDisplay(true); } if (availPlayers.Count() < 1 && CanRollDiceAgain) // got a 6 roll value @@ -522,7 +522,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader else // if there are any other pawns that are in safe or moving state { // for player's logic - UpdateActivePlayersAndSetDisplay(); + UpdateActivePlayersAndSetDisplay(true); int customAvailPlayers = availPlayers.Count(); Debug.Log($"before CustomAvailablePlayers: {customAvailPlayers}"); @@ -564,14 +564,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}"); } - private void UpdateActivePlayersAndSetDisplay() + private void UpdateActivePlayersAndSetDisplay(bool state) { availPlayers = playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values.Select(pawn => pawn) .Where(pawn => pawn.GetPlayerState() == PlayerState.InSafeZone || pawn.GetPlayerState() == PlayerState.Moving || pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList(); - SetDisplayCountForAllAvailPlayers(true); + SetDisplayCountForAllAvailPlayers(state); } private bool AreAllPawnsInFinishingPath() @@ -756,9 +756,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Debug.Log($"before SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}"); - UpdateActivePlayersAndSetDisplay(); + UpdateActivePlayersAndSetDisplay(false); Debug.Log($"after SwitchPlayer availPlayers: {availPlayers.Count}, playerPawn: {playerPawn}"); - SetDisplayCountForAllAvailPlayers(false); if (allPlayerTypes.Count == 1) { @@ -784,7 +783,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader diceSixRollCounter = 0; diceText.text = $"{0}"; - UpdateActivePlayersAndSetDisplay(); + UpdateActivePlayersAndSetDisplay(true); } Debug.Log($"CurrentPlayerTurn: {currentPlayerTypeTurn}"); @@ -1107,7 +1106,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader foreach (var pawn in pawns) { - if (pawn.GetPlayerState() == PlayerState.InHome || pawn.GetPlayerState() == PlayerState.HasFinished) continue; + if (pawn.GetPlayerState() == PlayerState.InHome) continue; tilesManager.ResetTileData(pawn.PlayerType, pawn.CurrentTileIndex, pawn.GetPlayerState()); } diff --git a/Assets/Scripts/Tile/TilesManager.cs b/Assets/Scripts/Tile/TilesManager.cs index e2c5c52..7f098a5 100644 --- a/Assets/Scripts/Tile/TilesManager.cs +++ b/Assets/Scripts/Tile/TilesManager.cs @@ -69,7 +69,7 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase public void ResetTileData(PlayerType playerType, int currentTileIndex, PlayerState playerState) { - if (playerState == PlayerState.InFinishingPath) + if (playerState == PlayerState.InFinishingPath || playerState == PlayerState.HasFinished) { Tile tile = RetrieveFinishingTileBasedOnIndex(playerType, currentTileIndex); tile.ResetTileData();