Example #1
0
        public static State Reducer(State state, Action action)
        {
            bool   hasChanged    = false;
            string nextStateName = Name.Reducer(state.Name, action);

            if (nextStateName != state.Name)
            {
                hasChanged = true;
            }
            int nextStatePlayerCount = PlayerCount.Reducer(state.PlayerCount, action);

            if (nextStatePlayerCount != state.PlayerCount)
            {
                hasChanged = true;
            }
            bool nextStatePlaying = Playing.Reducer(state.Playing, action);

            if (nextStatePlaying != state.Playing)
            {
                hasChanged = true;
            }
            bool nextStatePlayingErrored = PlayingErrored.Reducer(state.PlayingErrored, action);

            if (nextStatePlayingErrored != state.PlayingErrored)
            {
                hasChanged = true;
            }
            bool nextStatePlayingRequested = PlayingRequested.Reducer(state.PlayingRequested, action);

            if (nextStatePlayingRequested != state.PlayingRequested)
            {
                hasChanged = true;
            }
            return(hasChanged ? new State(nextStateName, nextStatePlayerCount, nextStatePlaying, nextStatePlayingErrored, nextStatePlayingRequested) : state);
        }
Example #2
0
 void Start()
 {
     _text         = this.GetComponent <Text>();
     _text.enabled = _playingErrored;
     _subscription = Provider.Store.Subscribe(state =>
     {
         bool nextPlayingErrored = PlayingErrored.Get(state);
         if (nextPlayingErrored == _playingErrored)
         {
             return;
         }
         _playingErrored = nextPlayingErrored;
         _text.enabled   = _playingErrored;
     });
 }