Slightly rework death screen
This commit is contained in:
@@ -15,17 +15,21 @@ public partial class GameLogic
|
||||
var gameRepo = Get<IGameRepo>();
|
||||
gameRepo.IsPaused.Sync += OnIsPaused;
|
||||
gameRepo.DoubleExpTimeStart += OnDoubleExpTimeStart;
|
||||
gameRepo.Ended += OnGameEnded;
|
||||
});
|
||||
OnDetach(() =>
|
||||
{
|
||||
var gameRepo = Get<IGameRepo>();
|
||||
gameRepo.IsPaused.Sync -= OnIsPaused;
|
||||
gameRepo.DoubleExpTimeStart -= OnDoubleExpTimeStart;
|
||||
gameRepo.Ended -= OnGameEnded;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnDoubleExpTimeStart(int lengthOfTimeInSeconds) => Output(new Output.DoubleExpTimeStart(lengthOfTimeInSeconds));
|
||||
|
||||
private void OnGameEnded() => Output(new Output.ShowLostScreen());
|
||||
|
||||
public void OnIsPaused(bool isPaused) => Output(new Output.SetPauseMode(isPaused));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ public interface IGameRepo : IDisposable
|
||||
|
||||
public void CloseInventory();
|
||||
|
||||
public void GameEnded();
|
||||
|
||||
public double ExpRate { get; }
|
||||
}
|
||||
|
||||
@@ -109,7 +111,7 @@ public class GameRepo : IGameRepo
|
||||
CloseInventoryEvent?.Invoke();
|
||||
}
|
||||
|
||||
public void OnGameEnded()
|
||||
public void GameEnded()
|
||||
{
|
||||
Pause();
|
||||
Ended?.Invoke();
|
||||
|
||||
@@ -8,20 +8,20 @@ public partial class GameLogic
|
||||
{
|
||||
[Meta]
|
||||
public partial record Playing : State,
|
||||
IGet<Input.GameOver>,
|
||||
IGet<Input.AskForTeleport>,
|
||||
IGet<Input.PauseGame>,
|
||||
IGet<Input.GoToOverworld>
|
||||
{
|
||||
public Playing()
|
||||
{
|
||||
OnAttach(() => Output(new Output.StartGame()));
|
||||
OnAttach(() =>
|
||||
{
|
||||
Output(new Output.StartGame());
|
||||
});
|
||||
}
|
||||
|
||||
public void OnEnded() => Input(new Input.GameOver());
|
||||
|
||||
public Transition On(in Input.GameOver input) => To<Quit>();
|
||||
|
||||
public Transition On(in Input.AskForTeleport input) => To<AskForTeleport>();
|
||||
|
||||
public Transition On(in Input.PauseGame input) => To<Paused>();
|
||||
|
||||
Reference in New Issue
Block a user