コード例 #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
        });
    }
コード例 #2
0
        public void ChangeState(T nextState)
        {
            if (Equals(nextState, CurrentState))
            {
                return;
            }
            HashSet <OnExit> exitCallbacks;

            if (OnStateExit.TryGetValue(CurrentState, out exitCallbacks))
            {
                foreach (var callback in exitCallbacks)
                {
                    callback(nextState);
                }
            }
            PreviousState = CurrentState;
            CurrentState  = nextState;
            HashSet <OnEnter> enterCallbacks;

            if (OnStateEnter.TryGetValue(CurrentState, out enterCallbacks))
            {
                foreach (var callback in enterCallbacks)
                {
                    callback(PreviousState);
                }
            }
            StateEnterTime = TimeSlice.Create();
            StateChanged.Publish(PreviousState, CurrentState);
        }
コード例 #3
0
ファイル: InputManager.cs プロジェクト: yilmazfatih6/hexfall
 // Exit this state
 private void ExitState(bool isClockwise)
 {
     Debug.Log("Exit Input State");
     isStateActive = false;
     OnStateExit?.Invoke(this, new OnStateExitEventArgs {
         isClockwise = isClockwise
     });
 }
コード例 #4
0
 public void ChangeState(TEnum next)
 {
     if (isCalledEnter)
     {
         isCalledEnter = false;
         OnStateExit?.Invoke(CurrentState);
         previousState = CurrentState;
     }
     currentState = next;
 }
コード例 #5
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);
 }
コード例 #6
0
        protected virtual void ExitCurrentState()
        {
            if (_currentState == null)
            {
                return;
            }

            _currentState.OnExitInvoke();
            _currentState.Exit();
            OnStateExit?.Invoke(_currentState);
            _currentState = null;
        }
コード例 #7
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
     });
 }
コード例 #8
0
ファイル: FSMProcessor.cs プロジェクト: KuhPik/Bootstrap
        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);
        }
コード例 #9
0
ファイル: StateManager.cs プロジェクト: daltonbr/Minesweeper
        /// <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);
        }
コード例 #10
0
ファイル: StateManager.cs プロジェクト: daltonbr/Minesweeper
        /// <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);
        }
コード例 #11
0
ファイル: SkillFSMMachine.cs プロジェクト: cnscj/THSTG
        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);
            }
        }
コード例 #12
0
 public virtual void Exit()
 {
     OnStateExit?.Invoke();
 }
コード例 #13
0
 // Exit this state
 private void ExitState()
 {
     Debug.Log("Exit Game Over State");
     OnStateExit?.Invoke(this, EventArgs.Empty);
 }
コード例 #14
0
 protected virtual void OnExit()
 {
     _active = false;
     OnStateExit?.Invoke();
 }
コード例 #15
0
 protected void StateExit()
 {
     OnStateExit?.Invoke(Cell);
 }
コード例 #16
0
 public Machine(SimpleState initial) : base()
 {
     _activeState = initial;
     OnStateEnter.Add(StateEntered);
     OnStateExit.Add(StateExited);
 }
コード例 #17
0
ファイル: State.cs プロジェクト: Kristoj/MOSS
 public virtual void ExitState(T owner)
 {
     OnStateExit?.Invoke(owner);
     OnStateExit = null;
 }
コード例 #18
0
 public void Exit(object data, CancellationToken ct)
 {
     OnStateExit?.Invoke(data, ct);
 }