Added start button to pause game
This commit is contained in:
parent
5440c56426
commit
543ae0599b
@ -18,12 +18,20 @@ public class AIEntity : Entity
|
||||
|
||||
override protected void Update() {
|
||||
base.Update();
|
||||
|
||||
if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.TimeStop)
|
||||
return;
|
||||
|
||||
if (currentState.UpdateState() is {} newState)
|
||||
SwitchState(newState);
|
||||
}
|
||||
|
||||
override protected void FixedUpdate() {
|
||||
base.FixedUpdate();
|
||||
|
||||
if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.TimeStop)
|
||||
return;
|
||||
|
||||
if (currentState.FixedUpdateState() is {} newState)
|
||||
SwitchState(newState);
|
||||
}
|
||||
|
||||
@ -11,7 +11,8 @@ public class GameFlowManager : MonoBehaviour {
|
||||
public enum PauseLevel {
|
||||
NotPaused,
|
||||
PreventActions,
|
||||
WorldFreeze,
|
||||
NothingMoves,
|
||||
TimeStop,
|
||||
}
|
||||
|
||||
[field: SerializeField]
|
||||
@ -39,7 +40,7 @@ public class GameFlowManager : MonoBehaviour {
|
||||
|
||||
void SetPauseLevel(PauseLevel value) {
|
||||
pauseLevel = value;
|
||||
Time.timeScale = value >= PauseLevel.WorldFreeze ? 0f : 1f;
|
||||
Time.timeScale = value >= PauseLevel.TimeStop ? 0f : 1f;
|
||||
}
|
||||
|
||||
public void GameOver() => SwitchState(new DeadFlowState(this));
|
||||
@ -50,11 +51,17 @@ public class GameFlowManager : MonoBehaviour {
|
||||
if (!ctx.WasPressedThisFrame(ref lastStartButton))
|
||||
return;
|
||||
|
||||
if (CurrentState is StartFlowState) {
|
||||
switch (CurrentState) {
|
||||
case StartFlowState _:
|
||||
startPrompt.SetActive(false);
|
||||
SwitchState(new GameplayFlowState(this));
|
||||
} else if (CurrentState is GameplayFlowState) {
|
||||
break;
|
||||
case GameplayFlowState _:
|
||||
SwitchState(new PauseMenuFlowState(this));
|
||||
break;
|
||||
case PauseMenuFlowState _:
|
||||
SwitchState(new GameplayFlowState(this));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,6 +126,11 @@ public class GameFlowManager : MonoBehaviour {
|
||||
public PauseMenuFlowState(GameFlowManager gameFlowManager) : base(gameFlowManager) {}
|
||||
|
||||
public override void EnterState() {
|
||||
base.EnterState();
|
||||
gameFlowManager.SetPauseLevel(PauseLevel.TimeStop);
|
||||
}
|
||||
|
||||
public override void LeaveState() {
|
||||
base.EnterState();
|
||||
gameFlowManager.SetPauseLevel(PauseLevel.NotPaused);
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
}
|
||||
|
||||
void Update() {
|
||||
if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.WorldFreeze)
|
||||
if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.TimeStop)
|
||||
return;
|
||||
|
||||
if (currentState.UpdateState() is {} newState)
|
||||
@ -51,7 +51,7 @@ public class PlayerMovement : MonoBehaviour {
|
||||
}
|
||||
|
||||
void FixedUpdate() {
|
||||
if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.WorldFreeze)
|
||||
if (gameFlowManager.pauseLevel >= GameFlowManager.PauseLevel.TimeStop)
|
||||
return;
|
||||
|
||||
if (safeZone != null && IsInSafeZone) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user