Beispiel #1
0
 public void DeleteTransition(FireMonsterTransition trans)
 {
     if (mMap.ContainsKey(trans) == false)
     {
         Debug.LogError("删除转换条件的时候, 转换条件:[" + trans + "]不存在"); return;
     }
     mMap.Remove(trans);
 }
Beispiel #2
0
 public FireMonsterStateID GetOutPutState(FireMonsterTransition trans)
 {
     if (mMap.ContainsKey(trans) == false)
     {
         return(FireMonsterStateID.NullState);
     }
     else
     {
         return(mMap[trans]);
     }
 }
Beispiel #3
0
 public void AddTransition(FireMonsterTransition trans, FireMonsterStateID id)
 {
     if (trans == FireMonsterTransition.NullTransition)
     {
         Debug.LogError("FireMonsterState Error: trans不能为空"); return;
     }
     if (id == FireMonsterStateID.NullState)
     {
         Debug.LogError("FireMonsterState Error: 状态ID不能为空"); return;
     }
     if (mMap.ContainsKey(trans))
     {
         Debug.LogError("FireMonsterState Error: " + trans + " 已经添加上了"); return;
     }
     mMap.Add(trans, id);
 }
Beispiel #4
0
    public void PerformTransition(FireMonsterTransition trans)
    {
        if (trans == FireMonsterTransition.NullTransition)
        {
            Debug.LogError("要执行的转换条件为空 : " + trans); return;
        }
        FireMonsterStateID nextStateID = mCurrentState.GetOutPutState(trans);

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