예제 #1
0
    public void PerformTransition(SoldierTransition trans)
    {
        if (trans == SoldierTransition.NullTransitionID)
        {
            Debug.LogError("要执行的转换条件为空:" + trans);
            return;
        }

        SoldierStateID nextStateID = mCurrentState.GetOutPutState(trans);

        if (nextStateID == SoldierStateID.NullState)
        {
            Debug.LogError("在转换条件 [" + trans + "] 下, 没有对应的转换状态");
            return;
        }

        foreach (ISoldierState s in mStates)
        {
            if (s.stateID == nextStateID)
            {
                mCurrentState.DoBeforeLeaving();
                mCurrentState = s;
                mCurrentState.DoBeforeEntering();
                return;
            }
        }
    }
예제 #2
0
    public void PerformTransition(SoldierTransition trans)
    {
        if (trans == SoldierTransition.NullTransition)
        {
            Debug.LogError("要执行的转换条件为空");
            return;
        }
        //获取要转换为的状态
        SoldierStateID nextStateID = mCurrentState.GetOutPutState(trans);

        if (nextStateID == SoldierStateID.NullState)
        {
            Debug.Log("要转换的状态ID[" + nextStateID + "]为空");
            return;
        }
        foreach (ISoldierState state in mStates)
        {
            //如果在集合中找到转换为的状态
            if (state.StateID == nextStateID)
            {
                //执行退出当前状态之前的操作
                mCurrentState.DoBeforeLeaving();
                //将当前状态变为将转换的状态
                mCurrentState = state;
                //执行进入当前状态之前的操作
                mCurrentState.DoBeforeEntering();
                break;
            }
        }
    }
예제 #3
0
    public void PerformTransition(SoldierTransition trans)
    {
        if (trans == SoldierTransition.NullTansition)
        {
            Debug.LogError("SoldierFSMSystem Error: 要执行的转换条件" + trans + "不存在"); return;
        }
        SoldierStateID nextStateID = mCurrentState.GetOutPutState(trans);

        if (nextStateID == SoldierStateID.NullState)
        {
            Debug.LogError("SoldierFSMSystem Error: 转换条件" + trans + "下,没有对应的状态"); return;
        }
        foreach (ISoldierState s in mStates)
        {
            if (s.StateID == nextStateID)
            {
                mCurrentState.DoBeforeLeaving();
                mCurrentState = s;
                mCurrentState.DoBeforeEntering();
            }
        }
    }
예제 #4
0
    /// <summary>
    /// 执行转换,切换到对应条件的状态类
    /// </summary>
    /// <param name="transition"></param>
    public void PerformTransition(SoldierTransition transition)
    {
        if (transition == SoldierTransition.NullTransition)
        {
            Debug.LogError("要转换的条件为空 " + transition); return;
        }
        SoldierStateID nextStateID = m_CurrentState.GetOutPutState(transition);

        if (nextStateID == SoldierStateID.NullState)
        {
            Debug.LogError("当前状态 [" + m_CurrentState.StateID + "]" + " 转换条件 [" + transition + "] 没有对应的转换状态");
            return;
        }
        foreach (var s in mLst_States)
        {
            if (s.StateID == nextStateID)
            {
                m_CurrentState.DoBeforeLeaving();
                m_CurrentState = s;
                m_CurrentState.DoBeforeEntering();
                return;
            }
        }
    }