Exemplo n.º 1
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy enemy = hitInfo.GetComponent <Enemy>();

        if (enemy != null)
        {
            enemy.TakeDamage(damage);
            Destroy(gameObject);
        }

        PowerUpBlimp Blimp = hitInfo.GetComponent <PowerUpBlimp>();

        if (Blimp != null)
        {
            Blimp.TakeDamage(damage);
            Destroy(gameObject);
        }
    }
Exemplo n.º 2
0
    void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Enemy      enemy = hitInfo.GetComponent <Enemy>();
        GameObject sound = GameObject.Find("Sound");
        PlaySound  play  = sound.GetComponent <PlaySound>();

        if (enemy != null)
        {
            play.PlayHitEnemy();
            enemy.TakeDamage(damage);
            Destroy(gameObject);
        }

        PowerUpBlimp blimp = hitInfo.GetComponent <PowerUpBlimp>();

        if (blimp != null)
        {
            play.PlayHitBox();
            blimp.TakeDamage(damage);
            Destroy(gameObject);
        }
        Box box = hitInfo.GetComponent <Box>();

        if (box != null)
        {
            play.PlayHitBox();
            box.TakeDamage(damage);
            Destroy(gameObject);
        }
        MonsterBlock mBlock = hitInfo.GetComponent <MonsterBlock>();

        if (mBlock != null)
        {
            play.PlayHitBox();
            mBlock.TakeDamage(damage);
            Destroy(gameObject);
        }

        Monster monster = hitInfo.GetComponent <Monster>();

        if (monster != null)
        {
            play.PlayHitEnemy();
            monster.TakeDamage(damage);
            Destroy(gameObject);
        }

        Turret turret = hitInfo.GetComponent <Turret>();

        if (turret != null)
        {
            play.PlayHitEnemy();
            turret.TakeDamage(damage);
            Destroy(gameObject);
        }


        if (hitInfo.gameObject.tag == "Destructable")
        {
            hitInfo.gameObject.GetComponent <DamageDestructable>().TakeDamage(damage);
            Destroy(gameObject);
        }
    }