Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        dropItem.ShootCoin();
        DamageDealer damageDealer = other.gameObject.GetComponent <DamageDealer>();

        if (!damageDealer)
        {
            return;
        }
        if (other.gameObject.tag == "PlayerFire")
        {
            health -= damageDealer.GetDamage();
            GameObject hitExplosion = Instantiate(shotsHitParticles, transform.position, Quaternion.identity) as GameObject;
            AudioSource.PlayClipAtPoint(hitSound, Camera.main.transform.position, .4f);
            Destroy(other.gameObject);
            Destroy(hitExplosion, 0.5f);
            if (health <= 0)
            {
                Death();
            }
        }
    }