private void ApplyThrust() { fuel -= fuelConsumptionRate; fuelBar.SetFuel(fuel); rigidBody.AddRelativeForce(Vector3.up * mainThrust * Time.deltaTime); //.up applies to the y-axis. if (!audioSource.isPlaying) //so audio doesn't layer (play multiple times at the same time) { audioSource.PlayOneShot(mainEngine); mainEngineParticles.Play(); } }
// Update is called once per frame void Update() { fuelBar.SetFuel(fuel); if (fuel > maxFuel) { fuel = maxFuel; } if (score % 4 == 0 && score != 0 && !speedInc) { speed = speed * 1.5f; speedInc = true; } else if (score % 4 != 0 && speedInc) { speedInc = false; } }
void Movement() { rb.velocity = Vector2.ClampMagnitude(rb.velocity, max_Speed); if (press && canPlay) { rb.AddRelativeForce(Vector2.up * thrust * Time.deltaTime); fuel -= 0.5f; fuelBar.SetFuel(fuel); } }
// Update is called once per frame void Update() { if (_infiniteFuelTimer <= 0) { if (_initialDash && _movement.isBoost()) { _initialDash = false; _currentFuelTime -= _dashFuelConsumption; } else if ((Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.S) || Input.GetKey(KeyCode.L)) && (!_movement.isDisabled() || _movement.isLooting()) && !_movement.isBoost()) { _currentFuelTime -= Time.deltaTime; _initialDash = true; } else if (!_movement.isBoost()) { _initialDash = true; } if (_currentFuelTime / _maxFuelTime < 0) { _fuelBar.SetFuel(0); } else { _fuelBar.SetFuel(_currentFuelTime / _maxFuelTime); } if (_currentFuelTime <= 0) { _movement.setDisabled(true); } } else { _infiniteFuelTimer -= Time.deltaTime; } }
public float SetFuel(float fuel) { if (isFly) { if (fuel > 0) { fuel -= fuelReduction * Time.deltaTime; fuelBar.SetFuel(fuel); } else { fuel = 0; } } else { if (fuel < maxFuel && playerController.IsGrounded) { fuel += fuelReplenishment * Time.deltaTime; fuelBar.SetFuel(fuel); } } return(fuel); }
public void Reset() { _healthBar.SetHealth(1f); _fuelBar.SetFuel(1f); SetScore(0); }
public void ApplyValues() { fBar.SetFuel(PitchUp1()); pBank.SetPower(PitchUp2()); }
void AddFuel(int fuel) { currentFuel += fuel; fuelBar.SetFuel(currentFuel); }