Пример #1
0
    /// <summary>
    /// 删除转换.
    /// </summary>
    /// <param name="trans">Trans.</param>
    public void DeleteTransition(EBehaviourTransition trans)
    {
        // 不要传空的进来哦.
        if (trans == EBehaviourTransition.None)
        {
            Debug.LogError("FSMState ERROR: NullTransition is not allowed for a real transition");
            return;
        }

        // Check if the pair is inside the map before deleting
        if (TransitionMap.ContainsKey(trans))
        {
            TransitionMap.Remove(trans);
            return;
        }
        Debug.LogError("FSMState ERROR: Transition " + trans.ToString() + " passed to " + _StateID.ToString() +
                       " was not on the state's transition list");
    }
Пример #2
0
    /// <summary>
    /// 添加切换的状态.
    /// </summary>
    /// <param name="trans">Trans.</param>
    /// <param name="stateID">State I.</param>
    public void AddTransition(EBehaviourTransition trans, EBehaviourStateID stateID)
    {
        // 不要传空的进来哦.
        if (trans == EBehaviourTransition.None)
        {
            Debug.LogError("FSMState ERROR: NullTransition is not allowed for a real transition");
            return;
        }

        if (stateID == EBehaviourStateID.None)
        {
            Debug.LogError("FSMState ERROR: NullStateID is not allowed for a real ID");
            return;
        }

        // Since this is a Deterministic FSM,
        // check if the current transition was already inside the map
        if (TransitionMap.ContainsKey(trans))
        {
            Debug.LogError("FSMState ERROR: State " + stateID.ToString() + " already has transition " + trans.ToString() +
                           "Impossible to assign to another state");
            return;
        }

        TransitionMap.Add(trans, stateID);
    }