コード例 #1
0
 public void ChangeState(MachineBehaviourState <T> targetState)
 {
     if (targetState == null)
     {
         throw new System.Exception("Can't find target state.");
     }
     targetState.owner = CurrentState.owner;
     PreState          = CurrentState;
     CurrentState.Exit();
     CurrentState = targetState;
     CurrentState.Enter();
 }
コード例 #2
0
 public StateMachine(T owner, MachineBehaviourState <T> firstState, MachineBehaviourState <T> globalState = null)
 {
     if (globalState != null)
     {
         GlobalState       = globalState;
         GlobalState.owner = owner;
         GlobalState.Enter();
     }
     CurrentState       = firstState;
     CurrentState.owner = owner;
     CurrentState.Enter();
 }