예제 #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));
         }
     });
 }
예제 #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);
        }
예제 #3
0
 // UPDATE FOR EACH DUCK
 public State(
     Mode.ModeEnum mode,
     bool placementValid,
     int score
     )
 {
     Mode           = mode;
     PlacementValid = placementValid;
     Score          = score;
 }
예제 #4
0
 void Start()
 {
     Provider.Store.Subscribe(state =>
     {
         Mode.ModeEnum nextMode = Mode.ModeGet(state);
         if (nextMode == _mode)
         {
             return;
         }
         _mode      = nextMode;
         _text.text = _mode.ToString();
     });
 }
예제 #5
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;
     });
 }
예제 #6
0
 void Start()
 {
     Provider.Store.Subscribe(state =>
     {
         Mode.ModeEnum nextMode = Mode.ModeGet(state);
         if (nextMode == _mode)
         {
             return;
         }
         _mode = nextMode;
         if (_mode == Mode.ModeEnum.Meshing)
         {
             _renderer.enabled = false;
         }
     });
 }
예제 #7
0
 void Start()
 {
     Provider.Store.Subscribe(state =>
     {
         Mode.ModeEnum nextMode = Mode.ModeGet(state);
         if (nextMode == _mode)
         {
             return;
         }
         _mode = nextMode;
         if (_mode == Mode.ModeEnum.Meshing)
         {
             transform.position       = Global.mZPosition;
             transform.localScale     = Global.mZLocalScale;
             _mLSpatialMapper.enabled = true;
         }
         else
         {
             _mLSpatialMapper.enabled = false;
         }
     });
 }
예제 #8
0
 void Start()
 {
     Provider.Store.Subscribe(state =>
     {
         Mode.ModeEnum nextMode = Mode.ModeGet(state);
         if (
             nextMode == _mode
             )
         {
             return;
         }
         _mode = nextMode;
         if (_mode == Mode.ModeEnum.Aim)
         {
             var position       = Global.placement + (new Vector3(0.0f, 0.1f, 0.0f));
             transform.position = position;
             _renderer.enabled  = true;
         }
         if (_mode == Mode.ModeEnum.Action)
         {
             _renderer.enabled = false;
         }
     });
 }
예제 #9
0
 public Action(Provider.Actions type, Mode.ModeEnum payload)
 {
     this.Type            = type;
     this.PayloadModeEnum = payload;
 }