private void UpdateBars(MovementBehavior moveBeh) { float lowerIntMult = (float)moveBeh.LowerEnginePowerIntervalsCount / (float)moveBeh.EnginePowerIntervalsCount; float upperIntMult = (float)moveBeh.UpperEnginePowerIntervalsCount / (float)moveBeh.EnginePowerIntervalsCount; float power = moveBeh.CurrentThrottleEnginePower01; if (power > 0) power *= upperIntMult; else power *= lowerIntMult; power += lowerIntMult; _speedThrottleBar.CurrentValue01 = power; //Debug.Log(power); _speedRealBar.CurrentValue01 = moveBeh.RigidBody.velocity.magnitude / moveBeh.GetMaximumSpeed(); //_boostSlider.value = moveBeh.CurrentBoostCharges01; if (moveBeh.CruiserSpeedChargingProgress > 0 && !moveBeh.IsCruiserSpeedActive) _cruiserChargeBar.gameObject.SetActive(true); else _cruiserChargeBar.gameObject.SetActive(false); _cruiserChargeBar.CurrentValue01 = moveBeh.CruiserSpeedChargingProgress; //float sliderWidth = _speedSliderRectTransform.rect.width; //float markWidth = _speedSliderPowerDirectionMark.rectTransform.rect.width; //Vector3 v = new Vector3(sliderWidth * lowerIntMult - sliderWidth / 2 + markWidth, 0); //_speedSliderPowerDirectionMark.rectTransform.localPosition = v; }
private void UpdateKeyboardRotation(MovementBehavior moveBeh) { moveBeh.StopRotation(); if (Input.GetKey(KeyCode.W)) moveBeh.AddRotation(EDirection.Down); if (Input.GetKey(KeyCode.S)) moveBeh.AddRotation(EDirection.Up); if (Input.GetKey(KeyCode.A)) moveBeh.AddRotation(EDirection.Left); if (Input.GetKey(KeyCode.D)) moveBeh.AddRotation(EDirection.Right); }
private void UpdateMouseRotation(MovementBehavior moveBeh) { moveBeh.StopRotation(); float screenAverage = (Screen.width + Screen.height) / 2; Vector3 screenCenter = new Vector3(Screen.width / 2, Screen.height / 2, 0); Vector3 mouseOffset = (Input.mousePosition - screenCenter) / screenAverage; CameraFollow cammeraFollow = Camera.main.GetComponent<CameraFollow>(); if (Vector3.Distance(Input.mousePosition, screenCenter) > screenAverage * MOUSE_BLIND_AREA_RADIUS) { moveBeh.AddRotation(Quaternion.Euler(0, 0, 90) * mouseOffset * _mouseSensitivity); //cammeraFollow.MouseOffset = mouseOffset; } else { //cammeraFollow.MouseOffset = Vector3.zero; } }
private void UpdateRoll(MovementBehavior moveBeh) { moveBeh.StopRoll(); if (Input.GetKey(KeyCode.Q)) moveBeh.AddRoll(EDirection.Left); if (Input.GetKey(KeyCode.E)) moveBeh.AddRoll(EDirection.Right); }
private void UpdateStrafe(MovementBehavior moveBeh) { moveBeh.StopStrafe(); if (Input.GetKey(KeyCode.W)) moveBeh.AddStrafe(EDirection.Up); if (Input.GetKey(KeyCode.S)) moveBeh.AddStrafe(EDirection.Down); if (Input.GetKey(KeyCode.A)) moveBeh.AddStrafe(EDirection.Left); if (Input.GetKey(KeyCode.D)) moveBeh.AddStrafe(EDirection.Right); }
private void UpdateSpeed(MovementBehavior moveBeh) { if (Input.GetAxis("Mouse ScrollWheel") > 0) moveBeh.ModifyIntervalSpeed(true); if (Input.GetAxis("Mouse ScrollWheel") < 0) if (moveBeh.IsCruiserSpeedActive) moveBeh.SetCruiserSpeed(false); else moveBeh.ModifyIntervalSpeed(false); if (!Input.GetKey(KeyCode.LeftShift)) if (Input.GetKey(KeyCode.Tab)) moveBeh.SetBoost(true); else moveBeh.SetBoost(false); if (Input.GetKeyDown(KeyCode.Tab) && Input.GetKey(KeyCode.LeftShift)) if (moveBeh.CruiserSpeedChargingProgress == 0 && !b) moveBeh.SetCruiserSpeed(true); else moveBeh.SetCruiserSpeed(false); if (Input.GetKeyDown(KeyCode.Escape)) moveBeh.SetCruiserSpeed(false); }