Script for playing SFX sounds related to the player.
Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    public void TakeDamage(int amount)
    {
        // Reduce the current health by the amount of damage sustained.
        currentHealth -= amount;

        if (amount != 0)
        {
            hasTakenDamage = true;
            dmgTimer       = secDamage;
        }

        // Update health on slider to new value.
        healthSlider.value = currentHealth;

        // It there is no health left.
        if (currentHealth <= 0)
        {
            // Play sound, animate and destroy object.
            PlayerSfxScript.playDeathSound();
            playerControlScript.InitiateAnimation("Die");
            Destroy(gameObject, 0.95f);
        }
        else
        {
            // Play sound and animate.
            PlayerSfxScript.playHitSound();
            playerControlScript.InitiateAnimation("Hit");
        }
    }
Ejemplo n.º 2
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();
     }
 }
Ejemplo n.º 3
0
 // Creates singleton on first run.
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         // Self-destruct if another instance exists
         Destroy(this);
         return;
     }
 }
Ejemplo n.º 4
0
 // Creates singleton on first run.
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         // Self-destruct if another instance exists
         Destroy(this);
         return;
     }
 }
Ejemplo n.º 5
0
    void Update()
    {
        // Regenerate the energy/mana bar after a specified amount of time
        if (Time.time > nextTime)
        {
            nextTime = Time.time + 1f;
            if (cooldown != 100f)
            {
                cooldown += regen;
            }
            UpdateCoolDownSlider();
        }

        // Perform a basic melee attack
        if (Input.GetKeyDown(KeyCode.J) && Time.time > nextMelee)
        {
            // Playsound, animate and attack
            PlayerSfxScript.playMeleeSound();
            anim.SetTrigger("Melee");
            // Pauses to sync up more with the animation
            Invoke("AttactInstantiate", 0.15f);
            nextMelee = Time.time + meleeRate;
        }
    }