Пример #1
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Debug.Log(hitInfo.name);
        Enemy         enemy         = hitInfo.GetComponent <Enemy>();
        ShootingEnemy shootingEnemy = hitInfo.GetComponent <ShootingEnemy>();
        EnemyGhost    enemyGhost    = hitInfo.GetComponent <EnemyGhost>();

        if (enemy != null)
        {
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            enemy.TakeDamege(damage);
            Instantiate(spellEnemyImpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else if (shootingEnemy != null)
        {
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            shootingEnemy.TakeDamege(damage);
            Instantiate(spellEnemyImpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else if (enemyGhost != null)
        {
            enemyGhost.TakeDamege(damage);
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            Instantiate(spellEnemyImpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
        else
        {
            FindObjectOfType <AudioManager>().Play("fireball_impact_ground");
            Instantiate(spellGroundInpact, transform.position, transform.rotation);
            Destroy(gameObject);
        }
    }
Пример #2
0
    private void OnTriggerEnter2D(Collider2D hitInfo)
    {
        Debug.Log(hitInfo.name);
        Enemy         enemy         = hitInfo.GetComponent <Enemy>();
        ShootingEnemy shootingEnemy = hitInfo.GetComponent <ShootingEnemy>();
        EnemyGhost    enemyGhost    = hitInfo.GetComponent <EnemyGhost>();

        if (enemy != null)
        {
            enemy.TakeDamege(damage);
        }
        else if (shootingEnemy != null)
        {
            shootingEnemy.TakeDamege(damage);
        }
        else if (enemyGhost != null)
        {
            enemyGhost.TakeDamege(damage);
        }
    }