Fix: User dice timer system.

Fix: User's dice roll attempt was not stopping while the game was paused.
This commit is contained in:
Ashby Issac 2026-02-23 17:09:04 +05:30
parent 6e420e0282
commit 627ddacb10
3 changed files with 42 additions and 21 deletions

View File

@ -15584,8 +15584,8 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 5608193482405246780} m_Father: {fileID: 5608193482973815123}
m_RootOrder: 3 m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0} m_AnchorMin: {x: 1, y: 0}
m_AnchorMax: {x: 1, y: 0} m_AnchorMax: {x: 1, y: 0}
@ -18146,7 +18146,7 @@ PrefabInstance:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
serializedVersion: 2 serializedVersion: 2
m_Modification: m_Modification:
m_TransformParent: {fileID: 5608193482405246780} m_TransformParent: {fileID: 5608193482973815123}
m_Modifications: m_Modifications:
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_Pivot.x propertyPath: m_Pivot.x
@ -18158,7 +18158,7 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_RootOrder propertyPath: m_RootOrder
value: 4 value: 2
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_AnchorMax.x propertyPath: m_AnchorMax.x
@ -18202,15 +18202,15 @@ PrefabInstance:
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_LocalRotation.x propertyPath: m_LocalRotation.x
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_LocalRotation.y propertyPath: m_LocalRotation.y
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_LocalRotation.z propertyPath: m_LocalRotation.z
value: 0 value: -0
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3} - target: {fileID: 1882416428171655664, guid: 94fc731c540da43c9ab09386da3501df, type: 3}
propertyPath: m_AnchoredPosition.x propertyPath: m_AnchoredPosition.x
@ -19183,7 +19183,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5608193482973815123} m_Father: {fileID: 5608193482973815123}
m_RootOrder: 2 m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.00047905743, y: 0.019000001} m_AnchorMin: {x: 0.00047905743, y: 0.019000001}
m_AnchorMax: {x: 0.164, y: 0.13700001} m_AnchorMax: {x: 0.164, y: 0.13700001}
@ -24277,10 +24277,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: m_Children:
- {fileID: 5608193482794695410} - {fileID: 5608193482794695410}
- {fileID: 5608193482610168847}
- {fileID: 5608193483164820607} - {fileID: 5608193483164820607}
- {fileID: 1489264326}
- {fileID: 1763545632}
m_Father: {fileID: 5608193482973815123} m_Father: {fileID: 5608193482973815123}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -24690,8 +24687,8 @@ RectTransform:
m_LocalScale: {x: 1, y: 1, z: 1} m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5608193482405246780} m_Father: {fileID: 5608193482973815123}
m_RootOrder: 1 m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}
@ -25398,6 +25395,9 @@ RectTransform:
m_Children: m_Children:
- {fileID: 5608193482405246780} - {fileID: 5608193482405246780}
- {fileID: 5608193483424667982} - {fileID: 5608193483424667982}
- {fileID: 1763545632}
- {fileID: 5608193482610168847}
- {fileID: 1489264326}
- {fileID: 1854040023} - {fileID: 1854040023}
m_Father: {fileID: 5608193482405325761} m_Father: {fileID: 5608193482405325761}
m_RootOrder: 1 m_RootOrder: 1
@ -25823,7 +25823,7 @@ RectTransform:
m_ConstrainProportionsScale: 0 m_ConstrainProportionsScale: 0
m_Children: [] m_Children: []
m_Father: {fileID: 5608193482405246780} m_Father: {fileID: 5608193482405246780}
m_RootOrder: 2 m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1} m_AnchorMax: {x: 0, y: 1}

View File

