Files
CourierOld/Game/CourierOld/Assets/Code/App/AppStates/GameOverState.cs
T

42 lines
1.1 KiB
C#

using Code.App.StateMachine;
using Code.Scenes;
using Code.StateMachine;
using Code.UI;
using UnityEngine;
namespace Code.App.AppStates
{
public class GameOverState : BaseState<AppStateMachineContext>
{
public GameOverState(AppStateMachineContext context) : base(context)
{ }
private float damnTimer = 3f; // TODO Удалить при первой возможности
public override void EnterState()
{
Context.UIService.SwitchPanelTo(UIPanel.GameOver);
base.EnterState();
}
private void ToMainMenu()
{
Context.StateMachine.SwitchState(AppState.MainMenu)
.AllowStateTransition(AppState.Gameplay);
}
public override void Tick()
{
damnTimer -= Time.deltaTime;
if (damnTimer <= float.Epsilon) ToMainMenu();
}
public override void ExitState()
{
damnTimer = 5f;
Context.UIService.LoadingScreen.Show();
base.ExitState();
}
}
}