Загрузчик не юзлес + больше интерфейса
This commit is contained in:
1 parent
f3a83eb909
commit
cd384239ff
28 files changed
+379
-1758
No files matched your search
@@ -1,8 +1,14 @@
|
||||
using Code.App.Loading;
|
||||
using Code.App.StateMachine;
|
||||
using Code.App.StateMachine;
|
||||
using Code.Gameplay.Player;
|
||||
using Code.Input;
|
||||
using Code.StateMachine;
|
||||
using Code.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Reflex.Core;
|
||||
using Reflex.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.App.AppStates
|
||||
{
|
||||
@@ -11,24 +17,35 @@ namespace Code.App.AppStates
|
||||
public GameOverState(AppStateMachineContext context) : base(context)
|
||||
{
|
||||
}
|
||||
|
||||
private float damnTimer = 3f; // TODO Удалить при первой возможности
|
||||
private IPlayerScore _playerScore;
|
||||
|
||||
private GameOverPanel _gameOverPanel;
|
||||
|
||||
public override void EnterState()
|
||||
{
|
||||
Container sceneContainer = SceneManager.GetActiveScene().GetSceneContainer();
|
||||
_playerScore = sceneContainer.Resolve<IPlayerScore>();
|
||||
_scoreCounter = 0;
|
||||
|
||||
Context.InputService.EnableMap(ActionMappings.UI);
|
||||
Context.InputService.DebugBindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
|
||||
|
||||
GameOver();
|
||||
|
||||
|
||||
base.EnterState();
|
||||
}
|
||||
|
||||
private void TryToExit(InputAction.CallbackContext context)
|
||||
{
|
||||
ToMainMenu();
|
||||
}
|
||||
|
||||
private async UniTaskVoid GameOver()
|
||||
{
|
||||
await UniTask.WhenAll(
|
||||
Context.UIService.AsyncSwitchPanelTo(UIPanel.GameOver),
|
||||
UniTask.WaitForSeconds(damnTimer)
|
||||
);
|
||||
|
||||
ToMainMenu();
|
||||
await Context.UIService.AsyncSwitchPanelTo(UIPanel.GameOver);
|
||||
|
||||
_gameOverPanel = (GameOverPanel)Context.UIService.CurrentPanel;
|
||||
|
||||
}
|
||||
|
||||
private void ToMainMenu()
|
||||
@@ -36,16 +53,24 @@ namespace Code.App.AppStates
|
||||
Context.StateMachine.SwitchState(AppState.MainMenu)
|
||||
.AllowStateTransition(AppState.Gameplay);
|
||||
}
|
||||
|
||||
// public override void Tick()
|
||||
// {
|
||||
// damnTimer -= Time.deltaTime;
|
||||
// if (damnTimer <= float.Epsilon) ToMainMenu();
|
||||
// }
|
||||
public override void ExitState()
|
||||
private float _scoreCounter;
|
||||
public override void Tick()
|
||||
{
|
||||
damnTimer = 5f;
|
||||
|
||||
if (!_gameOverPanel) return;
|
||||
|
||||
_scoreCounter += Time.deltaTime * 100;
|
||||
// UnityEngine.Debug.Log($"Score: {_scoreCounter}");
|
||||
if((int)_scoreCounter >= _playerScore.Score)
|
||||
{
|
||||
_gameOverPanel.UpdateScoreText(_playerScore.Score);
|
||||
}
|
||||
else _gameOverPanel.UpdateScoreText((int)_scoreCounter);
|
||||
}
|
||||
public override void ExitState()
|
||||
{
|
||||
Context.InputService.DisableMap(ActionMappings.UI);
|
||||
Context.InputService.DebugUnbindAction((int)ActionMappings.UI,(int)UIActions.Continue, TryToExit);
|
||||
|
||||
base.ExitState();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user