Added timer in UI.
This commit is contained in:
parent
f34fa9bce9
commit
96e544001f
@ -250,11 +250,16 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
bool isBotTurn = botTypesInGame.Contains(currentPlayerTypeTurn);
|
bool isBotTurn = botTypesInGame.Contains(currentPlayerTypeTurn);
|
||||||
SetCanRollDiceForUser(!isBotTurn);
|
SetCanRollDiceForUser(!isBotTurn);
|
||||||
if (isBotTurn)
|
if (isBotTurn)
|
||||||
|
{
|
||||||
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
SetCanRollDiceForUser(true);
|
SetCanRollDiceForUser(true);
|
||||||
|
|
||||||
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerTurnMaxTime);
|
||||||
|
|
||||||
if (currentPlayerTurnTimer == null)
|
if (currentPlayerTurnTimer == null)
|
||||||
currentPlayerTurnTimer = new TimerSystem();
|
currentPlayerTurnTimer = new TimerSystem();
|
||||||
@ -263,6 +268,9 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
{
|
{
|
||||||
Debug.Log($"currentPlayerTurnTimer: HandleDiceViewForUser");
|
Debug.Log($"currentPlayerTurnTimer: HandleDiceViewForUser");
|
||||||
diceRollHandler.HandleDiceViewForUser();
|
diceRollHandler.HandleDiceViewForUser();
|
||||||
|
}, inProgress: (remTime) =>
|
||||||
|
{
|
||||||
|
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn, currentPlayerTurnMaxTime - (int)remTime);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,7 +295,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
public void InitCurrentGamePlayerInfo()
|
public void InitCurrentGamePlayerInfo()
|
||||||
{
|
{
|
||||||
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
||||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn);
|
|
||||||
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
Debug.Log($"currentPlayerTypeTurn: {currentPlayerTypeTurn}");
|
||||||
|
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
@ -860,7 +867,6 @@ public class GameplayManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
|
|
||||||
soundManager.PlayGameSoundClip(SoundType.Turn);
|
soundManager.PlayGameSoundClip(SoundType.Turn);
|
||||||
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
UpdateCurrentPlayerTurn(allPlayerTypes[currentPlayerTurnIndex]);
|
||||||
uIManager.UpdatePlayerTurnText(currentPlayerTypeTurn);
|
|
||||||
|
|
||||||
diceSixRollCounter = 0;
|
diceSixRollCounter = 0;
|
||||||
diceText.text = $"{0}";
|
diceText.text = $"{0}";
|
||||||
|
|||||||
@ -9,6 +9,14 @@ public enum PlayerType
|
|||||||
Player4 = 3
|
Player4 = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum PlayerColorType
|
||||||
|
{
|
||||||
|
Red = 0,
|
||||||
|
Blue = 1,
|
||||||
|
Grey = 2,
|
||||||
|
Green = 3
|
||||||
|
}
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class PlayerGameData
|
public class PlayerGameData
|
||||||
{
|
{
|
||||||
|
|||||||
@ -6,7 +6,7 @@ public class TimerSystem
|
|||||||
private float maxTimeAvail;
|
private float maxTimeAvail;
|
||||||
|
|
||||||
private Action onTimerComplete = null;
|
private Action onTimerComplete = null;
|
||||||
private Action onTimerInProgress = null;
|
private Action<float> onTimerInProgress = null;
|
||||||
public bool IsTimerComplete
|
public bool IsTimerComplete
|
||||||
{
|
{
|
||||||
get;
|
get;
|
||||||
@ -24,7 +24,7 @@ public class TimerSystem
|
|||||||
IsTimerComplete = false;
|
IsTimerComplete = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Init(float maxTimeAvail, Action onComplete = null, Action inProgress = null, Action onStart = null)
|
public void Init(float maxTimeAvail, Action onComplete = null, Action<float> inProgress = null, Action onStart = null)
|
||||||
{
|
{
|
||||||
timeRem = 0;
|
timeRem = 0;
|
||||||
IsTimerComplete = false;
|
IsTimerComplete = false;
|
||||||
@ -40,7 +40,7 @@ public class TimerSystem
|
|||||||
if (timeRem < maxTimeAvail)
|
if (timeRem < maxTimeAvail)
|
||||||
{
|
{
|
||||||
timeRem += deltaTime;
|
timeRem += deltaTime;
|
||||||
onTimerInProgress?.Invoke();
|
onTimerInProgress?.Invoke(timeRem);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -44,9 +44,14 @@ public class UIManager : MonoBehaviour, IBase, IBootLoader, IDataLoader
|
|||||||
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
screenManager.ShowScreen(ScreenType.InGameHUDScreen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UpdatePlayerTurnText(PlayerType type, int remSec)
|
||||||
|
{
|
||||||
|
screenManager.GetScreen<GameHUDS>(ScreenType.InGameHUDScreen).UpdatePlayerTurnText(type, remSec);
|
||||||
|
}
|
||||||
|
|
||||||
public void UpdatePlayerTurnText(PlayerType type)
|
public void UpdatePlayerTurnText(PlayerType type)
|
||||||
{
|
{
|
||||||
screenManager.GetScreen<GameHUDS>(ScreenType.InGameHUDScreen).UpdatePlayerTurnText(type);
|
screenManager.GetScreen<GameHUDS>(ScreenType.InGameHUDScreen).UpdateBotTurnText(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnGameOver()
|
public void OnGameOver()
|
||||||
|
|||||||
@ -53,26 +53,15 @@ public class GameHUDS : ScreenBase
|
|||||||
uiManager = uiManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<UIManager>() : uiManager;
|
uiManager = uiManager == null ? InterfaceManager.Instance?.GetInterfaceInstance<UIManager>() : uiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdatePlayerTurnText(PlayerType playerType)
|
public void UpdatePlayerTurnText(PlayerType playerType, int remSec)
|
||||||
{
|
{
|
||||||
Debug.Log($"GameHUDS: UpdatePlayerTurnText: {playerType}");
|
Debug.Log($"GameHUDS: UpdatePlayerTurnText: {playerType}");
|
||||||
switch (playerType)
|
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)} ({remSec})";
|
||||||
{
|
}
|
||||||
case PlayerType.Player1:
|
|
||||||
playerTurnText.text = "Turn : Red";
|
public void UpdateBotTurnText(PlayerType playerType)
|
||||||
break;
|
{
|
||||||
case PlayerType.Player2:
|
Debug.Log($"GameHUDS: UpdatePlayerTurnText: {playerType}");
|
||||||
playerTurnText.text = "Turn : Blue";
|
playerTurnText.text = $"Turn : {(PlayerColorType)((int)playerType)}";
|
||||||
break;
|
|
||||||
case PlayerType.Player3:
|
|
||||||
playerTurnText.text = "Turn : Grey";
|
|
||||||
break;
|
|
||||||
case PlayerType.Player4:
|
|
||||||
playerTurnText.text = "Turn : Green";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
playerTurnText.text = "Turn";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user