void Update() { playerIndex = XInputState.playerIndex; state = XInputState.state; // VIBRATION CONTROL if (_VibLow && _Overloading) { GamePad.SetVibration(playerIndex, 1f, 0f); } if (_VibHigh && _Overloading) { GamePad.SetVibration(playerIndex, 0f, 1f); } // MOVEMENT DEFINITION Vector2 velocity = new Vector2(); // New velocity vector each frame // MOVEMENT! if (!_Overloading) { velocity.x = state.ThumbSticks.Left.X * MaxSpeed.x; velocity.y = state.ThumbSticks.Left.Y * MaxSpeed.y; _rigidbody.velocity = velocity; // apply velocity } // STOP PLAYER WHEN OVERLOADING OR HITTING A BOUNDS if (_Overloading) { _rigidbody.velocity = new Vector2(0f, 0f); } // DO STUFF DURING LIMIT BREAK if (_FireRate == 5) { _NewRate -= Time.deltaTime; // subtract time from limit break } // BOOST ON if (_CanBoost && state.Triggers.Left > 0.5f && !_IsHidden && EndlessGameInfo._GameState == 1 && _CurrentBoost > 0) { _IsBoosting = true; _CanBoost = false; BoostControl(); } // UPDATE BOOST METER if (_IsBoosting) { _CurrentBoost = _CurrentBoost - 20; EndlessEnemySystem._HUD.UpdateBoostMeter((float)_CurrentBoost / _MaxBoost); // update health bar with HP percentage } // BOOST OFF if (!_CanBoost && state.Triggers.Left < 0.5f || _CurrentBoost <= 0) { _IsBoosting = false; _CanBoost = true; CancelBoost(); } // MANUAL PURGE with X BUTTON if (_ReadyToPurge && state.Buttons.X == ButtonState.Pressed) { Purge(); } // STANDARD FIRING with A BUTTON if (_CanFire && _IsHidden == false && _IsDestroyed == false && state.Buttons.A == ButtonState.Pressed) { FireControl(); } // MISSILE FIRING with B BUTTON if (_CanFire && _IsHidden == false && _IsDestroyed == false && _LockedOn == true && _CanFireMissile == true && _MissileActive == false && state.Buttons.B == ButtonState.Pressed) { if (GameObject.Find("missile") == false) { StartCoroutine(MissileControl()); } //Debug.Log("FIRE MISSILE!"); } // TOGGLE FPS COUNTER if (state.Buttons.LeftShoulder == ButtonState.Pressed && _FPSActive == false) { StartCoroutine(ToggleFPS()); _FPSActive = true; } //if (state.Buttons.LeftStick == ButtonState.Pressed) //{ // Application.CaptureScreenshot("EndlessReach_screen.png", 2); //} // MANUAL HMD Orientation Rest //if (state.Buttons.Back == ButtonState.Pressed) //{ // OVRManager.display.RecenterPose(); // OVR Reset function for 0.4.3 //} #region Pause Control if (state.Buttons.Start == ButtonState.Pressed && GameInfo.Paused == false && _Paused == false) { GameInfo.DoPause(); _Paused = true; HidePlayer(); _IsHidden = true; } #endregion #region Unpause Control if (state.Buttons.Start == ButtonState.Pressed && GameInfo.Paused == true && _Paused == true) { GameInfo.UnDoPause(); _Paused = false; ShowPlayer(); _IsHidden = false; } #endregion #region Hide Control // HIDE PLAYER WHEN BOSS DIES if (EndlessEnemySystem.BossDying && Application.loadedLevel != 10) { GamePad.SetVibration(playerIndex, 0, 0); HidePlayer(); StopCoroutine("LimitBreak"); _IsHidden = true; } // HIDE PLAYER IF GAME ON STATUS SCREEN if (EndlessGameInfo._GameState == 2) { GamePad.SetVibration(playerIndex, 0, 0); HidePlayer(); StopCoroutine("LimitBreak"); // TURN OFF LIMIT BREAK SHIELD IF ACTIVE if (LimitBreak_Shield.activeInHierarchy) { LimitBreak_Shield.SetActive(false); } } // HIDE PLAYER DURING STATUS SCREEN if (EndlessGameInfo.StatusScreen == true && _IsHidden == false && EndlessGameInfo._GameState == 1) { GamePad.SetVibration(playerIndex, 0, 0); HidePlayer(); _IsHidden = true; } #endregion }