コード例 #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
 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;
     });
 }