コード例 #1
0
            public SimpleState AddState()
            {
                SimpleState newState = new SimpleState();

                States.Add(newState);
                return(newState);
            }
コード例 #2
0
 public StateTransition(SimpleState from, SimpleState to)
 {
     _fromState         = from;
     _toState           = to;
     _onTransitionStart = new WriteAction();
     _onTransitionEnd   = new WriteAction();
     OnTransitionStart  = _onTransitionStart;
     OnTransitionEnd    = _onTransitionEnd;
 }
コード例 #3
0
 public SimpleState AddState(SimpleState addedState)
 {
     if (States.Contains(addedState))
     {
         return(addedState);
     }
     States.Add(addedState);
     return(addedState);
 }
コード例 #4
0
 public void RemoveTransition(SimpleState toState)
 {
     if (_activeTransition == toState)
     {
         EndTransition();
     }
     if (_transitions.ContainsKey(toState))
     {
         _transitions.Remove(toState);
     }
 }
コード例 #5
0
 public void AddTransition(SimpleState toState)
 {
     if (_transitions.ContainsKey(toState))
     {
         StateTransition transition = _transitions[toState];
     }
     else
     {
         _transitions.Add(toState, new StateTransition(this, toState));
     }
 }
コード例 #6
0
            public new void EndTransition()
            {
                SimpleState newState = _activeState._activeTransition;

                if (newState == null)
                {
                    return;
                }
                _activeState.EndTransition();
                _activeState = newState;
            }
コード例 #7
0
        public ReadAction OnTransitionEnd(SimpleState toState)
        {
            StateTransition transition;

            if (_transitions.TryGetValue(toState, out transition))
            {
                return(transition.OnTransitionEnd);
            }
            else
            {
                return(null);
            }
        }
コード例 #8
0
        protected void EndTransition()
        {
            if (_activeTransition == null)
            {
                return;
            }
            StateTransition transition;

            if (_transitions.TryGetValue(_activeTransition, out transition))
            {
                transition.EndTransition();
            }
            _activeTransition = null;
        }
コード例 #9
0
        protected void StartTransition(SimpleState to)
        {
            if (to == null)
            {
                return;
            }
            StateTransition transition;

            if (_transitions.TryGetValue(to, out transition))
            {
                transition.StartTransition();
                _activeTransition = to;
            }
        }
コード例 #10
0
 public new void StartTransition(SimpleState toState)
 {
     _activeState.StartTransition(toState);
 }
コード例 #11
0
 public void MoveState(SimpleState state, SimpleState.Machine toMachine)
 {
     States.Remove(state);
     toMachine.AddState(state);
 }
コード例 #12
0
 public void RemoveState(SimpleState state)
 {
     States.Remove(state);
 }
コード例 #13
0
 public Machine(SimpleState initial) : base()
 {
     _activeState = initial;
     OnStateEnter.Add(StateEntered);
     OnStateExit.Add(StateExited);
 }