Пример #1
0
    public void AddState(IEliteMonsterState state)
    {
        if (state == null)
        {
            Debug.LogError("要添加的状态为空"); return;
        }

        if (mStates.Count == 0)
        {
            mStates.Add(state);
            mCurrentState = state;
            mCurrentState.DoBeforeEntering();
            return;
        }

        foreach (IEliteMonsterState s in mStates)
        {
            if (s.stateID == state.stateID)
            {
                Debug.LogError("要添加的状态ID[" + s.stateID + "]已经添加"); return;
            }
        }

        mStates.Add(state);
    }
Пример #2
0
    public void PerformTransition(EliteMonsterTransition trans)
    {
        if (trans == EliteMonsterTransition.NullTransition)
        {
            Debug.LogError("要执行的转换条件为空 : " + trans); return;
        }
        EliteMonsterStateID nextStateID = mCurrentState.GetOutPutState(trans);

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