Fix: indicator values.
This commit is contained in:
parent
273c86d5b9
commit
4530c474e9
@ -207,7 +207,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO :: Call based on 2P/3P/4P
|
|
||||||
public void InitCurrentGamePlayerInfo()
|
public void InitCurrentGamePlayerInfo()
|
||||||
{
|
{
|
||||||
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
currentPlayerTypeTurn = allPlayerTypes[currentPlayerTurnIndex];
|
||||||
@ -565,10 +564,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
pawn.GetPlayerState() == PlayerState.Moving ||
|
pawn.GetPlayerState() == PlayerState.Moving ||
|
||||||
pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList();
|
pawn.GetPlayerState() == PlayerState.InFinishingPath).ToList();
|
||||||
|
|
||||||
foreach (var player in availPlayers) // TODO :: Move from here
|
SetDisplayCountForAllAvailPlayers(true);
|
||||||
{
|
|
||||||
DisplayPlayerCountOnTile(player, true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool AreAllPawnsInFinishingPath()
|
private bool AreAllPawnsInFinishingPath()
|
||||||
@ -615,32 +611,32 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
diceRollHandler.HandleDiceViewForBot((rollVal) => RollDiceForBot(rollVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPawnSelected(PlayerPawn playerPawn)
|
public void OnPawnSelected(PlayerPawn selectedPawn)
|
||||||
{
|
{
|
||||||
EnablePlayerSelectionStates(false);
|
EnablePlayerSelectionStates(false);
|
||||||
|
|
||||||
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
||||||
Debug.Log($"playerPawn.GetPlayerState(): {playerPawn.GetPlayerState()}");
|
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
||||||
|
|
||||||
|
|
||||||
if (playerPawn.GetPlayerState() == PlayerState.InHome)
|
if (selectedPawn.GetPlayerState() == PlayerState.InHome)
|
||||||
{
|
{
|
||||||
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
Tile targetTile = tilesManager.RetrieveTileBasedOnIndex(playerGameData.startIndex);
|
||||||
|
|
||||||
DisplayPlayerCountOnTile(playerPawn, false);
|
UpdatePlayerCountOnTile(selectedPawn, false);
|
||||||
playerPawn.MoveToTile(
|
selectedPawn.MoveToTile(
|
||||||
GetAndInitPositionInsideSafeZone(playerPawn, targetTile),
|
GetAndInitPositionInsideSafeZone(selectedPawn, targetTile),
|
||||||
onComplete: () =>
|
onComplete: () =>
|
||||||
{
|
{
|
||||||
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
playerGameDatasDict[playerGameData.playerType].totalPawnsInHome--;
|
||||||
UpdatePlayerState(playerPawn, PlayerState.InSafeZone);
|
UpdatePlayerState(selectedPawn, PlayerState.InSafeZone);
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
UpdatePlayerCountOnTile(selectedPawn, true);
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerPawn.IsBotPlayer)
|
if (selectedPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot();
|
||||||
else
|
else
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
@ -649,53 +645,61 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (playerPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
else if (selectedPawn.GetPlayerState() == PlayerState.InFinishingPath)
|
||||||
{
|
{
|
||||||
ApplyFinishingPathLogic(playerPawn);
|
ApplyFinishingPathLogic(selectedPawn);
|
||||||
}
|
}
|
||||||
else if (playerPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
else if (selectedPawn.CurrentTileIndex == playerGameDatasDict[currentPlayerTypeTurn].endIndex)
|
||||||
{
|
{
|
||||||
tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).ResetPlayerPawn(playerPawn);
|
tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex).ResetPlayerPawn(selectedPawn);
|
||||||
ApplyFinishingPathLogic(playerPawn);
|
ApplyFinishingPathLogic(selectedPawn);
|
||||||
}
|
}
|
||||||
else if (playerPawn.GetPlayerState() == PlayerState.InSafeZone || playerPawn.GetPlayerState() == PlayerState.Moving)
|
else if (selectedPawn.GetPlayerState() == PlayerState.InSafeZone || selectedPawn.GetPlayerState() == PlayerState.Moving)
|
||||||
{
|
{
|
||||||
// move based on the dice value
|
// move based on the dice value
|
||||||
Debug.Log($"Tile Index :: currentTileIndex: {playerPawn.CurrentTileIndex}");
|
Debug.Log($"Tile Index :: currentTileIndex: {selectedPawn.CurrentTileIndex}");
|
||||||
int nextTileIdx = GetNextGeneralTileIndex(playerPawn);
|
int nextTileIdx = GetNextGeneralTileIndex(selectedPawn);
|
||||||
int targetIdx = playerPawn.CurrentTileIndex + diceRolledValue;
|
int targetIdx = selectedPawn.CurrentTileIndex + diceRolledValue;
|
||||||
|
|
||||||
if (nextTileIdx == 0)
|
if (nextTileIdx == 0)
|
||||||
targetIdx = (targetIdx - playerPawn.CurrentTileIndex) - 1;
|
targetIdx = (targetIdx - selectedPawn.CurrentTileIndex) - 1;
|
||||||
|
|
||||||
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex);
|
Tile currentSittingTile = tilesManager.RetrieveTileBasedOnIndex(selectedPawn.CurrentTileIndex);
|
||||||
if (currentSittingTile.IsSafeZone)
|
if (currentSittingTile.IsSafeZone)
|
||||||
{
|
{
|
||||||
SafeTile safeTile = (SafeTile)currentSittingTile;
|
SafeTile safeTile = (SafeTile)currentSittingTile;
|
||||||
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, playerPawn);
|
safeTile.UpdateSafeZonePlayerData(currentPlayerTypeTurn, selectedPawn);
|
||||||
// DisplayPlayerCountOnTile(playerPawn, false);
|
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||||
// if (safeTile.PlayerTypesCount > 0)
|
{
|
||||||
// {
|
var playerPawns = safeTile.GetPlayerPawns(selectedPawn.PlayerType);
|
||||||
// var pawns = safeTile.GetPlayerPawns(playerPawn.PlayerType);
|
|
||||||
// foreach (var pawn in pawns)
|
|
||||||
// DisplayPlayerCountOnTile(pawn, true);
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (safeTile.PlayerTypesCount == 1)
|
if (safeTile.PlayerTypesCount == 1)
|
||||||
{
|
{
|
||||||
PlayerType playerType = safeTile.GetFirstPlayerType();
|
PlayerType playerType = safeTile.GetFirstPlayerType();
|
||||||
|
|
||||||
var playerPawns = safeTile.GetPlayerPawns(playerType);
|
|
||||||
foreach (var pawn in playerPawns)
|
foreach (var pawn in playerPawns)
|
||||||
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
pawn.MoveToCustomTilePosition(safeTile.CenterPlacementPosition);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (safeTile.ContainsPlayerType(selectedPawn.PlayerType))
|
||||||
|
{
|
||||||
|
foreach (var pawn in playerPawns)
|
||||||
|
UpdatePlayerCountOnTile(pawn, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
currentSittingTile.ResetPlayerPawn(playerPawn);
|
currentSittingTile.ResetPlayerPawn(selectedPawn);
|
||||||
|
if (currentSittingTile.HasPawnsAvailable)
|
||||||
|
{
|
||||||
|
var playerPawns = currentSittingTile.GetPlayerPawns();
|
||||||
|
foreach (var pawn in playerPawns)
|
||||||
|
UpdatePlayerCountOnTile(pawn, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MoveThroughTiles(playerPawn, nextTileIdx, targetIndex: targetIdx);
|
MoveThroughTiles(selectedPawn, nextTileIdx, targetIndex: targetIdx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -706,7 +710,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1 : finishingPathIndex + diceRolledValue;
|
||||||
|
|
||||||
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
Debug.Log($"TargetIdx: {targetIdx}, finishingPathIndex: {finishingPathIndex}");
|
||||||
DisplayPlayerCountOnTile(playerPawn, false);
|
UpdatePlayerCountOnTile(playerPawn, false);
|
||||||
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
MoveThroughFinishingPath(playerPawn, finishingPathIndex, targetIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -793,7 +797,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
foreach (var pawn in availPlayers)
|
foreach (var pawn in availPlayers)
|
||||||
{
|
{
|
||||||
DisplayPlayerCountOnTile(pawn, state);
|
UpdatePlayerCountOnTile(pawn, state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,7 +818,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
Debug.Log($"tile targetPosition: {targetPosition}");
|
Debug.Log($"tile targetPosition: {targetPosition}");
|
||||||
DisplayPlayerCountOnTile(playerPawn, false);
|
UpdatePlayerCountOnTile(playerPawn, false);
|
||||||
|
|
||||||
playerPawn.MoveToTile(
|
playerPawn.MoveToTile(
|
||||||
targetPosition,
|
targetPosition,
|
||||||
@ -847,7 +851,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
Debug.Log($"nextTile.IsSafeZone: {nextTile.IsSafeZone}");
|
||||||
|
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
UpdatePlayerCountOnTile(playerPawn, true);
|
||||||
|
|
||||||
if (!nextTile.IsSafeZone)
|
if (!nextTile.IsSafeZone)
|
||||||
{
|
{
|
||||||
@ -866,8 +870,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"pawn: {pawn}");
|
Debug.Log($"pawn: {pawn}");
|
||||||
Debug.Log($"playerBase: {playerBaseHandler}");
|
Debug.Log($"playerBase: {playerBaseHandler}");
|
||||||
|
|
||||||
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType)
|
var playerBasePos = playerBaseHandler.GetPlayerBase(pawn.PlayerType).GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
||||||
.GetBasePlacementDataPosition(pawn.PlayerId - 1);
|
|
||||||
Debug.Log($"playerBasePos: {playerBasePos}");
|
Debug.Log($"playerBasePos: {playerBasePos}");
|
||||||
|
|
||||||
playerGameDatasDict[pawn.PlayerType].totalPawnsInHome++;
|
playerGameDatasDict[pawn.PlayerType].totalPawnsInHome++;
|
||||||
@ -877,7 +880,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
// UpdatePlayerCountOnTile(playerPawn, true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -888,7 +891,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
UpdatePlayerCountOnTile(playerPawn, true);
|
||||||
|
|
||||||
if (CheckForMaxDiceRollAttempt())
|
if (CheckForMaxDiceRollAttempt())
|
||||||
{
|
{
|
||||||
@ -989,7 +992,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DisplayPlayerCountOnTile(playerPawn, true);
|
|
||||||
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
if (playerPawn.CurrentTileIndex == tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
|
||||||
{
|
{
|
||||||
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
||||||
@ -1040,6 +1042,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UpdatePlayerCountOnTile(playerPawn, CanRollDiceAgain && playerPawn.CurrentTileIndex != tilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index);
|
index);
|
||||||
@ -1051,7 +1055,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
Debug.Log($"CAnRollDiceForUser: {CanRollDiceForUser}");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DisplayPlayerCountOnTile(PlayerPawn playerPawn, bool show)
|
private void UpdatePlayerCountOnTile(PlayerPawn playerPawn, bool show)
|
||||||
{
|
{
|
||||||
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
Tile tile = playerPawn.GetPlayerState() == PlayerState.InFinishingPath ?
|
||||||
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
tilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex)
|
||||||
|
|||||||
@ -27,6 +27,8 @@ public class Tile : MonoBehaviour
|
|||||||
|
|
||||||
private List<PlayerPawn> PlayerPawns = new List<PlayerPawn>(); // Change implementation
|
private List<PlayerPawn> PlayerPawns = new List<PlayerPawn>(); // Change implementation
|
||||||
|
|
||||||
|
public List<PlayerPawn> GetPlayerPawns() => PlayerPawns;
|
||||||
|
|
||||||
public bool HasPawnsAvailable => PlayerPawns.Count > 0;
|
public bool HasPawnsAvailable => PlayerPawns.Count > 0;
|
||||||
public PlayerType CurrentHoldingPlayerType => PlayerPawns[0].PlayerType;
|
public PlayerType CurrentHoldingPlayerType => PlayerPawns[0].PlayerType;
|
||||||
public int TotalPawnsInTile => PlayerPawns.Count;
|
public int TotalPawnsInTile => PlayerPawns.Count;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user