Example #1
0
 public void AddState(IEnemyState state)
 {
     if (state == null)
     {
         return;
     }
     if (mStates.Count == 0)
     {
         mStates.Add(state);
         currentState = state;
         currentState.DoBeforeEntering();
         return;
     }
     foreach (IEnemyState s in mStates)
     {
         if (s.stateID == state.stateID)
         {
             return;
         }
     }
     mStates.Add(state);
 }
Example #2
0
        public void PerformTransition(EnemyTransition trans)
        {
            if (trans == EnemyTransition.NullTansition)
            {
                return;
            }
            EnemyStateID nextStateID = currentState.GetOutPutState(trans);

            if (nextStateID == EnemyStateID.NullState)
            {
                return;
            }
            foreach (IEnemyState s in mStates)
            {
                if (s.stateID == nextStateID)
                {
                    currentState.DoBeforeLeaving();
                    currentState = s;
                    currentState.DoBeforeEntering();
                    return;
                }
            }
        }