コード例 #1
0
    public void DeleteState(SoldierStateID stateID)
    {
        if (stateID == SoldierStateID.NullState)
        {
            Debug.LogError("要删除的状态ID为空" + stateID); return;
        }

        foreach (ISoldierState s in mStates)
        {
            if (s.stateID == stateID)
            {
                mStates.Remove(s); return;
            }
        }
        Debug.LogError("要删除的stateID不存在集合中:" + stateID);
    }
コード例 #2
0
 public void AddTransition(SoldierTransition trans, SoldierStateID id)
 {
     if (trans == SoldierTransition.NullTransition)
     {
         Debug.LogError("SoldierStateError: trans不能为空"); return;
     }
     if (id == SoldierStateID.NullState)
     {
         Debug.LogError("SoldierStateError: id不能为空"); return;
     }
     if (mMap.ContainsKey(trans))
     {
         Debug.LogError("SoldierStateError: " + trans + "已经存在"); return;
     }
     mMap.Add(trans, id);
 }
コード例 #3
0
 public void AddTransition(SoldierTransition trans, SoldierStateID stateID)
 {
     if (trans == SoldierTransition.NullTransition)
     {
         Debug.LogError("SoldierState Error: trans 不能为空"); return;
     }
     if (stateID == SoldierStateID.NullState)
     {
         Debug.LogError("SoldierState Error: stateID 不能为空"); return;
     }
     if (m_Map.ContainsKey(trans))
     {
         Debug.LogError("SoldierState Error: " + trans + " 已经添加上了"); return;
     }
     m_Map.Add(trans, stateID);
 }
コード例 #4
0
 /** 添加转换条件 */
 public void AddTransition(SoldierTransition trans, SoldierStateID id)
 {
     if (trans == SoldierTransition.NullTansition)
     {
         Debug.LogError("SoldierState Error: [添加] 转换条件不能为空"); return;
     }
     if (id == SoldierStateID.NullState)
     {
         Debug.LogError("SoldierState Error: [添加] 状态ID不能为空"); return;
     }
     if (mMap.ContainsKey(trans))
     {
         Debug.LogError("SoldierState Error: [添加] 转换条件" + trans + "已被添加"); return;
     }
     mMap.Add(trans, id);
 }
コード例 #5
0
 public void AddTransition(SoldierTransition trans, SoldierStateID stateID)
 {
     if (trans == SoldierTransition.NullTransition)
     {
         Debug.LogError("SoldierState Error : trans不能为空");
     }
     if (stateID == SoldierStateID.NullState)
     {
         Debug.LogError("SoldierState Error:id状态Id不能为空");
     }
     if (map.ContainsKey(trans))
     {
         Debug.LogError("SoldierState Error " + trans + "已经添加上");
     }
     map.Add(trans, stateID);
 }
コード例 #6
0
 public void deleteState(SoldierStateID id)
 {
     if (id == SoldierStateID.NullState)
     {
         Debug.LogError("id is null");
         return;
     }
     foreach (ISoldierState s in mStates)
     {
         if (s.StateID == id)
         {
             mStates.Remove(s);
             return;
         }
     }
     Debug.LogError("id is not exist");
 }
コード例 #7
0
    /// <summary>
    /// 删除状态
    /// </summary>
    /// <param name="stateID"></param>
    public void DeleteState(SoldierStateID stateID)
    {
        if (stateID == SoldierStateID.NullState)
        {
            Debug.LogError("状态为空,不删除 " + stateID); return;
        }

        foreach (var s in mLst_States)
        {
            if (s.StateID == stateID)
            {
                mLst_States.Remove(s);
                return;
            }
        }

        Debug.LogError("要删除的ID不存在于集合中 id = " + stateID);
    }
