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