@ -50,6 +50,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
private PlayerType currentPlayerTypeTurn; private PlayerType currentPlayerTypeTurn;
private TimerSystem currentPlayerTurnTimer; private TimerSystem currentPlayerTurnTimer;
private TimerSystem savedCurrentPlayerTurnTimerInst;
private int currentPlayerTurnIndex = 0; private int currentPlayerTurnIndex = 0;
private List<PlayerType> allPlayerTypes = new List<PlayerType>(); private List<PlayerType> allPlayerTypes = new List<PlayerType>();
@ -95,7 +96,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
public List<PlayerData> PlayerDatas => playerDatas; public List<PlayerData> PlayerDatas => playerDatas;
public List<PlayerType> PlayerTypesCollection => allPlayerTypes; public List<PlayerType> PlayerTypesCollection => allPlayerTypes;
public Action OnGameResumed = null; public Action onGameResumed = null;
public void Initialize() public void Initialize()
{ {
@ -285,6 +286,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
onComplete?.Invoke(); onComplete?.Invoke();
}, inProgress: (remTime) => }, inProgress: (remTime) =>
{ {
if (HasGamePausedForUser())
{
savedCurrentPlayerTurnTimerInst = currentPlayerTurnTimer;
currentPlayerTurnTimer = null;
return;
}
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerMaxTime - (int)remTime); uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerMaxTime - (int)remTime);
}); });
} }
@ -1195,13 +1203,18 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
index); index);
} }
private bool HasGamePausedForUser()
{
return (botTypesInGame == null || !botTypesInGame.Contains(currentPlayerTypeTurn)) &&
GameManager.CurrentGameState == GameState.IsPaused;
}
public void CheckForGamePause(Action onComplete) public void CheckForGamePause(Action onComplete)
{ {
Debug.Log($"CheckForGamePause: {GameManager.CurrentGameState == GameState.IsPaused}"); Debug.Log($"CheckForGamePause: {GameManager.CurrentGameState == GameState.IsPaused}");
if ((botTypesInGame == null || !botTypesInGame.Contains(currentPlayerTypeTurn)) && if (HasGamePausedForUser())
GameManager.CurrentGameState == GameState.IsPaused)
{ {
OnGameResumed = onComplete; onGameResumed = onComplete;
} }
else else
{ {
@ -1209,6 +1222,13 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
} }
} }
public void OnGameResumed()
{
onGameResumed?.Invoke();
currentPlayerTurnTimer = savedCurrentPlayerTurnTimerInst;
savedCurrentPlayerTurnTimerInst = null;
}
private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex) private void MoveThroughFinishingPath(PlayerPawn playerPawn, int index, int targetIndex)
{ {
UpdatePlayerState(playerPawn, PlayerState.InFinishingPath); UpdatePlayerState(playerPawn, PlayerState.InFinishingPath);
@ -1233,7 +1253,7 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
{ {
if (playerPawn.CurrentTileIndex == TilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1) if (playerPawn.CurrentTileIndex == TilesManager.GetFinishingTileDataLength(currentPlayerTypeTurn) - 1)
{ {
OnGameResumed = null; onGameResumed = null;
Tile tile = TilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex); Tile tile = TilesManager.RetrieveFinishingTileBasedOnIndex(playerPawn.PlayerType, playerPawn.CurrentTileIndex);
tile.InitPlayerPawn(playerPawn, playerPawn.PlayerType); tile.InitPlayerPawn(playerPawn, playerPawn.PlayerType);
// ShowUpdatedPlayerCountOnTile(playerPawn); // ShowUpdatedPlayerCountOnTile(playerPawn);
@ -1389,8 +1409,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
ResetGameRestartData(); ResetGameRestartData();
currentPlayerTurnTimer?.KillTimer(); currentPlayerTurnTimer?.KillTimer();
savedCurrentPlayerTurnTimerInst = null;
currentPlayerTurnTimer = null; currentPlayerTurnTimer = null;
OnGameResumed = null; onGameResumed = null;
playerDatas = null; playerDatas = null;
allPlayerTypes = null; allPlayerTypes = null;

View File

@ -40,7 +40,7 @@ public class PauseMenuPopup : PopupBase
screenManager.ShowScreen(ScreenType.InGameHUDScreen); screenManager.ShowScreen(ScreenType.InGameHUDScreen);
SetGameModeHandler(); SetGameModeHandler();
gameModeHandler.GameplayManager.OnGameResumed?.Invoke(); gameModeHandler.GameplayManager.OnGameResumed();
} }
private void OnClick_HomeButton() private void OnClick_HomeButton()