namespace LTGame { public abstract class NBaseState { public int id { get; protected set; } public bool canReEnter { get; protected set; } public bool isFinished { get; protected set; } public int nextState { get; protected set; } public float passTime { get; protected set; } public float deltaTime { get; protected set; } public NBaseState(int id) { this.canReEnter = true; this.id = id; } public virtual void Enter(NBaseState exitState, object param) { this.isFinished = false; this.nextState = 0; this.deltaTime = 0; this.passTime = 0; this._OnEnter(exitState, param); } public virtual void Run(float dt) { if (this.isFinished) return; this.deltaTime = dt; this.passTime += this.deltaTime; this._OnRunning(); } public virtual void Exit(NBaseState enterState, object param) { this._OnExit(enterState, param); } public int GetNextState() { if (this.isFinished) { return this.nextState; } return 0; } protected abstract void _OnEnter(NBaseState exitState, object param); protected abstract void _OnRunning(); protected abstract void _OnExit(NBaseState exitState, object param); } }