public override void ChangeState(RoleStateType nextState)
 {
     if (CurrentRoleStateType == nextState)
     {
         return;
     }
     if (CurrentRoleState != null)
     {
         CurrentRoleState.OnLevel();
     }
     CurrentRoleStateType = nextState;
     CurrentRoleState     = m_StateDic[CurrentRoleStateType];
     CurrentRoleState.OnEnter();
 }
Ejemplo n.º 2
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();
        }