From 151823eb3610612a64f79e6aad591931daa04c59 Mon Sep 17 00:00:00 2001 From: Ashby Issac Date: Fri, 23 Jan 2026 13:33:16 +0530 Subject: [PATCH] Visual gameplay bug fixes. --- Assets/Scripts/Gameplay/GameplayManager.cs | 35 +++++++++----------- Assets/Scripts/Gameplay/Player/PlayerPawn.cs | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/Assets/Scripts/Gameplay/GameplayManager.cs b/Assets/Scripts/Gameplay/GameplayManager.cs index c14be1d..e5c6146 100644 --- a/Assets/Scripts/Gameplay/GameplayManager.cs +++ b/Assets/Scripts/Gameplay/GameplayManager.cs @@ -195,7 +195,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex); playerPawn.MoveToTile( - GetPositionInsideSafeZone(playerPawn, targetTile), + GetAndInitPositionInsideSafeZone(playerPawn, targetTile), onComplete: () => { CanRollDice = true; @@ -227,7 +227,17 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex); if (currentSittingTile.IsSafeZone) { - ((SafeTile)currentSittingTile).UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn); + SafeTile safeTile = (SafeTile)currentSittingTile; + safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn); + + if (safeTile.PlayerTypesCount == 1) + { + PlayerTypes playerType = safeTile.GetFirstPlayerType(); + + var playerPawns = safeTile.GetPlayerPawns(playerType); + foreach (var pawn in playerPawns) + pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition); + } } MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx); @@ -291,7 +301,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(targetIndex); if (targetTile.IsSafeZone) { - targetPosition = GetPositionInsideSafeZone(playerPawn, targetTile); + targetPosition = GetAndInitPositionInsideSafeZone(playerPawn, targetTile); } } @@ -335,10 +345,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn); } - // else - // { - // ((SafeTile)nextTile).InitPlayerPawn(playerPawn, currentPlayerTypeTurn); - // } SwitchPlayer(playerPawn); CanRollDice = true; @@ -347,7 +353,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader index); } - private Vector3 GetPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile) + private Vector3 GetAndInitPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile) { Vector3 targetPosition; SafeTile targetSafeTile = (SafeTile)targetTile; @@ -357,26 +363,15 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader Debug.Log($"targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn): {targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn)}"); if (!targetSafeTile.ContainsPlayerType(currentPlayerTypeTurn)) // means it is a new player type, the second one { - Debug.Log($"Logging data"); PlayerTypes initialPlayerType = targetSafeTile.GetFirstPlayerType(); - Debug.Log($"initialPlayerType: {initialPlayerType}"); - int playerPawnsCount = targetSafeTile.GetPlayerPawnsCountInTile(initialPlayerType); - Debug.Log($"playerPawnsCount: {playerPawnsCount}"); // rearrange already existing player from center position to it's saved transform var playerPawns = targetSafeTile.GetPlayerPawns(initialPlayerType); - Debug.Log($"playerPawns: {playerPawns.Count}"); foreach (var pawn in playerPawns) { - Debug.Log($"Getting placement data"); var placementPoint = targetSafeTile.GetPlacementPoint(initialPlayerType); - Debug.Log($"PlacementPoint: {placementPoint.name}"); - pawn.MoveToTileSubPosition(placementPoint.position); + pawn.MoveToCustomTilePosition(placementPoint.position); } - // for (int idx = 0; idx < playerPawnsCount; idx++) - // { - // targetSafeTile.IterateAndGetPlayerPawn(initialPlayerType, idx).MoveToTileSubPosition(targetSafeTile.GetPlacementPoint(initialPlayerType).position); - // } targetSafeTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn); targetPosition = targetSafeTile.GetPlacementPoint(currentPlayerTypeTurn).position; diff --git a/Assets/Scripts/Gameplay/Player/PlayerPawn.cs b/Assets/Scripts/Gameplay/Player/PlayerPawn.cs index eba2146..c10a15b 100644 --- a/Assets/Scripts/Gameplay/Player/PlayerPawn.cs +++ b/Assets/Scripts/Gameplay/Player/PlayerPawn.cs @@ -48,7 +48,7 @@ public class PlayerPawn : MonoBehaviour transform.DOMove(startingPoint, 0.1f).onComplete = () => onComplete?.Invoke(); } - public void MoveToTileSubPosition(Vector3 targetPoint) + public void MoveToCustomTilePosition(Vector3 targetPoint) { transform.DOMove(targetPoint, 0.1f); }