コード例 #8
0
    public void DeleteState(SoldierStateID id)
    {
        if (id == SoldierStateID.NullState)
        {
            Debug.Log("DeleteState 无法删除 NullState ");
            return;
        }

        for (int i = 0; i < statesList.Count; i++)
        {
            if (statesList[i].StateID == id)
            {
                statesList.RemoveAt(i);
                return;
            }
        }
        Debug.Log("DeleteState" + id + " 不存在 无法删除");
    }
コード例 #9
0
ファイル: ISoldierState.cs プロジェクト: hoppyNaut/RedAlbert
 public void AddTransition(SoldierTransition trans, SoldierStateID id)
 {
     if (trans == SoldierTransition.NullTransition)
     {
         Debug.LogError("SoldierState Error:trans is null");
         return;
     }
     if (id == SoldierStateID.NullState)
     {
         Debug.LogError("SoldierState Error:id is null");
         return;
     }
     if (mMap.ContainsKey(trans))
     {
         Debug.LogError("SoldierState Error: " + trans + " is already included");
         return;
     }
     mMap.Add(trans, id);
 }
コード例 #10
0
        public void DeleteState(SoldierStateID stateID)
        {
            if (stateID == SoldierStateID.NullState)
            {
                Debug.LogError(GetType() + "/DeleteState()/ state is NullState ");
                return;
            }

            foreach (ISoldierState s in mStateLst)
            {
                if (s.StateID == stateID)
                {
                    mStateLst.Remove(s);
                    return;
                }
            }

            Debug.LogError(GetType() + "/DeleteState()/ stateID is not contained: " + stateID.ToString());
        }
コード例 #11
0
ファイル: ISoldierState.cs プロジェクト: s344951241/design
 public void addTransition(SoldierTransition trans, SoldierStateID id)
 {
     if (trans == SoldierTransition.NullTransition)
     {
         Debug.LogError("SoldierState Error:trans can't null");
         return;
     }
     if (id == SoldierStateID.NullState)
     {
         Debug.LogError("SoldierState Error:id can't null");
         return;
     }
     if (map.ContainsKey(trans))
     {
         Debug.LogError("SoldierState Error" + trans + "is already add");
         return;
     }
     map.Add(trans, id);
 }
コード例 #12
0
    /// <summary>
    /// This method delete a state from the FSM List if it exists,
    ///   or prints an ERROR message if the state was not on the List.
    /// </summary>
    public void DeleteState(SoldierStateID id)
    {
        // Check for NullState before deleting
        if (id == SoldierStateID.NullStateID)
        {
            Debug.LogError("SoldierFSM ERROR: NullStateID is not allowed for a real state");
            return;
        }

        // Search the List and delete the state if it's inside it
        foreach (SoldierFSMState state in states)
        {
            if (state.ID == id)
            {
                states.Remove(state);
                return;
            }
        }
        Debug.LogError("SoldierFSM ERROR: Impossible to delete state " + id.ToString() +
                       ". It was not on the list of states");
    }
コード例 #13
0
    //添加状态转换键值对
    public void AddTransition(SoldierTransition trans, SoldierStateID id)
    {
        if (trans == SoldierTransition.NullTransition)
        {
            Debug.LogError("转换条件不能为NullTransition");
            return;
        }

        if (id == SoldierStateID.NullStateID)
        {
            Debug.LogError("转换状态不能为NullStateID");
            return;
        }

        if (map.ContainsKey(trans))
        {
            Debug.LogError("已经存在 " + trans);
            return;
        }

        map.Add(trans, id);
    }
コード例 #14
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();
            }
        }
    }
コード例 #15
0
    public void PerformTransition(SoldierTransition trans)
    {
        if (trans == SoldierTransition.NullTransition)
        {
            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();
            }
        }
    }
