Exemple #1
0
 public void DeleteState(NpcStateID stateID)
 {
     if (stateID == NpcStateID.NullState)
     {
         Debug.LogError("要删除的状态ID为空" + stateID); return;
     }
     foreach (INpcState s in mStates)
     {
         if (s.stateID == stateID)
         {
             mStates.Remove(s); return;
         }
     }
     Debug.LogError("要删除的StateID不存在集合中:" + stateID);
 }
Exemple #2
0
 public void AddTransition(NpcTransition trans, NpcStateID id)
 {
     if (trans == NpcTransition.NullTansition)
     {
         Debug.LogError("NpcState Error: trans不能为空"); return;
     }
     if (id == NpcStateID.NullState)
     {
         Debug.LogError("NpcState Error: 状态ID不能为空"); return;
     }
     if (mMap.ContainsKey(trans))
     {
         Debug.LogError("NpcState Error: " + trans + " 已经添加上了"); return;
     }
     mMap.Add(trans, id);
 }
Exemple #3
0
    public void PerformTransition(NpcTransition trans)
    {
        if (trans == NpcTransition.NullTansition)
        {
            Debug.LogError("要执行的转换条件为空 : " + trans); return;
        }
        NpcStateID nextStateID = mCurrentState.GetOutPutState(trans);

        if (nextStateID == NpcStateID.NullState)
        {
            Debug.LogError("在转换条件 [" + trans + "] 下,没有对应的转换状态"); return;
        }
        foreach (INpcState s in mStates)
        {
            if (s.stateID == nextStateID)
            {
                mCurrentState.DoBeforeLeaving();
                mCurrentState = s;
                mCurrentState.DoBeforeEntering();
                return;
            }
        }
    }