From d465293ad794c2c9cdcb811e80685d5440608c23 Mon Sep 17 00:00:00 2001 From: Ashby Issac Date: Wed, 4 Feb 2026 12:32:18 +0530 Subject: [PATCH] Feedback-fixes. --- .../Gameplay/Snake and Ladder/DiceView.cs | 5 +- Assets/Scripts/Gameplay/GameplayManager.cs | 49 +++++++++---------- Assets/Scripts/Input/DiceRollHandler.cs | 2 +- Assets/Scripts/Loader/GameBootLoader.cs | 3 +- Assets/Scripts/Tile/SafeTile.cs | 1 + Assets/Scripts/Tile/TilesManager.cs | 9 ++++ 6 files changed, 39 insertions(+), 30 deletions(-) diff --git a/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs b/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs index 584f377..0e6afec 100644 --- a/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs +++ b/Assets/External-Assets/packages/Project/Scripts/Gameplay/Snake and Ladder/DiceView.cs @@ -9,6 +9,7 @@ public class DiceView : MonoBehaviour, IBase [SerializeField] private DiceSide[] diceSides; [SerializeField] private float sideValueTime = 1.2f; + [SerializeField] private Vector3 startPos = new Vector3(0, 20, 0); [Header("Physics Randomness")] [SerializeField] private float baseSpinForce = 900f; @@ -22,7 +23,7 @@ public class DiceView : MonoBehaviour, IBase { rb = GetComponent(); rb.useGravity = false; - transform.localPosition = new Vector3(0, 20, 0); + transform.localPosition = startPos; } public void Roll(Action onComplete, bool isBot) @@ -96,7 +97,7 @@ public class DiceView : MonoBehaviour, IBase rb.useGravity = false; rb.velocity = Vector3.zero; rb.angularVelocity = Vector3.zero; - transform.localPosition = new Vector3(0, 20, 0); + transform.localPosition = startPos; rolling = false; // Invoke(nameof(ResetEvent), 0.1f); diff --git a/Assets/Scripts/Gameplay/GameplayManager.cs b/Assets/Scripts/Gameplay/GameplayManager.cs index daabe6c..2990490 100644 --- a/Assets/Scripts/Gameplay/GameplayManager.cs +++ b/Assets/Scripts/Gameplay/GameplayManager.cs @@ -16,13 +16,16 @@ public enum BotMove public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader { - [SerializeField] private bool isDebugTest = false; + [SerializeField] private bool isDebugAITest = false; + [SerializeField] private bool isDebugPlayerTest = false; - public bool IsDebugTest => isDebugTest; + public bool IsDebugAITest => isDebugAITest; + public bool IsDebugPlayerTest => isDebugPlayerTest; [SerializeField] DiceRollHandler diceRollHandler; [SerializeField] private int diceValue = 0; + [SerializeField] private float botDiceRollDelay = 0.25f; [SerializeField] private int maxDiceSixRollCounter = 2; [SerializeField] private int totalStepsForCharacter = 57; @@ -151,7 +154,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader SetCanRollDiceForUser(!botTypesInGame.Contains(allPlayerTypes[0])); if (botTypesInGame.Contains(allPlayerTypes[0])) - Invoke(nameof(HandleDiceRoll), 1f); + HandleDiceRollWithDelay(); + } + + private void HandleDiceRollWithDelay() + { + Invoke(nameof(HandleDiceRoll), botDiceRollDelay); } private void InitBotRuntimeData() @@ -509,6 +517,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader diceText.text = $"{diceRolledValue}"; availPlayers = new List(); + if (!CanRollDiceAgain) + UpdateActivePlayersAndSetDisplay(true); + if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls) { canSwitchPlayer = false; @@ -540,7 +551,6 @@ 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(true); int customAvailPlayers = availPlayers.Count(); Debug.Log($"before CustomAvailablePlayers: {customAvailPlayers}"); @@ -630,7 +640,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader private void HandleDiceRoll() { - if (isDebugTest) + if (isDebugAITest) diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal), diceValue == 0 ? UnityEngine.Random.Range(1, Ludo_3D_Constants.Max_Dice_Rolls + 1) : diceValue); else diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal)); @@ -702,25 +712,14 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Tile currentSittingTile = TilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex); if (currentSittingTile.IsSafeZone) { - SafeTile safeTile = (SafeTile)currentSittingTile; - safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn); - if (safeTile.ContainsPlayerType(selectedPawn.PlayerType)) + SafeTile currentSittingSafeTile = (SafeTile)currentSittingTile; + currentSittingSafeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn); + + if (currentSittingSafeTile.PlayerTypesCount == 1) // && currentSittingSafeTile.ContainsPlayerType(selectedPawn.PlayerType)) { - var playerPawns = safeTile.GetPlayerPawns(selectedPawn.PlayerType); - - if (safeTile.PlayerTypesCount == 1) - { - PlayerType playerType = safeTile.GetFirstPlayerType(); - - foreach (var pawn in playerPawns) - pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition); - } - - if (safeTile.ContainsPlayerType(selectedPawn.PlayerType)) - { - foreach (var pawn in playerPawns) - ShowUpdatedPlayerCountOnTile(pawn); - } + var playerPawnsTest = currentSittingSafeTile.GetFirstPlayerPawns(); + foreach (var pawn in playerPawnsTest) + pawn.MoveToCustomTilePosition(currentSittingSafeTile.CenterPlacementPosition); } } else @@ -793,8 +792,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader diceSixRollCounter = 0; diceText.text = $"{0}"; - - UpdateActivePlayersAndSetDisplay(true); } Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}"); @@ -812,7 +809,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function { Debug.Log($"Invoking RollDiceForBot"); - Invoke(nameof(HandleDiceRoll), 1f); + HandleDiceRollWithDelay(); } } diff --git a/Assets/Scripts/Input/DiceRollHandler.cs b/Assets/Scripts/Input/DiceRollHandler.cs index ce799c1..c9636d1 100644 --- a/Assets/Scripts/Input/DiceRollHandler.cs +++ b/Assets/Scripts/Input/DiceRollHandler.cs @@ -34,7 +34,7 @@ public class DiceRollHandler : MonoBehaviour SoundManager soundManager = InterfaceManager.Instance?.GetInterfaceInstance(); soundManager?.PlayGameSoundClip(SoundType.Dice); - if (inputManager.GameplayManager.IsDebugTest) + if (inputManager.GameplayManager.IsDebugPlayerTest) OnUserDiceRollComplete(GetDiceTestVal()); else diceView.Roll(onComplete: (rolledVal) => OnUserDiceRollComplete(rolledVal), false); diff --git a/Assets/Scripts/Loader/GameBootLoader.cs b/Assets/Scripts/Loader/GameBootLoader.cs index ce32f28..1aca842 100644 --- a/Assets/Scripts/Loader/GameBootLoader.cs +++ b/Assets/Scripts/Loader/GameBootLoader.cs @@ -3,7 +3,7 @@ using UnityEngine; public class GameBootLoader : BootLoader { [SerializeField] private GameObject[] baseObjects; - // [SerializeField] private BaseSO[] scriptables; + [SerializeField] private bool enableLogs = false; private bool hasInitializedScriptables = false; @@ -21,6 +21,7 @@ public class GameBootLoader : BootLoader } protected override void InitializeData() { + Debug.unityLogger.logEnabled = enableLogs; Debug.Log($"InitializeData: for loaders"); InitializeScriptablesData(); diff --git a/Assets/Scripts/Tile/SafeTile.cs b/Assets/Scripts/Tile/SafeTile.cs index de62512..857aa5c 100644 --- a/Assets/Scripts/Tile/SafeTile.cs +++ b/Assets/Scripts/Tile/SafeTile.cs @@ -12,6 +12,7 @@ public class SafeTile : Tile public int PlayerTypesCount => playerTypesDict.Count; public bool HasMoreThanOnePlayerType => playerTypesDict.Count > 1; public List GetPlayerPawns(PlayerType playerType) => playerTypesDict[playerType].playerPawns.Values.ToList(); + public List GetFirstPlayerPawns() => playerTypesDict.FirstOrDefault().Value.playerPawns.Values.ToList(); public bool ContainsPlayerType(PlayerType playerType) => playerTypesDict.ContainsKey(playerType); diff --git a/Assets/Scripts/Tile/TilesManager.cs b/Assets/Scripts/Tile/TilesManager.cs index bb0d415..a238f85 100644 --- a/Assets/Scripts/Tile/TilesManager.cs +++ b/Assets/Scripts/Tile/TilesManager.cs @@ -109,15 +109,24 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase PlayerType initialPlayerType = targetSafeTile.GetFirstPlayerType(); // rearrange already existing player from center position to it's saved transform + Debug.Log($"### GetAndInitPositionInsideSafeZone initialPlayerType: {initialPlayerType}"); var playerPawns = targetSafeTile.GetPlayerPawns(initialPlayerType); + Debug.Log($"### GetAndInitPositionInsideSafeZone playerPawns: {playerPawns.Count}"); + foreach (var pawn in playerPawns) { var placementPoint = targetSafeTile.GetPlacementPoint(initialPlayerType); + Debug.Log($"### GetAndInitPositionInsideSafeZone placementPoint: {placementPoint.position}"); pawn.MoveToCustomTilePosition(placementPoint.position); } + Debug.Log($"### GetAndInitPositionInsideSafeZone playerPawn: {playerPawn.name}, {playerPawn.PlayerType}"); + Debug.Log($"### GetAndInitPositionInsideSafeZone currentPlayerTypeTurn: {currentPlayerTypeTurn}"); + targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn); targetPosition = targetSafeTile.GetPlacementPoint(currentPlayerTypeTurn).position; + + Debug.Log($"### GetAndInitPositionInsideSafeZone targetPosition: {targetPosition}"); } else {