Exemplo n.º 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;
        }
    }