コード例 #1
0
 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();
     }
 }
コード例 #2
0
    // 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;
        }
    }
コード例 #3
0
 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);
     }
 }
コード例 #4
0
    // 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;
        }
    }
コード例 #5
0
 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);
 }
コード例 #6
0
ファイル: Hud.cs プロジェクト: lucaspopp0/starrrgh
 public void Reset()
 {
     _healthBar.SetHealth(1f);
     _fuelBar.SetFuel(1f);
     SetScore(0);
 }
コード例 #7
0
ファイル: PitchUp.cs プロジェクト: krobinson20/Space-Force
 public void ApplyValues()
 {
     fBar.SetFuel(PitchUp1());
     pBank.SetPower(PitchUp2());
 }
コード例 #8
0
    void AddFuel(int fuel)
    {
        currentFuel += fuel;

        fuelBar.SetFuel(currentFuel);
    }