Пример #1
0
 void OnTriggerEnter2D(Collider2D coll)
 {
     if(coll.gameObject.tag == "Player")
     {
         playerController = coll.gameObject.GetComponent<PlayerController>();
         playerController.DoDamage(1);
         Destroy(gameObject);
     }
     else if(coll.gameObject.tag == "Starbase")
     {
         starbaseController = coll.gameObject.GetComponentInParent<StarbaseController>();
         starbaseController.StarbaseDamage(1);
         Destroy(gameObject);
     }
 }
Пример #2
0
    void OnTriggerEnter2D(Collider2D coll)
    {
        if(this.transform.position.y <= 5f)
        {
            if(coll.gameObject.tag == "Easy" || coll.gameObject.tag == "Medium" || coll.gameObject.tag == "Hard")
            {
                enemyController = coll.gameObject.GetComponent<EnemyController>();
                bool isDead = enemyController.IsDead();

                if (!isDead && coll.transform.position.y <= 5f)
                {
                    enemyController.KillEnemyNoBonus();
                    KillMeteor();
                }
                else
                {
                    return;
                }
            }
            else if(coll.gameObject.tag == "Player" || coll.gameObject.tag == "StarbaseShield")
            {
                KillMeteorNoPoints();
            }

            if(coll.gameObject.tag == "Laser")
            {
                DamageMeteor();
                Destroy(coll.gameObject);
            }
            else if(coll.gameObject.tag == "Starbase")
            {
                starbaseController = coll.gameObject.GetComponentInParent<StarbaseController>();
                starbaseController.StarbaseDamage(2);
                KillMeteorNoPoints();
            }
        }
    }