Exemple #1
0
    public void UsePowerup(Hud.PowerupId id, float value = 0)
    {
        Debug.Log(value);
        powerUpAmounts[(int)id]--;
        _hud.UsePowerup(id);
        switch (id)
        {
        case Hud.PowerupId.Bomb:
            currentBombAmount += (int)value;
            gameObject.GetComponent <PlayerBomb>().AddBombs((int)value);
            break;

        case Hud.PowerupId.Fuel:
            _hud.ActivatePowerup(Hud.PowerupId.Fuel, value);
            gameObject.GetComponent <PlayerFuel>().InfiniteFuel(value);
            break;

        case Hud.PowerupId.Health:
            gameObject.GetComponent <PlayerHealth>().Heal((int)value);
            break;

        case Hud.PowerupId.Shield:
            _hud.ActivatePowerup(Hud.PowerupId.Shield);
            gameObject.GetComponent <PlayerHealth>().setShield(true);
            break;

        case Hud.PowerupId.Speed:
            _hud.ActivatePowerup(Hud.PowerupId.Speed, PowerupSpeed.DURATION);
            gameObject.GetComponent <PlayerMovement>().speedUp(value, PowerupSpeed.DURATION);
            break;
        }
    }
Exemple #2
0
    public void ObtainPowerup(Hud.PowerupId id, float value = 0f, int amountGained = 1)
    {
        RunStats.Current.PowerupsCollected++;
        _hud.GainPowerup(id, amountGained);
        _powerupSound.Play();
        switch (id)
        {
        case Hud.PowerupId.Bomb:
            powerUpAmounts[(int)Hud.PowerupId.Bomb]++;
            bombAmountToAdd = (int)value;
            textPopup.DisplayPopup($"+{(int)value} BOMBS", Color.cyan, 1.5f);
            break;

        case Hud.PowerupId.Fuel:
            powerUpAmounts[(int)Hud.PowerupId.Fuel]++;
            infiniteFuelTime = value;
            textPopup.DisplayPopup($"+1 INFINITE FUEL POWERUP", Color.cyan, 1.5f);
            break;

        case Hud.PowerupId.Health:
            powerUpAmounts[(int)Hud.PowerupId.Health]++;
            healAmount = (int)value;
            textPopup.DisplayPopup("+1 HEALTH POWERUP", Color.cyan, 1.5f);
            break;

        case Hud.PowerupId.Shield:
            powerUpAmounts[(int)Hud.PowerupId.Shield]++;
            textPopup.DisplayPopup($"+1 SHIELD POWERUP", Color.cyan, 1.5f);
            break;

        case Hud.PowerupId.Speed:
            powerUpAmounts[(int)Hud.PowerupId.Speed]++;
            textPopup.DisplayPopup($"+1 SPEED BOOST", Color.cyan, 1.5f);
            speedCoeff = value;
            break;
        }
    }
Exemple #3
0
 private bool HasPowerupAvailable(Hud.PowerupId id)
 {
     return(powerUpAmounts[(int)id] > 0);
 }
Exemple #4
0
 public void ObtainPowerup(Hud.PowerupId id, int amountGained = 1)
 {
     _hud.GainPowerup(id, amountGained);
     _powerupSound.Play();
 }