状态机接口笔记
//状态机接口
Public interface IState{
Void Enter(EntityBase entity,params object[] args);
}
//不同状态继承状态机
Public class StateAttack:Istate{
Public void Enter(EntityBase entity,params object[] args ){
}
}
//状态枚举
public enum AniState
{ None,
Idle,
Move,
Attack,
}
Dictionary<AniState,IState> fsm = new Dictionary<AniState,Istate>();
Void Init(){
fsm.Add(AniState,Idle,new StateAttack());
}
//使用状态切换
Void ChangeStatus(EntityBase entity,AniState targetState ,params object[] args){
fsm[targetState].Enter(entity,args);
}