IndieGame/client/Assets/Ether/Scripts/Module/StateMachine/StateBase.cs
DOBEST\zhaoyingjie f242607587 初始化工程
2024-10-11 10:12:15 +08:00

53 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace Ether
{
/// <summary>
/// 状态类型
/// </summary>
public enum StateType
{
Loop = 0, //循环如idle,walk,run等
Once = 1, //一次:如技能播放等,结束后自动切换会默认状态
}
/// <summary>
/// 状态所处阶段
/// </summary>
public enum StateStage
{
Playing = 0, //播放中
Over = 1, //结束
}
public abstract class StateBase : IDisposable
{
protected StateMachine machine;
private StateType stateType = StateType.Loop;
public virtual StateType StateType { get { return stateType; } set { stateType = value; } }
public void Init(StateMachine stateMachine)
{
this.machine = stateMachine;
OnInit();
}
public virtual void OnInit() { }
public abstract void EnterState();
public abstract void ExitState();
public virtual bool CheckStateIsCanSwitch()
{
return true;
}
public virtual void Dispose()
{
PoolManager.Inst.Push(this);
}
}
}