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

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