コード例 #16
0
    /// <summary>
    /// 添加状态转换
    /// </summary>
    /// <param name="trans">转换条件</param>
    /// <param name="id">输出的状态ID</param>
    public void AddTransition(SoldierTransition trans, SoldierStateID id)
    {
        if (trans == SoldierTransition.NullTransition)
        {
            Debug.LogError("SoldierState Error: trans转换条件不能为空");
            return;
        }

        if (id == SoldierStateID.NullStateID)
        {
            Debug.LogError("SoldierState Error: id状态ID不能为空");
            return;
        }

        if (mMap.ContainsKey(trans))
        {
            Debug.LogError("SoldierState Error:" + trans + "已经添加了");
            return;
        }//以上为安全校验

        mMap.Add(trans, id);
    }
コード例 #17
0
        public void AddTransition(SoldierTransition trans, SoldierStateID stateId)
        {
            if (trans == SoldierTransition.NullTansition)
            {
                Debug.LogError(GetType() + "/AddTransition()/ SoldierTransition is NullTansition ");
                return;
            }

            if (stateId == SoldierStateID.NullState)
            {
                Debug.LogError(GetType() + "/AddTransition()/ stateId is NullState ");
                return;
            }

            if (mMap.ContainsKey(trans))
            {
                Debug.LogError(GetType() + "/AddTransition()/ The trans is Contained in mMap");
                return;
            }

            mMap.Add(trans, stateId);
        }
コード例 #18
0
        public void AddTransition(SoldierTransition trans, SoldierStateID id)
        {
            if (trans == SoldierTransition.NullTransition)
            {
                Debug.LogError("SoldierState Error: trans没有状态");
                return;
            }

            if (id == SoldierStateID.NullState)
            {
                Debug.LogError("SoldierState Error:ID状态不能为空");
                return;
            }

            if (mMap.ContainsKey(trans))
            {
                Debug.LogError("SoldierState Error:" + trans + "已经添加上了");
                return;
            }

            //将状态添加到字典中
            mMap.Add(trans, id);
        }
コード例 #19
0
    /// <summary>
    /// This method tries to change the state the FSM is in based on
    /// the current state and the transition passed. If current state
    ///  doesn't have a target state for the transition passed,
    /// an ERROR message is printed.
    /// </summary>
    public void PerformTransition(SoldierTransition trans)
    {
        // Check for NullTransition before changing the current state
        if (trans == SoldierTransition.NullTransition)
        {
            Debug.LogError("SoldierFSM ERROR: NullTransition is not allowed for a real transition");
            return;
        }

        // Check if the currentState has the transition passed as argument
        SoldierStateID id = currentState.GetOutputState(trans);

        if (id == SoldierStateID.NullStateID)
        {
            Debug.LogError("SoldierFSM ERROR: State " + currentStateID.ToString() + " does not have a target state " +
                           " for transition " + trans.ToString());
            return;
        }

        // Update the currentStateID and currentState
        currentStateID = id;
        foreach (SoldierFSMState state in states)
        {
            if (state.ID == currentStateID)
            {
                // Do the post processing of the state before setting the new one
                currentState.DoBeforeLeaving();

                currentState = state;

                // Reset the state to its desired condition before it can reason or act
                currentState.DoBeforeEntering();
                break;
            }
        }
    } // PerformTransition()
コード例 #20
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;
            }
        }
    }
コード例 #21
0
 /// <summary>
 /// 添加状态,并设置第一个添加的为初始状态
 /// </summary>
 /// <param name="state"></param>
 public void AddState(ISoldierState state)
 {
     if (state == null)
     {
         Debug.LogError("添加的状态为空!");
         return;
     }
     if (mStates.Count == 0)
     {
         mStates.Add(state);
         mCurrentState   = state;
         mCurrentStateID = state.stateID;
         return;
     }
     foreach (ISoldierState s in mStates)
     {
         if (s.stateID == state.stateID)
         {
             Debug.LogError("要添加的状态ID:" + "[" + s.stateID.ToString() + "]" + "已经添加了");
             return;
         }
     }
     mStates.Add(state);
 }
コード例 #22
0
 public SoldierState(SoldierFSMSystem system, SoldierStateID stateID, Character character)
 {
     System    = system;
     StateID   = stateID;
     Character = character;
 }