chore: initial commit
This commit is contained in:
141
Assets/Scripts/Core/BuiltinGameStates.cs
Normal file
141
Assets/Scripts/Core/BuiltinGameStates.cs
Normal file
@@ -0,0 +1,141 @@
|
||||
using System.Collections.Generic;
|
||||
using BaseGames.Core;
|
||||
using BaseGames.Core.Events;
|
||||
|
||||
namespace BaseGames.Core.States
|
||||
{
|
||||
/// <summary>初始化状态(应用启动时的第一个状态)。</summary>
|
||||
public class InitializingState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.Initializing;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId> { GameStates.MainMenu };
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>主菜单状态。</summary>
|
||||
public class MainMenuState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.MainMenu;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId> { GameStates.LoadingScene };
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>场景加载中状态。</summary>
|
||||
public class LoadingSceneState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.LoadingScene;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId> { GameStates.MainMenu, GameStates.Gameplay };
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>正常游玩状态。</summary>
|
||||
public class GameplayState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.Gameplay;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId>
|
||||
{
|
||||
GameStates.LoadingScene,
|
||||
GameStates.BossFight,
|
||||
GameStates.Paused,
|
||||
GameStates.Dead,
|
||||
GameStates.Cutscene,
|
||||
};
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>Boss 战状态。</summary>
|
||||
public class BossFightState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.BossFight;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId>
|
||||
{
|
||||
GameStates.LoadingScene,
|
||||
GameStates.Gameplay,
|
||||
GameStates.Paused,
|
||||
GameStates.Dead,
|
||||
};
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>暂停状态。</summary>
|
||||
public class PausedState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.Paused;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId>
|
||||
{
|
||||
GameStates.Gameplay,
|
||||
GameStates.BossFight,
|
||||
GameStates.MainMenu,
|
||||
};
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>死亡状态。</summary>
|
||||
public class DeadState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.Dead;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId> { GameStates.LoadingScene, GameStates.GameOver };
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>过场动画状态。</summary>
|
||||
public class CutsceneState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.Cutscene;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId> { GameStates.Gameplay };
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
|
||||
/// <summary>Game Over 状态(SteelSoul 清档用)。</summary>
|
||||
public class GameOverState : IGameState
|
||||
{
|
||||
public GameStateId Id => GameStates.GameOver;
|
||||
|
||||
public IReadOnlyCollection<GameStateId> ValidNextStates { get; } =
|
||||
new HashSet<GameStateId> { GameStates.MainMenu };
|
||||
|
||||
public void OnEnter(GameStateId prev) { }
|
||||
public void OnExit(GameStateId next) { }
|
||||
public void Tick(float dt) { }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user