Beispiel #1
0
    private void OnTriggerExit(Collider other)
    {
        EnemiesInRange.Remove(other.gameObject);
        EnemyDestructionDelegate delete = other.gameObject.GetComponent <EnemyDestructionDelegate>();

        delete.enemyDelegate -= OnEnemyDestroy;
    }
 void OnTriggerExit2D(Collider2D other)
 {
     if (other.gameObject.tag.Equals("Enemy"))
     {
         enemiesInRange.Remove(other.gameObject);
         EnemyDestructionDelegate del = other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate -= OnEnemyDestroy;
     }
 }
Beispiel #3
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Enemy"))
     {
         enemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del = other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
Beispiel #4
0
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Enemy"))
     {
         enemiesInRange.Remove(collision.gameObject);
         EnemyDestructionDelegate del = collision.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate -= OnEnemyDestroy;
     }
 }
 protected virtual void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag.Equals("Enemy"))
     {
         EnemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del = other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.gameObject.CompareTag("Enemy"))
     {
         enemiesInRange.Add(collision.gameObject);
         EnemyDestructionDelegate enemyDestruction = collision.gameObject.GetComponent <EnemyDestructionDelegate>();
         enemyDestruction.enemyDelegate += OnEnemyDesroy;
     }
 }
Beispiel #7
0
 // add enemies that are in range to list
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag.Equals("Enemy"))
     {
         // make sure chicken doesn't shoot dead enemies
         enemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del = other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
 void OnTriggerExit2D(Collider2D other)                                                             //este método detecta se algum objeto com corpo rigido colidiu com este gameObject
 {
     if (other.gameObject.tag.Equals("Enemy"))                                                      //se o objeto que colidir com o collider da arma, tiver a tag de enemy
     {
         enemiesInRange.Remove(other.gameObject);                                                   //o objeto é adicionado na lista
         EnemyDestructionDelegate del =                                                             //em seguida a variavel del que é um do tipo de um delegate recebe o
                                        other.gameObject.GetComponent <EnemyDestructionDelegate>(); //GameObject que tiver o componente EnemuDestructionDelegate
         del.enemyDelegate -= OnEnemyDestroy;                                                       //o del chama o ponteiro do delgate inserindo o metodo a qual ele referencia
     }
 }
Beispiel #9
0
 void OnTriggerEnter2D(Collider2D other)
 {
     // 2
     if (other.gameObject.tag.Equals("Enemy"))
     {
         target.Add(other.gameObject);
         EnemyDestructionDelegate del =
             other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
Beispiel #10
0
 void OnTriggerEnter2D(Collider2D other)
 {
     // This makes sure that OnEnemyDestroy is called when the enemy is destroyed.
     if (other.gameObject.tag.Equals("Enemy"))
     {
         enemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del =
             other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
Beispiel #11
0
 void OnTriggerEnter2D(Collider2D other)
 {
     //You then add the enemy to the list of enemiesInRange and add OnEnemyDestroy to the EnemyDestructionDelegate.
     //This makes sure that OnEnemyDestroy is called when the enemy is destroyed. You don’t want monsters to waste ammo on dead enemies now — do you?
     if (other.gameObject.tag.Equals("Enemy"))
     {
         enemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del = other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
Beispiel #12
0
 void OnTriggerEnter(Collider other)
 {
     print("gsr667");
     if (other.gameObject.tag.Equals("Enemy"))
     {
         enemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del =
             other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
 void OnTriggerEnter2D(Collider2D other)                                                             //este método detecta se algum objeto com corpo rigido colidiu com este gameObject
 {
     if (other.gameObject.tag.Equals("Enemy"))                                                       //se o objeto que colidir com o collider da arma, tiver a tag de enemy
     {
         enemiesInRange.Add(other.gameObject);                                                       //o objeto é adicionado na lista
         EnemyDestructionDelegate del =                                                              //em seguida a variavel del que é um do tipo de um delegate recebe o
                                        other.gameObject.GetComponent <EnemyDestructionDelegate> (); //GameObject que tiver o componente EnemuDestructionDelegate
         del.enemyDelegate += OnEnemyDestroy;                                                        //o del chama o ponteiro do delgate inserindo o metodo a qual ele referencia
         //SpriteRenderer spriteEnemy = other.gameObject.GetComponentInChildren<SpriteRenderer>();
         //spriteEnemy.sortingOrder = (int)Camera.main.WorldToScreenPoint (spriteEnemy.bounds.min).y * -1;
     }
 }
Beispiel #14
0
 void OnTriggerEnter2D(Collider2D other)
 {
     Debug.Log("OnTriggerEnter");
     // 2
     if (other.gameObject.tag.Equals("Enemy"))
     {
         Debug.Log("enemy entered");
         enemiesInRange.Add(other.gameObject);
         EnemyDestructionDelegate del = other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate += OnEnemyDestroy;
     }
 }
Beispiel #15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        // 2
        if (other.gameObject.tag.Equals("Enemy"))
        {
            enemiesInRange.Add(other.gameObject);
            EnemyDestructionDelegate del =
                other.gameObject.GetComponent <EnemyDestructionDelegate>();
            del.enemyDelegate += OnEnemyDestroy;

            if (shock != null)
            {
                shock.addTarget(other.gameObject);
            }
        }
    }
Beispiel #16
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (CompareTag("RedTower") && other.gameObject.CompareTag("RedEnemy") ||
         CompareTag("BlueTower") && other.gameObject.CompareTag("BlueEnemy") ||
         CompareTag("YellowTower") && other.gameObject.CompareTag("YellowEnemy") ||
         CompareTag("PurpleTower") && other.gameObject.CompareTag("RedEnemy") || CompareTag("PurpleTower") && other.gameObject.CompareTag("BlueEnemy") || CompareTag("PurpleTower") && other.gameObject.CompareTag("PurpleEnemy") ||
         CompareTag("GreenTower") && other.gameObject.CompareTag("YellowEnemy") || CompareTag("GreenTower") && other.gameObject.CompareTag("BlueEnemy") || CompareTag("GreenTower") && other.gameObject.CompareTag("GreenEnemy") ||
         CompareTag("OrangeTower") && other.gameObject.CompareTag("YellowEnemy") || CompareTag("OrangeTower") && other.gameObject.CompareTag("RedEnemy") || CompareTag("OrangeTower") && other.gameObject.CompareTag("OrangeEnemy")
         )
     {
         enemiesInRange.Add(other.gameObject);
         Debug.Log("enemy removed " + other);
         EnemyDestructionDelegate del =
             other.gameObject.GetComponent <EnemyDestructionDelegate>();
         del.enemyDelegate -= OnEnemyDestroy;
     }
 }