Exemplo n.º 1
0
    // Exit this state
    private void ExitState()
    {
        Debug.Log("Exit Explosion State");
        // Set which state to go.
        States stateToGo;

        if (isAnyExploded)
        {
            stateToGo = States.Reposition;
        }
        else
        {
            if (RotationManager.Instance.isOver)
            {
                stateToGo = States.Input;
            }
            else
            {
                stateToGo = States.Rotation;
            }
        }
        // Publish state exit
        OnStateExit?.Invoke(this, new OnStateExitEventArgs {
            stateToGo = stateToGo
        });
    }
Exemplo n.º 2
0
 // Exit this state
 private void ExitState(bool isClockwise)
 {
     Debug.Log("Exit Input State");
     isStateActive = false;
     OnStateExit?.Invoke(this, new OnStateExitEventArgs {
         isClockwise = isClockwise
     });
 }
Exemplo n.º 3
0
 public void ChangeState(TEnum next)
 {
     if (isCalledEnter)
     {
         isCalledEnter = false;
         OnStateExit?.Invoke(CurrentState);
         previousState = CurrentState;
     }
     currentState = next;
 }
Exemplo n.º 4
0
 // Exit this state
 private void ExitState()
 {
     Debug.Log("Exit Reposition State");
     // Set checkers to false
     isStateOver = true;
     // Clear target positions
     targetPositions.Clear();
     // Publish exit event
     OnStateExit?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 5
0
        protected virtual void ExitCurrentState()
        {
            if (_currentState == null)
            {
                return;
            }

            _currentState.OnExitInvoke();
            _currentState.Exit();
            OnStateExit?.Invoke(_currentState);
            _currentState = null;
        }
Exemplo n.º 6
0
 // Exit this state
 private void ExitState()
 {
     Debug.Log("Exit Rotation State");
     isStepOver = true;
     counter++;
     if (counter == 3)
     {
         isOver = true;
     }
     OnStateExit?.Invoke(this, new OnStateExitEventArgs {
         isOver = isOver
     });
 }
Exemplo n.º 7
0
        public void ChangeState(TKey key)
        {
            if (CurrentState != null)
            {
                OnStateExit?.Invoke(CurrentStateKey);
            }

            LogExtensions.Log($"State changed to <color=orange>{key}</color>");

            CurrentState    = states[key];
            CurrentStateKey = key;

            OnStateEnter?.Invoke(key);
        }
Exemplo n.º 8
0
        /// <summary>
        /// Delete the current state, and activate the one bellow that.
        /// </summary>
        internal void PopState()
        {
            if (_states.Count < 2)
            {
                throw new StackOverflowException();
            }

            _states.Peek().OnExit();
            OnStateExit?.Invoke(_states.Peek());
            _states.Pop();

            var currentState = _states.Peek();

            State.InitStateManager(this);
            currentState.OnEnter();
            OnStateChanged?.Invoke(currentState);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Calls OnExit on the current state (without Popping it), then Add a new one.
        /// </summary>
        internal void PushState(State state)
        {
            if (state == null)
            {
                Debug.LogWarning("[StateManager] Trying to Push a null state");
                return;
            }

            if (_states.Count > 0)
            {
                _states.Peek().OnExit();
                OnStateExit?.Invoke(_states.Peek());
            }

            _states.Push(state);
            State.InitStateManager(this);
            _states.Peek().OnEnter();
            OnStateChanged?.Invoke(state);
        }
Exemplo n.º 10
0
        public bool IssueCommand(IComparable command)
        {
            if (IsTransitioning)
            {
                return(false);
            }
            if (CurrentState == null)
            {
                return(false);
            }
            else
            {
                if (!_transitions.ContainsKey(CurrentState))
                {
                    return(false);
                }
                if (!_transitions[CurrentState].ContainsKey(command))
                {
                    return(false);
                }

                if (isInitialisingState)
                {
                    Debug.LogWarning("Do not call IssueCommand from OnStateChange and OnStateEnter handlers");
                    return(false);
                }

                var transition = _transitions[CurrentState][command];
                var ret1       = transition.TestCondition();
                var ret2       = OnStateTransition == null || OnStateTransition.Invoke(transition);
                if (ret1 && ret2)
                {
                    CurrentTransition      = transition;
                    transition.OnComplete += HandleTransitionComplete;

                    OnStateExit?.Invoke(CurrentState);
                    transition.Begin();
                }
                return(true);
            }
        }
Exemplo n.º 11
0
 public virtual void ExitState(T owner)
 {
     OnStateExit?.Invoke(owner);
     OnStateExit = null;
 }
 public virtual void Exit()
 {
     OnStateExit?.Invoke();
 }
Exemplo n.º 13
0
 // Exit this state
 private void ExitState()
 {
     Debug.Log("Exit Game Over State");
     OnStateExit?.Invoke(this, EventArgs.Empty);
 }
Exemplo n.º 14
0
 public void Exit(object data, CancellationToken ct)
 {
     OnStateExit?.Invoke(data, ct);
 }
Exemplo n.º 15
0
 protected virtual void OnExit()
 {
     _active = false;
     OnStateExit?.Invoke();
 }
Exemplo n.º 16
0
 protected void StateExit()
 {
     OnStateExit?.Invoke(Cell);
 }