public override void ChangeState(RoleStateType nextState)
 {
     if (CurrentRoleStateType == nextState)
     {
         return;
     }
     if (CurrentRoleState != null)
     {
         CurrentRoleState.OnLevel();
     }
     CurrentRoleStateType = nextState;
     CurrentRoleState     = m_StateDic[CurrentRoleStateType];
     CurrentRoleState.OnEnter();
 }
Exemplo n.º 2
0
 public RoleFSMMgr(RoleCtrl roleCtrl, Action onDestory, Action onDie)
 {
     this.CurRoleCtrl = roleCtrl;
     states           = new Dictionary <RoleState, RoleStateAbstract>();
     //装载状态
     //states.Add(RoleState.Idle, new RoleStateIdle(this));
     //states.Add(RoleState.Run, new RoleStateRun(this));
     //states.Add(RoleState.Attack, new RoleStateAttack(this));
     //states.Add(RoleState.Hurt, new RoleStateHurt(this));
     //states.Add(RoleState.Die, new RoleStateDie(this));
     //states.Add(RoleState.Select, new RoleStateSelect(this));
     if (states.ContainsKey(CurrentRoleStateEnum))
     {
         CurrentRoleState = states[CurrentRoleStateEnum];
     }
 }
Exemplo n.º 3
0
        public void ChangeState(RoleState nextState)
        {
            //如果在当前状态则返回,但是当前状态是Idle Attack 可以进来
            //攻击的限制条件 是否僵值, Idle 的限制条件是当前的Idle状态
            if (CurrentRoleStateEnum == nextState && CurrentRoleStateEnum != RoleState.Idle && CurrentRoleStateEnum != RoleState.Attack)
            {
                return;
            }

            //当前状态退出
            if (CurrentRoleState != null)
            {
                CurrentRoleState.OnLevel();
            }
            //替换当前状态
            CurrentRoleStateEnum = nextState;
            CurrentRoleState     = states[CurrentRoleStateEnum];
            if (CurrentRoleStateEnum == RoleState.Idle)
            {
                CurIdleType = NextIdleType;
            }
            //当前状态进入
            CurrentRoleState.OnEnter();
        }
 public void AddState(RoleStateAbstract state)
 {
     m_StateDic.Add(state.RoleStateType, state);
 }