Major Refactoring + fixes for new feedback logic + tiny visual fixes with dice logic.
This commit is contained in:
parent
b41e2990fc
commit
8be8ffae15
@ -8492,10 +8492,12 @@ MonoBehaviour:
|
|||||||
isDebugPlayerTest: 0
|
isDebugPlayerTest: 0
|
||||||
diceRollHandler: {fileID: 1013177415}
|
diceRollHandler: {fileID: 1013177415}
|
||||||
diceValue: 0
|
diceValue: 0
|
||||||
diceRollDelay: 0.7
|
diceRollDelayForBot: 0.5
|
||||||
|
diceRollDelayForUser: 0.5
|
||||||
maxDiceSixRollCounter: 2
|
maxDiceSixRollCounter: 2
|
||||||
totalStepsForCharacter: 57
|
totalStepsForCharacter: 57
|
||||||
currentPlayerTurnMaxTime: 4
|
currentPlayerTurnMaxTime: 2
|
||||||
|
currentPlayerSelectionMaxTime: 2
|
||||||
diceText: {fileID: 953941044}
|
diceText: {fileID: 953941044}
|
||||||
pointerDebug: {fileID: 102349503}
|
pointerDebug: {fileID: 102349503}
|
||||||
pointerMeshRend: {fileID: 102349501}
|
pointerMeshRend: {fileID: 102349501}
|
||||||
|
|||||||
@ -132,8 +132,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
playerBaseHandler.InitPlayerTypes(allPlayerTypes);
|
||||||
InitCurrentGamePlayerInfo();
|
InitCurrentGamePlayerInfo();
|
||||||
|
|
||||||
// SetCanRollDiceForUser(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
public void InitPlayerTypesForBotMatch(PlayerData selectedPlayerData, int botCount)
|
||||||
@ -263,15 +261,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot)
|
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot)
|
||||||
{
|
{
|
||||||
bool isBotTurn = botTypesInGame.Contains(currentPlayerTypeTurn);
|
bool isBotTurn = botTypesInGame.Contains(currentPlayerTypeTurn);
|
||||||
SetCanRollDiceForUser(!isBotTurn);
|
// SetCanRollDiceForUser(!isBotTurn); // TODO :: Need to change
|
||||||
if (isBotTurn)
|
if (isBotTurn)
|
||||||
{
|
{
|
||||||
|
currentPlayerTurnTimer.KillTimer();
|
||||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn);
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
SetCanRollDiceForUser(true);
|
// SetCanRollDiceForUser(true); // TODO :: Need to change
|
||||||
|
|
||||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerMaxTime);
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerMaxTime);
|
||||||
|
|
||||||
@ -309,6 +308,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitCurrentGamePlayerInfo()
|
public void InitCurrentGamePlayerInfo()
|
||||||
{
|
{
|
||||||
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
||||||
|
SetCanRollDiceForUser(IsUsersTurn());
|
||||||
UpdateDiceView();
|
UpdateDiceView();
|
||||||
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
||||||
|
|
||||||
@ -361,14 +361,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
playerPawn.Value.SetPlayerSelectionState(state);
|
playerPawn.Value.SetPlayerSelectionState(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnDiceInteracted()
|
public void OnDiceInteracted()
|
||||||
{
|
{
|
||||||
ResetCurrentPlayerTurnTimer();
|
|
||||||
RollDiceForUser();
|
RollDiceForUser();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -538,7 +536,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
|
{
|
||||||
RollDiceForBot();
|
RollDiceForBot();
|
||||||
|
}
|
||||||
else
|
else
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
}
|
}
|
||||||
@ -614,6 +614,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilterAvailablePlayersToMove();
|
||||||
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
if (rolledVal == Ludo_3D_Constants.Max_Dice_Rolls)
|
||||||
{
|
{
|
||||||
canSwitchPlayer = false;
|
canSwitchPlayer = false;
|
||||||
@ -637,9 +638,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome < 1 && CanMoveSoloPlayer())
|
if (playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome < 1 && CanMoveSoloPlayer())
|
||||||
|
{
|
||||||
|
SetPlayerSelectionStates(false);
|
||||||
|
OnPawnSelected(availPlayersToMove[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
pointerMeshRend.material = selectMat;
|
pointerMeshRend.material = selectMat;
|
||||||
@ -649,6 +654,8 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (AreAllPawnsInFinishingPath())
|
if (AreAllPawnsInFinishingPath())
|
||||||
{
|
{
|
||||||
SetCanRollDiceForUser(IsUsersTurn());
|
SetCanRollDiceForUser(IsUsersTurn());
|
||||||
|
UpdateResponseTimerForUser(currentPlayerSelectionMaxTime, () => RollDiceForUser());
|
||||||
|
CheckForMaxDiceRollAttempt();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -658,6 +665,51 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Log($"before CustomAvailablePlayers: {availPlayersToMove.Count}");
|
Debug.Log($"before CustomAvailablePlayers: {availPlayersToMove.Count}");
|
||||||
|
|
||||||
|
Debug.Log($"CustomAvailablePlayers: {availPlayersToMove.Count}");
|
||||||
|
canSwitchPlayer = availPlayersToMove.Count < 1;
|
||||||
|
CanRollDiceAgain = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
diceRollHandler.DiceView.SetDiceButtonInteraction(CanRollDiceAgain);
|
||||||
|
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
||||||
|
|
||||||
|
if (IsUsersTurn())
|
||||||
|
{
|
||||||
|
Action onComplete = null;
|
||||||
|
if (CanRollDiceAgain && availPlayersToMove.Count < 1 &&
|
||||||
|
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome > 0)
|
||||||
|
{
|
||||||
|
onComplete = () => OnPawnSelected(playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values
|
||||||
|
.FirstOrDefault(pawn => pawn.GetPlayerState() == PlayerState.InHome));
|
||||||
|
|
||||||
|
UpdateResponseTimerForUser(currentPlayerSelectionMaxTime, () => onComplete?.Invoke());
|
||||||
|
}
|
||||||
|
else if (availPlayersToMove.Count > 0)
|
||||||
|
{
|
||||||
|
if (CanRollDiceAgain && playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome > 0)
|
||||||
|
{
|
||||||
|
onComplete = () => OnPawnSelected(playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values
|
||||||
|
.FirstOrDefault(pawn => pawn.GetPlayerState() == PlayerState.InHome));
|
||||||
|
UpdateResponseTimerForUser(currentPlayerSelectionMaxTime, () => onComplete?.Invoke());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CanMoveSoloPlayer())
|
||||||
|
{
|
||||||
|
SetPlayerSelectionStates(false);
|
||||||
|
OnPawnSelected(availPlayersToMove[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
onComplete = () => OnPawnSelected(availPlayersToMove.OrderByDescending(pawn => pawn.StepsTaken).FirstOrDefault());
|
||||||
|
UpdateResponseTimerForUser(currentPlayerSelectionMaxTime, () => onComplete?.Invoke());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FilterAvailablePlayersToMove()
|
||||||
|
{
|
||||||
List<int> indexesToRemove = new List<int>();
|
List<int> indexesToRemove = new List<int>();
|
||||||
|
|
||||||
for (int i = 0; i < availPlayersToMove.Count; i++)
|
for (int i = 0; i < availPlayersToMove.Count; i++)
|
||||||
@ -688,38 +740,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
for (int idx = indexesToRemove.Count - 1; idx >= 0; idx--)
|
for (int idx = indexesToRemove.Count - 1; idx >= 0; idx--)
|
||||||
availPlayersToMove.RemoveAt(idx);
|
availPlayersToMove.RemoveAt(idx);
|
||||||
|
|
||||||
// TODO :: Show the selectable characters indicator here
|
|
||||||
Debug.Log($"CustomAvailablePlayers: {availPlayersToMove.Count}");
|
|
||||||
canSwitchPlayer = availPlayersToMove.Count < 1;
|
|
||||||
CanRollDiceAgain = false;
|
|
||||||
|
|
||||||
if (IsUsersTurn() && availPlayersToMove.Count > 0)
|
|
||||||
{
|
|
||||||
if (CanMoveSoloPlayer())
|
|
||||||
{
|
|
||||||
SetPlayerSelectionStates(false);
|
|
||||||
OnPawnSelected(availPlayersToMove[0]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
diceRollHandler.DiceView.SetDiceButtonInteraction(CanRollDiceAgain);
|
|
||||||
|
|
||||||
Action onComplete = null;
|
|
||||||
if (CanRollDiceAgain && availPlayersToMove.Count < 1 && playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInHome > 0)
|
|
||||||
{
|
|
||||||
onComplete = () => OnPawnSelected(playerGameDatasDict[currentPlayerTypeTurn].playerPawnsDict.Values
|
|
||||||
.FirstOrDefault(pawn => pawn.GetPlayerState() == PlayerState.InHome));
|
|
||||||
}
|
|
||||||
else if (availPlayersToMove.Count > 0)
|
|
||||||
{
|
|
||||||
onComplete = () => availPlayersToMove.OrderByDescending(pawn => pawn.StepsTaken).FirstOrDefault();
|
|
||||||
}
|
|
||||||
|
|
||||||
UpdateResponseTimerForUser(currentPlayerSelectionMaxTime, () => onComplete?.Invoke());
|
|
||||||
|
|
||||||
Debug.Log($"CanRollDiceAgain: {CanRollDiceAgain}, canSwitchPlayer: {canSwitchPlayer}");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool CanMoveSoloPlayer()
|
private bool CanMoveSoloPlayer()
|
||||||
@ -768,6 +788,12 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void UpdatePlayerState(PlayerPawn playerPawn, PlayerState playerState)
|
private void UpdatePlayerState(PlayerPawn playerPawn, PlayerState playerState)
|
||||||
{
|
{
|
||||||
|
if (!playerPawn)
|
||||||
|
{
|
||||||
|
// Debug.LogError($"Player pawn is null");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Debug.Log($"#### UpdatePlayerState ");
|
Debug.Log($"#### UpdatePlayerState ");
|
||||||
playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId] = playerPawn;
|
playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId] = playerPawn;
|
||||||
playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId].SetPlayerState(playerState);
|
playerGameDatasDict[playerPawn.PlayerType].playerPawnsDict[playerPawn.PlayerId].SetPlayerState(playerState);
|
||||||
@ -784,6 +810,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void RollDiceForUser()
|
private void RollDiceForUser()
|
||||||
{
|
{
|
||||||
|
ResetCurrentPlayerTurnTimer();
|
||||||
InitActivePlayers();
|
InitActivePlayers();
|
||||||
bool canUsePawnsFromHome = CanUsePawnsFromHome();
|
bool canUsePawnsFromHome = CanUsePawnsFromHome();
|
||||||
diceRollHandler.HandleDiceViewForUser(
|
diceRollHandler.HandleDiceViewForUser(
|
||||||
@ -793,6 +820,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
private void RollDiceForBot()
|
private void RollDiceForBot()
|
||||||
{
|
{
|
||||||
|
ResetCurrentPlayerTurnTimer();
|
||||||
InitActivePlayers();
|
InitActivePlayers();
|
||||||
HandleDiceRollForBot();
|
HandleDiceRollForBot();
|
||||||
}
|
}
|
||||||
@ -826,6 +854,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
// TODO :: Hide the selectable characters indicator here
|
// TODO :: Hide the selectable characters indicator here
|
||||||
SetPlayerSelectionStates(false);
|
SetPlayerSelectionStates(false);
|
||||||
|
if (IsUsersTurn()) currentPlayerTurnTimer.KillTimer();
|
||||||
|
|
||||||
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
PlayerGameData playerGameData = playerGameDatasDict[currentPlayerTypeTurn];
|
||||||
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
Debug.Log($"playerPawn.GetPlayerState(): {selectedPawn.GetPlayerState()}");
|
||||||
@ -854,7 +883,10 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
if (selectedPawn.IsBotPlayer)
|
if (selectedPawn.IsBotPlayer)
|
||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot();
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
SetCanRollDiceForUser(IsUsersTurn());
|
||||||
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
}
|
||||||
|
|
||||||
}, playerGameData.startIndex);
|
}, playerGameData.startIndex);
|
||||||
|
|
||||||
@ -987,24 +1019,29 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
Debug.Log($"IsUsersTurn: {IsUsersTurn()}");
|
Debug.Log($"IsUsersTurn: {IsUsersTurn()}");
|
||||||
if (IsUsersTurn())
|
if (IsUsersTurn())
|
||||||
{
|
{
|
||||||
|
SetCanRollDiceForUser(true);
|
||||||
Invoke(nameof(UpdateDiceView), diceRollDelayForUser);
|
Invoke(nameof(UpdateDiceView), diceRollDelayForUser);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
SetCanRollDiceForUser(false);
|
||||||
|
currentPlayerTurnTimer.KillTimer();
|
||||||
Invoke(nameof(UpdateDiceViewForBot), diceRollDelayForBot);
|
Invoke(nameof(UpdateDiceViewForBot), diceRollDelayForBot);
|
||||||
|
}
|
||||||
|
|
||||||
diceSixRollCounter = 0;
|
diceSixRollCounter = 0;
|
||||||
diceText.text = $"{0}";
|
diceText.text = $"{0}";
|
||||||
}
|
}
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
// UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
//
|
||||||
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
// if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||||
{
|
// {
|
||||||
Debug.Log($"Invoking RollDiceForBot");
|
// Debug.Log($"Invoking RollDiceForBot");
|
||||||
HandleDiceRollWithDelay();
|
// HandleDiceRollWithDelay();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
|
Debug.Log($"currentPlayerTurnIndex: {currentPlayerTurnIndex}");
|
||||||
Debug.Log($"CurrentPlayerTurn: {currentPlayerTypeTurn}");
|
Debug.Log($"CurrentPlayerTurn: {currentPlayerTypeTurn}");
|
||||||
@ -1016,6 +1053,20 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnCanRollDiceAgain(PlayerPawn playerPawn = null)
|
||||||
|
{
|
||||||
|
if (playerPawn)
|
||||||
|
UpdatePlayerState(playerPawn, TilesManager.RetrieveTileBasedOnIndex(playerPawn.CurrentTileIndex).IsSafeZone ? PlayerState.InSafeZone : PlayerState.Moving);
|
||||||
|
|
||||||
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
|
||||||
|
if (gameModeHandler.CurrentGameModeType == GameModeType.Bot && botTypesInGame.Contains(currentPlayerTypeTurn)) // TODO :: Double check calling of the function
|
||||||
|
{
|
||||||
|
Debug.Log($"Invoking RollDiceForBot");
|
||||||
|
HandleDiceRollWithDelay();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
private void MoveThroughTiles(PlayerPawn playerPawn, int index, int targetIndex)
|
||||||
{
|
{
|
||||||
Tile nextTile = TilesManager.RetrieveTileBasedOnIndex(index);
|
Tile nextTile = TilesManager.RetrieveTileBasedOnIndex(index);
|
||||||
@ -1104,12 +1155,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
|
|
||||||
CanRollDiceAgain = true;
|
CanRollDiceAgain = true;
|
||||||
if (!playerPawn.IsBotPlayer)
|
|
||||||
{
|
|
||||||
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
|
||||||
}
|
|
||||||
|
|
||||||
diceRollHandler.DiceView.SetDiceButtonInteraction(CanRollDiceAgain);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
nextTile.InitPlayerPawn(playerPawn, currentPlayerTypeTurn);
|
||||||
@ -1130,7 +1175,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SwitchPlayer(playerPawn);
|
if (!CanRollDiceAgain) SwitchPlayer(playerPawn);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (IsUsersTurn())
|
||||||
|
{
|
||||||
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
|
SetCanRollDiceForUser(IsUsersTurn());
|
||||||
|
}
|
||||||
|
|
||||||
|
OnCanRollDiceAgain(playerPawn);
|
||||||
|
diceRollHandler.DiceView.SetDiceButtonInteraction(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
index);
|
index);
|
||||||
@ -1180,6 +1236,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
// ShowUpdatedPlayerCountOnTile(playerPawn);
|
// ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||||
|
|
||||||
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
UpdatePlayerState(playerPawn, PlayerState.HasFinished);
|
||||||
|
playerPawn.SetPlayerSelectionState(false);
|
||||||
|
|
||||||
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsFinished++;
|
||||||
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInFinishingPath--;
|
playerGameDatasDict[currentPlayerTypeTurn].totalPawnsInFinishingPath--;
|
||||||
@ -1221,6 +1278,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
CheckDiceRollForBot();
|
CheckDiceRollForBot();
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
SetCanRollDiceForUser(true);
|
||||||
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
UpdateResponseTimerForUser(currentPlayerMaxTime: currentPlayerTurnMaxTime, () => RollDiceForUser());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1239,11 +1297,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
if (CanRollDiceAgain)
|
if (CanRollDiceAgain)
|
||||||
{
|
{
|
||||||
|
SetCanRollDiceForUser(IsUsersTurn());
|
||||||
|
OnCanRollDiceAgain();
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
ShowUpdatedPlayerCountOnTile(playerPawn);
|
ShowUpdatedPlayerCountOnTile(playerPawn);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
else
|
||||||
SwitchPlayer();
|
SwitchPlayer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1302,17 +1362,20 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void ResetTileDatasForPlayers()
|
public void ResetTileDatasForPlayers()
|
||||||
{
|
{
|
||||||
foreach (PlayerData data in playerDatas)
|
// causes null ref cast exception while player is moving.
|
||||||
{
|
// foreach (PlayerData data in playerDatas)
|
||||||
var pawns = playerGameDatasDict[data.playerType].playerPawnsDict.Values;
|
// {
|
||||||
|
// var pawns = playerGameDatasDict[data.playerType].playerPawnsDict.Values;
|
||||||
|
//
|
||||||
|
// foreach (var pawn in pawns)
|
||||||
|
// {
|
||||||
|
// if (pawn.GetPlayerState() == PlayerState.InHome) continue;
|
||||||
|
//
|
||||||
|
// TilesManager.ResetTileData(pawn.PlayerType, pawn.CurrentTileIndex, pawn.GetPlayerState());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
foreach (var pawn in pawns)
|
TilesManager.ResetTileDatas();
|
||||||
{
|
|
||||||
if (pawn.GetPlayerState() == PlayerState.InHome) continue;
|
|
||||||
|
|
||||||
TilesManager.ResetTileData(pawn.PlayerType, pawn.CurrentTileIndex, pawn.GetPlayerState());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ResetData()
|
public void ResetData()
|
||||||
|
|||||||
@ -90,6 +90,7 @@ public class SafeTile : Tile
|
|||||||
|
|
||||||
public override void ResetTileData()
|
public override void ResetTileData()
|
||||||
{
|
{
|
||||||
|
Debug.Log($"Resetting tile in safe tile {name}");
|
||||||
if (playerTypesDict != null && playerTypesDict.Count > 0)
|
if (playerTypesDict != null && playerTypesDict.Count > 0)
|
||||||
{
|
{
|
||||||
playerTypesDict.Clear();
|
playerTypesDict.Clear();
|
||||||
|
|||||||
@ -56,6 +56,7 @@ public class Tile : MonoBehaviour
|
|||||||
|
|
||||||
public virtual void ResetTileData()
|
public virtual void ResetTileData()
|
||||||
{
|
{
|
||||||
|
Debug.Log($"Resetting tile in parent tile {name}");
|
||||||
if (HasPawnsAvailable)
|
if (HasPawnsAvailable)
|
||||||
PlayerPawns.Clear();
|
PlayerPawns.Clear();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -77,6 +77,8 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
|||||||
finishingTileDataPairs.Clear();
|
finishingTileDataPairs.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// causes null ref cast exception while player is moving.
|
||||||
|
/*
|
||||||
public void ResetTileData(PlayerType playerType, int currentTileIndex, PlayerState playerState)
|
public void ResetTileData(PlayerType playerType, int currentTileIndex, PlayerState playerState)
|
||||||
{
|
{
|
||||||
if (playerState == PlayerState.InFinishingPath || playerState == PlayerState.HasFinished)
|
if (playerState == PlayerState.InFinishingPath || playerState == PlayerState.HasFinished)
|
||||||
@ -95,6 +97,21 @@ public class TilesManager : MonoBehaviour, IBootLoader, IDataLoader, IBase
|
|||||||
tile.ResetTileData();
|
tile.ResetTileData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void ResetTileDatas()
|
||||||
|
{
|
||||||
|
foreach (var tile in generalTiles)
|
||||||
|
tile.ResetTileData();
|
||||||
|
|
||||||
|
foreach (var pair in finishingTileDataPairs)
|
||||||
|
{
|
||||||
|
foreach (var tile in finishingTileDataPairs[pair.Key])
|
||||||
|
{
|
||||||
|
tile.ResetTileData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Vector3 GetAndInitPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile, PlayerType currentPlayerTypeTurn)
|
public Vector3 GetAndInitPositionInsideSafeZone(PlayerPawn playerPawn, Tile targetTile, PlayerType currentPlayerTypeTurn)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -46,12 +46,12 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
public void UpdatePlayerTurnText(PlayerType type, int remSec)
|
public void UpdatePlayerTurnText(PlayerType type, int remSec)
|
||||||
{
|
{
|
||||||
screenManager.GetScreen<GameHUDS>(ScreenType.InGameHUDScreen).UpdatePlayerTurnText(type, remSec);
|
screenManager.GetScreen<GameHUDScreen>(ScreenType.InGameHUDScreen).UpdatePlayerTurnText(type, remSec);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePlayerTurnText(PlayerType type)
|
public void UpdatePlayerTurnText(PlayerType type)
|
||||||
{
|
{
|
||||||
screenManager.GetScreen<GameHUDS>(ScreenType.InGameHUDScreen).UpdateBotTurnText(type);
|
screenManager.GetScreen<GameHUDScreen>(ScreenType.InGameHUDScreen).UpdateBotTurnText(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGameOver()
|
public void OnGameOver()
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using System.Collections;
|
|
||||||
|
|
||||||
public class GameHUDS : ScreenBase
|
public class GameHUDScreen : ScreenBase
|
||||||
{
|
{
|
||||||
|
[Header("Buttons")]
|
||||||
[SerializeField] private Button diceBtn;
|
[SerializeField] private Button diceBtn;
|
||||||
[SerializeField] private Button pauseBtn;
|
[SerializeField] private Button pauseBtn;
|
||||||
|
|
||||||
@ -55,11 +55,13 @@ public class GameHUDS : ScreenBase
|
|||||||
|
|
||||||
public void UpdatePlayerTurnText(PlayerType playerType, int remSec)
|
public void UpdatePlayerTurnText(PlayerType playerType, int remSec)
|
||||||
{
|
{
|
||||||
|
Debug.Log($"UpdateTurnText: Player Turn :: {(PlayerColorType)((int)playerType)} ({remSec})");
|
||||||
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)} ({remSec})";
|
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)} ({remSec})";
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBotTurnText(PlayerType playerType)
|
public void UpdateBotTurnText(PlayerType playerType)
|
||||||
{
|
{
|
||||||
|
Debug.Log($"UpdateTurnText: Bot Turn :: {(PlayerColorType)((int)playerType)}");
|
||||||
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)}";
|
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user