Beispiel #1
0
 void OnCollisionEnter2D(Collision2D other) //при столкновении возвращаем в пул
 {
     if (other.gameObject.CompareTag("Player"))
     {
         if (other != null)
         {
             other.gameObject.GetComponent <PlayerController>().TakeNormalDamage(_pool.FireDamage);
         }
         Instantiate(_ProjectileVFX, transform.position, transform.rotation);// партиклы дестроятся сами /стопЭкшн - дестрой
         _pool.AddToPool(gameObject);
     }
     else if (other.gameObject.CompareTag("Enemy"))
     {
         if (other != null)
         {
             other.gameObject.GetComponent <EnemyController>().HealthBar.gameObject.SetActive(true);
             other.gameObject.GetComponent <EnemyController>().TakeNormalDamage(_pool.FireDamage);
             Instantiate(_ProjectileVFX, transform.position, transform.rotation);// партиклы дестроятся сами /стопЭкшн - дестрой
             _pool.AddToPool(gameObject);
         }
         //FireTrap.ReturnToPool(gameObject);
     }
     else if (other.gameObject.CompareTag("Map") || other.gameObject.CompareTag("fireballTrap") || other.gameObject.CompareTag("projectileKnife"))
     {
         if (other != null)
         {
             Instantiate(_ProjectileVFX, transform.position, transform.rotation);// партиклы дестроятся сами /стопЭкшн - дестрой
             _pool.AddToPool(gameObject);
         }
     }
 }
Beispiel #2
0
 public void Deactivate()
 {
     this.gameObject.SetActive(false);
     if (collisions <= 1)
     {
         owningPool.AddToPool(this);
     }
     // Debug.Log(transform.GetInstanceID() + " has deactivated.");
 }