PlayerSfxScript.playShotSound C# (CSharp) Method

playShotSound() public static method

public static playShotSound ( Gem, gem ) : void
gem Gem,
return void
    public static void playShotSound(Gem gem)
    {
        float vol = Random.Range(instance.volLowRange, instance.volHighRange);

        // Play the corresponding sound
        switch (gem)
        {
            case Gem.Red:
                instance.sound.PlayOneShot(instance.fireGemSound, vol);
                break;
            case Gem.Green:
                instance.sound.PlayOneShot(instance.healGemSound, vol);
                break;
            case Gem.Blue:
                instance.sound.PlayOneShot(instance.iceGemSound, vol);
                break;
            case Gem.Purple:
                instance.sound.PlayOneShot(instance.stealthGemSound, vol);
                break;
            case Gem.Yellow:
                instance.sound.PlayOneShot(instance.lightningGemSound, vol);
                break;
            default:
                instance.sound.PlayOneShot(instance.aoeGemSound, vol);
                break;
        }
    }

Usage Example

Ejemplo n.º 1
0
 protected virtual void Update()
 {
     // Cast ability when K is pressed then there is enough mana/energy
     if (Input.GetKeyDown(KeyCode.K) && playerControl.cooldown >= cost && isCurrent)
     {
         // Update achievement log, play sound and execute associated gem ability
         AchievementManager.Instance.usedGem();
         PlayerSfxScript.playShotSound(GemManager.Instance.GetCurrentGem());
         doEffect();
         castAnimation();
     }
 }