コード例 #1
0
ファイル: FSMSystem.cs プロジェクト: mengtest/FaceMask
    //执行转换
    public void PerformTransition(Transition trans)
    {
        if (trans == Transition.NullTransition)
        {
            Debug.LogError("无法执行NullTransition");
        }
        //得到StateID
        StateID id = currentState.GetOutputState(trans);

        if (id == StateID.NullStateID)
        {
            Debug.LogWarning("当前状态" + currentState + "无法根据" + trans + "状态发生转换");
        }
        if (states.ContainsKey(id) == false)
        {
            Debug.LogError(id + "不存在");
        }
        //根据StateID得到state
        FSMState state = states[id];

        currentState.DoAfterLeaving();
        //将当前状态设为state
        currentState = state;
        //将当前状态ID设为id
        currentStateID = id;
        currentState.DoBeforeEntering();
    }
コード例 #2
0
ファイル: FsmSystem.cs プロジェクト: Cucurbit1988/FSM
    /// <summary>
    /// 状态切换
    /// </summary>
    /// <param name="trans">条件.</param>
    public void PerformTransiton(Transition trans)
    {
        if (trans == Transition.NullTransiton)
        {
            Debug.LogError("无法执行空的转换条件");
        }
        StateID id = currenState.GetOutputState(trans);

        if (id == StateID.NullStateId)
        {
            Debug.LogWarning("当前状态" + currentStateID + "无法根据转换条件" + trans + "发生转换");
            return;
        }
        if (states.ContainsKey(id) == false)
        {
            Debug.LogError("在状态里面不存在状态" + id + ",无法进行状态转换!"); return;
        }
        FSMState state = states [id];

        //因为要发生转换所以调用当前状态的离开函数
        currenState.DoAfterLeaving();
        currenState    = state;
        currentStateID = id;
        //调用新状态的进入函数
        currenState.DobeforeEntering();
    }
コード例 #3
0
    public void PerformTransition(int _transition)
    {
        if (_transition == FSMState.NULL_TRANSITION)
        {
            return;
        }

        int stateID = m_currentState.GetOutputState(_transition);

        if (stateID == FSMState.NULL_STATE_ID)
        {
            return;
        }

        if (!m_states.ContainsKey(stateID))
        {
            return;
        }

        FSMState state = m_states[stateID];

        m_currentState.DoAfterLeaving();
        m_currentState   = state;
        m_currentStateID = stateID;
        m_currentState.DoBeforeEntering();
    }
コード例 #4
0
ファイル: FSMSystem.cs プロジェクト: Shiyingzhi/DarkGod
    public void PerformTransition(Transition trans)
    {
        if (trans == Transition.Null)
        {
            Debug.LogWarning("trans为null无法发生转换"); return;
        }
        StateID id = FSMstate.GetStateID(trans);

        if (id == StateID.Null)
        {
            Debug.LogWarning("id为null,无法发生转换"); return;
        }
        if (StateDic.ContainsKey(id))
        {
            FSMState state = StateDic[id];
            FSMstate.DoAfterLeaving();
            FSMstate = state;
            stateId  = id;
            FSMstate.DoBeforeEntering();
        }
        else
        {
            Debug.LogWarning("要转换的" + id + "不存在");
        }
    }
コード例 #5
0
    /// <summary>
    /// 执行转换条件
    /// </summary>
    /// <param name="trans"></param>
    public void PerformTransition(Transition trans)
    {
        if (trans == Transition.NullTRansition)
        {
            Debug.LogError("无法执行空的转换条件");
            return;
        }
        StateID id = currentState.GetOutputState(trans);

        Debug.Log(id);
        if (id == StateID.NullStateID)
        {
            Debug.LogWarning("当前状态" + currentState + "无法发生条件转换" + trans);
            return;
        }
        if (states.ContainsKey(id) == false)
        {
            Debug.LogError("在状态机里不存在状态" + id);
        }
        FSMState state = states[id];

        currentState.DoAfterLeaving();
        currentState   = state;
        currentStateID = state.ID;
        currentState.DoBeforeEntering();
    }
コード例 #6
0
ファイル: FSMSystem.cs プロジェクト: zcCarl/EntitasProject
    /// <summary>
    /// 执行转换
    /// </summary>
    /// <param name="trans">转换条件</param>
    public void PerformTransition(Transition trans)
    {
        if (trans == Transition.NullTransition)
        {
            Debug.LogError(trans + "为空"); return;
        }
        StateID targetID = currentState.GetTargetStateID(trans);

        if (states.ContainsKey(targetID) == false)
        {
            Debug.LogError(targetID + "不存在"); return;
        }
        FSMState targetState = states[targetID];

        currentState.DoAfterLeaving();
        targetState.DoBeforeEntering();
        currentState = targetState;
    }
コード例 #7
0
    public void PerformTransition(Transition trans)//执行状态转换
    {
        if (trans == Transition.NullTransition)
        {
            Debug.LogError("无法执行空的转换条件"); return;
        }

        StateID id = currentState.GetOutputState(trans);

        if (id == StateID.NullStateID)
        {
            Debug.LogWarning("当前状态" + currentStateID + "无法根据条件转换" + trans + "发生转换"); return;
        }
        if (states.ContainsKey(id) == false)
        {
            Debug.LogError("在状态机里面不存在状态" + id + ",无法进行转换!"); return;
        }
        FSMState state = states[id];

        currentState.DoAfterLeaving();
        currentState   = state;
        currentStateID = id;
        currentState.DoBeforeEntering();
    }