예제 #1
0
    // Only trigger when player touches a powerup. Then apply powerup to player.
    private void OnTriggerEnter(Collider other)
    {
        // Only activate powerup if player is currently not buffed
        if (other.tag != "PU" || isCurrentlyBuffed || playerMovement.isPulseEnabled)
        {
            return;
        }

        Powerup_SO powerUp = other.GetComponent <PowerupDisplay>().powerupInfo;

        // Activate the right buff and apply it to player's stats
        switch (powerUp.buffType)
        {
        case Powerup_SO.powerType.health:
            playerHealth.IncreaseHealth(powerUp.amount);
            break;

        case Powerup_SO.powerType.AOE_pulse:
            playerMovement.ActivatePulses(powerUp.amount);
            break;

        case Powerup_SO.powerType.damagingPower:
            playerShoot.buffShootingPower(powerUp.amount, powerUp.duration);
            break;

        case Powerup_SO.powerType.immunity:
            playerHealth.ActivateImmunity(powerUp.duration);
            break;

        case Powerup_SO.powerType.movementSpeed:
            playerMovement.buffMovementSpeed(powerUp.amount, powerUp.duration);
            break;

        default:
            break;
        }

        // Prevent player from stacking buffs
        buffCooldown     += (powerUp.duration + additionalBuffDelay);
        isCurrentlyBuffed = true;

        // Change the screen color to "blink"
        playerHealth.FlashScreen(powerUp.blinkColor);
    }