Ejemplo n.º 1
0
    /// <summary>切换状态</summary>
    /// <param name="newState">新状态</param>
    public void ChangeState(RoleState newState)
    {
        if (CurrRoleCtrl.CurrRoleType == RoleType.Monster)
        {
            //Debug.Log(newState.ToString());
        }
        //因为休闲 战斗 都有多种状态 所以此处需要排除 休闲 攻击状态(因为可能需要从普通休闲切换到战斗休闲及技能切换)
        if (CurrRoleStateEnum == newState && CurrRoleStateEnum != RoleState.Idle && CurrRoleStateEnum != RoleState.Attack)
        {
            return;
        }
        //调用以前状态的离开方法
        if (m_CurrRoleState != null)
        {
            m_CurrRoleState.OnLeave();
        }

        //更改当前状态枚举
        CurrRoleStateEnum = newState;

        //更改当前状态
        m_CurrRoleState = m_RoleStateDic[newState];

        if (CurrRoleStateEnum == RoleState.Idle)
        {
            //给当前待机状态赋值
            CurrIdleState = ToIdleState;
        }

        //调用新状态的进入方法
        m_CurrRoleState.OnEnter();
    }
Ejemplo n.º 2
0
    /// <summary>
    /// 切换状态
    /// </summary>
    /// <param name="newState">新状态</param>
    public void ChangState(RoleState newState)
    {
        if (CurrRoleStateEnum == newState)
        {
            return;
        }

        //调用以前状态的离开方法
        if (m_CurrRoleState != null)
        {
            m_CurrRoleState.OnLeave();
        }

        //更改当前状态枚举
        CurrRoleStateEnum = newState;

        //更改当前状态
        m_CurrRoleState = m_RoleStateDic[newState];

        //调入新状态的进入方法
        m_CurrRoleState.OnEnter();
    }
Ejemplo n.º 3
0
    /// <summary>
    ///  切换状态
    /// </summary>
    /// <param name="newState">新的状态</param>
    public void ChangeState(RoleStateType newState)
    {
        if (newState == RoleStateType)
        {
            return;
        }

        if (m_RoleState == null)
        {
            return;
        }
        //离开之前的状态
        m_RoleState.OnLeave();

        //将当前状态更新为新的状态
        RoleStateType = newState;

        m_RoleState = m_RoleStateDic[newState];

        //调用新状态的进入方法
        m_RoleState.OnEnter();
    }