public void HighlightSpeed(ESpeeds index) { // hihlight the speed that matches the current speed speedTexts[prevIndex].color = deselectedColor; speedTexts[(int)index].color = highlightedColor; prevIndex = (int)index; }
private void SetSpeed(ESpeeds index) { // rotate to position //Quaternion rotation = speedPointer.transform.localRotation; //speedPointer.transform.localRotation = Quaternion.Euler(rotation.eulerAngles.x, rotation.eulerAngles.y, rotations[(int)index]); //Debug.Log($"Setting rotation from {speedPointer.transform.localRotation} to { speedPointer.transform.localRotation}"); speedPointer.GetComponent <RotationZTween>().TweenRotation(rotations[(int)index]); }
// Update is called once per frame void Update() { if (prevSpeed != playerFlightControls.currentSpeedSetting) { SetSpeed(playerFlightControls.currentSpeedSetting); speedText.HighlightSpeed(playerFlightControls.currentSpeedSetting); prevSpeed = playerFlightControls.currentSpeedSetting; } }
// Start is called before the first frame update void Start() { playerFlyingComponent = this.GetComponent <Flying>(); playerFlightControls = this.GetComponentInChildren <PlayerFlightControls>(); prevSpeed = playerFlightControls.currentSpeedSetting; SetSpeed(prevSpeed); speedText = this.GetComponent <HgihlightSpeed>(); speedText.HighlightSpeed(prevSpeed); }
// Start is called before the first frame update void Start() { playerFlyingComponent = this.GetComponent <Flying>(); playerFlightControls = this.GetComponentInChildren <PlayerFlightControls>(); speedSlider.maxValue = playerFlightControls.presetSpeeds[playerFlightControls.presetSpeeds.Length - 1]; speedSlider.minValue = playerFlightControls.presetSpeeds[0]; speedSlider.value = playerFlyingComponent.currentForwardSpeed; speedText.text = playerFlightControls.currentSpeedSetting.ToString(); //Mathf.RoundToInt(playerFlyingComponent.currentForwardSpeed) + " mph"; prevSpeed = playerFlightControls.currentSpeedSetting; }
// Start is called before the first frame update void Start() { player = this.transform.parent; // set first density UpdateDensity(densities[(int)player.GetComponentInChildren <PlayerFlightControls>().currentAltSetting]); prevAlt = player.GetComponentInChildren <PlayerFlightControls>().currentAltSetting; // set first speed UpdateSpeed(speeds[(int)player.GetComponentInChildren <PlayerFlightControls>().currentSpeedSetting]); prevSpeed = player.GetComponentInChildren <PlayerFlightControls>().currentSpeedSetting; }
// Update is called once per frame void Update() { // the speed fluctuates too much, check within a range if (playerFlyingComponent.desiredForwardSpeed - 2 > playerFlyingComponent.currentForwardSpeed || playerFlyingComponent.currentForwardSpeed > playerFlyingComponent.desiredForwardSpeed + 2) { speedSlider.value = playerFlyingComponent.currentForwardSpeed; } if (prevSpeed != playerFlightControls.currentSpeedSetting) { speedText.text = playerFlightControls.currentSpeedSetting.ToString(); prevSpeed = playerFlightControls.currentSpeedSetting; } }
public void CheckForSpeedChange() { if (Input.GetKeyDown(KeyCode.W)) { if ((int)currentSpeedSetting < (int)ESpeeds.Fast) { currentSpeedSetting += 1; } } else if (Input.GetKeyDown(KeyCode.S)) { if ((int)currentSpeedSetting > (int)ESpeeds.Slow) { currentSpeedSetting -= 1; //fly.SetDesSpeed(presetSpeeds[(int)currentSpeedSetting]); } } autoPilot.desiredSpeed = (presetSpeeds[(int)currentSpeedSetting]); }
// Update is called once per frame void FixedUpdate() { // change in alt if (player.GetChild(0).gameObject.active) { if (player.GetComponentInChildren <PlayerFlightControls>().currentAltSetting != prevAlt) { UpdateCloudBoxDensity((int)player.GetComponentInChildren <PlayerFlightControls>().currentAltSetting); prevAlt = player.GetComponentInChildren <PlayerFlightControls>().currentAltSetting; } // change in speed if (player.GetComponentInChildren <PlayerFlightControls>().currentSpeedSetting != prevSpeed) { // figure out how to smooth this! UpdateCloudBoxSpeed((int)player.GetComponentInChildren <PlayerFlightControls>().currentSpeedSetting); //UpdateSpeed(speeds[(int)player.GetComponentInChildren<PlayerFlightControls>().currentSpeedSetting]); prevSpeed = player.GetComponentInChildren <PlayerFlightControls>().currentSpeedSetting; } } }