Пример #1
0
        private AbstractGameState DeactivateCurrentState(AbstractGameState nextState)
        {
            AbstractGameState current = State;

            if (current != null)
            {
                current.Deactivate(nextState: nextState);
            }

            return(current);
        }
Пример #2
0
        public void PopState()
        {
            AbstractGameState next = null;

            if (states.Count >= 2)
            {
                next = states.ElementAt(states.Count - 2);
            }
            AbstractGameState current = DeactivateCurrentState(next);

            states.Remove(current);
            ActivateState(next, current);
        }
 virtual public void Activate(AbstractGameState previousState)
 {
     if (context.LayerSwitcher != null)
     {
         if (previousState != null)
         {
             int          other        = previousState.uiLayer;
             GameObject[] transitionIn = context.LayerSwitcher.GameObjectsOnlyIn(context.LayerSwitcher.GetLayer(uiLayer), notIn: context.LayerSwitcher.GetLayer(other));
             HandleTransitionIn(transitionIn);
         }
         else
         {
             context.LayerSwitcher.ActivateLayer(uiLayer);
         }
     }
     isActive = true;
 }
 virtual public void Deactivate(AbstractGameState nextState)
 {
     if (context.LayerSwitcher != null)
     {
         GameObject[] transitionOut = default;
         if (nextState != null)
         {
             int other = nextState.uiLayer;
             transitionOut = context.LayerSwitcher.GameObjectsOnlyIn(context.LayerSwitcher.GetLayer(uiLayer), notIn: context.LayerSwitcher.GetLayer(other));
         }
         else
         {
             transitionOut = context.LayerSwitcher.GameObjectsForLayer(context.LayerSwitcher.GetLayer(uiLayer));
         }
         HandleTransitionOut(transitionOut);
     }
     isActive = false;
 }
Пример #5
0
 private void AddAndActivateState(AbstractGameState newState, AbstractGameState current)
 {
     states.Add(newState);
     ActivateState(newState, current);
 }
Пример #6
0
        public void PushState(AbstractGameState value)
        {
            AbstractGameState current = DeactivateCurrentState(value);

            AddAndActivateState(value, current);
        }