Esempio n. 1
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        PlayerHealth player = hitInfo.GetComponent <PlayerHealth>();

        if (player)
        {
            player.AddShield();
            Destroy(gameObject);
        }
    }
Esempio n. 2
0
    IEnumerator AddShield(int shieldType, float delay)
    {
        yield return(new WaitForSeconds(delay));

        _health.AddShield(shieldType);
        if (shieldType == 0)
        {
            anim.ObjectSoundSource.PlayOneShot(anim.GetSoundFromBank("Shield", anim.ObjectSounds));
        }
    }
Esempio n. 3
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag == "Player")
        {
            PlayerHealth playerHealth = other.gameObject.GetComponent <PlayerHealth>();

            // If the player has health to lose...
            if (playerHealth.currentHealth > 0)
            {
                playerHealth.AddShield(timeToShield);
            }

            Destroy(gameObject);
        }
    }