Esempio n. 1
0
 void Start()
 {
     Provider.Store.Subscribe(state =>
     {
         Mode.ModeEnum nextMode  = Mode.ModeGet(state);
         bool nextPlacementValid = PlacementValid.PlacementValidGet(state);
         if (
             nextMode == _mode &&
             nextPlacementValid == _placementValid
             )
         {
             return;
         }
         _mode = nextMode;
         var firstPlacement = nextPlacementValid && !_placementValid;
         _placementValid    = nextPlacementValid;
         if (firstPlacement)
         {
             var position       = Global.placement + (new Vector3(0.0f, 0.1f, 0.0f));
             transform.position = position;
             _renderer.enabled  = true;
         }
         if (_mode == Mode.ModeEnum.Action)
         {
             _sphereColllider.enabled = true;
             var rb         = gameObject.AddComponent <Rigidbody>();
             rb.angularDrag = 0.0f;
             rb.velocity    = Quaternion.Euler(Global.aimEulerAngles) * (new Vector3(0.0f, 0.0f, 1.1f));
         }
     });
 }
Esempio n. 2
0
        public static State Reducer(State state, Action action)
        {
            // UPDATE FOR EACH DUCK
            bool hasChanged = false;

            Mode.ModeEnum nextMode = Mode.Reducer(state.Mode, action);
            if (nextMode != state.Mode)
            {
                hasChanged = true;
            }
            bool nextPlacementValid = PlacementValid.Reducer(state.PlacementValid, action);

            if (nextPlacementValid != state.PlacementValid)
            {
                hasChanged = true;
            }
            int nextScore = Score.Reducer(state.Score, action);

            if (nextScore != state.Score)
            {
                hasChanged = true;
            }
            return(hasChanged ? new State(
                       nextMode,
                       nextPlacementValid,
                       nextScore
                       ) : state);
        }
Esempio n. 3
0
 void Start()
 {
     Provider.Store.Subscribe(state =>
     {
         Mode.ModeEnum nextMode  = Mode.ModeGet(state);
         bool nextPlacementValid = PlacementValid.PlacementValidGet(state);
         if (nextMode == _mode && nextPlacementValid == _placementValid)
         {
             return;
         }
         _mode           = nextMode;
         _placementValid = nextPlacementValid;
     });
 }