64 lines
1.6 KiB
C#
64 lines
1.6 KiB
C#
using Cysharp.Threading.Tasks;
|
|
using SepCore.Definition;
|
|
using GameFramework.Fsm;
|
|
using GameFramework.Procedure;
|
|
using SepCore.UI;
|
|
using UnityGameFramework.Runtime;
|
|
|
|
namespace SepCore.Procedure
|
|
{
|
|
public class GameStateShop : GameStateBase
|
|
{
|
|
public override GameStateType GameStateType => GameStateType.Shop;
|
|
|
|
private ProcedureGame _procedureGame;
|
|
|
|
public bool ShopFinish { get; set; }
|
|
|
|
#region FSM
|
|
|
|
public override void OnInit(ProcedureGame master)
|
|
{
|
|
Log.Debug("GameStateShop::OnInit");
|
|
_procedureGame = master;
|
|
|
|
var shopFormUseCase =
|
|
new ShopUseCase(_procedureGame.Player, _procedureGame.CurrentLevel, () => ShopFinish = true);
|
|
GameEntry.UIRouter.BindUIUseCase(UIFormType.ShopForm, shopFormUseCase);
|
|
}
|
|
|
|
public override void OnEnter()
|
|
{
|
|
Log.Debug("GameStateShop::OnEnter");
|
|
|
|
ShopFinish = false;
|
|
|
|
GameEntry.UIRouter.OpenUIAsync(UIFormType.ShopForm).Forget();
|
|
}
|
|
|
|
public override void OnUpdate(float elapseSeconds, float realElapseSeconds)
|
|
{
|
|
if (ShopFinish)
|
|
{
|
|
_procedureGame.ShopToBattle();
|
|
}
|
|
}
|
|
|
|
public override void OnLeave()
|
|
{
|
|
Log.Debug("GameStateShop::OnLeave");
|
|
|
|
GameEntry.UIRouter.CloseUIAsync(UIFormType.ShopForm).Forget();
|
|
}
|
|
|
|
public override void OnDestroy()
|
|
{
|
|
_procedureGame = null;
|
|
|
|
Log.Debug("GameStateShop::OnDestroy");
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|