Exemple #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);
        }
Exemple #2
0
 void Start()
 {
     PhotonNetwork.autoJoinLobby = false;
     _subscription = Provider.Store.Subscribe(state =>
     {
         bool nextPlayingRequested = PlayingRequested.Get(state);
         if (nextPlayingRequested == _playingRequested)
         {
             return;
         }
         _playingRequested = nextPlayingRequested;
     });
 }
Exemple #3
0
 void Start()
 {
     _button = this.GetComponent <Button>();
     _button.interactable = _name != "";
     _subscription        = Provider.Store.Subscribe(state =>
     {
         string nextName           = Name.Get(state);
         bool nextPlayingRequested = PlayingRequested.Get(state);
         if (nextName == _name && nextPlayingRequested == _playingRequested)
         {
             return;
         }
         _name                = nextName;
         _playingRequested    = nextPlayingRequested;
         _button.interactable = _name != "" && !_playingRequested;
     });
 }
Exemple #4
0
        void Start()
        {
            _inputField   = this.GetComponent <InputField>();
            _subscription = Provider.Store.Subscribe(state =>
            {
                // INITIALIZE INPUT
                string value      = _inputField.text;
                string playerName = Name.Get(state);
                if (value == "" && playerName != "")
                {
                    _inputField.text = playerName;
                }

                // CHECK FOR PLAYING REQUESTED
                bool nextPlayingRequested = PlayingRequested.Get(state);
                if (nextPlayingRequested == _playingRequested)
                {
                    return;
                }
                _playingRequested        = nextPlayingRequested;
                _inputField.interactable = !_playingRequested;
            });
        }