private void Update() { float containerWidth = (fuelManager.GetCapacity() / fuelChunk) * widthPerFuelChunk; container.sizeDelta = new Vector2(containerWidth, container.sizeDelta.y); float fillWidth = (fuelManager.GetFuel() / fuelChunk) * widthPerFuelChunk; fillWidth = Mathf.Clamp(fillWidth, 0f, containerWidth - padding * 2); fill.sizeDelta = new Vector2(fillWidth, fill.sizeDelta.y); }
public void UpdateValue() { float angle = Mathf.Clamp(90f - (0.9f * FuelManager.GetFuel()), 0f, 90f); arrow.rotation = Quaternion.Euler(0f, 0f, angle); if (FuelManager.GetFuel() < FuelManager.GetMaxFuel() / 5) { icon.color = Color.yellow; if (!beeped) { soundsController.PlayLowFuel(); beeped = true; } } else { icon.color = Color.black; beeped = false; } }
private void Update() { if (died) { return; } int altitude = GameManager.Instance.AltMeter.GetAltitude(); if (altitude >= 0) { vignette.intensity.Override(0.1f); } else { float vignetteIntensity = 0.1f + Mathf.Clamp(((float)Mathf.Abs(altitude) / 100f) * maxVignetteIntensity, 0f, 0.3f); vignette.intensity.Override(vignetteIntensity); } if (fuelManager.GetFuel() <= 0) { Die(); } }
void Update() { if (areControllsEnabled) { x = Input.GetAxis("Horizontal"); if (Input.GetKeyUp(KeyCode.Escape)) { gameManager.ShowMainMenuPrompt(true); escaped = true; gameManager.PauseTimer(); } if (Input.GetKeyDown(KeyCode.Escape) && escaped) { gameManager.BackToMainMenu(); } else if (!Input.GetKeyDown(KeyCode.Escape) && Input.anyKey && escaped) { gameManager.ShowMainMenuPrompt(false); escaped = false; if (timerController.GetTime() > 0) { gameManager.ResumeTimer(); } } } //----------------------------- // Car has enought fuel to move if (FuelManager.GetFuel() > 0 && areControllsEnabled) { z = Input.GetAxis("Vertical"); Translate(z); if (z != 0) { Rotate(x * z); } //----------------------------------------- // Car run out of fuel while moving FORWARD } else if (FuelManager.GetFuel() <= 0 && z > 0) { z -= 0.4f * Time.deltaTime; Rotate(x * z); Translate(z); if (Input.GetAxis("Vertical") < 0f) { Translate(0); z = 0; } //------------------------------------------ // Car run out of fuel while moving BACKWARD } else if (FuelManager.GetFuel() <= 0 && z < 0) { z += 0.4f * Time.deltaTime; Rotate(x * z); Translate(z); if (Input.GetAxis("Vertical") > 0f) { Translate(0); z = 0; } } if (Input.GetAxis("Vertical") != 0 && areControllsEnabled) { FuelManager.ConsumeFuel(fuelConsumption); } }