protected virtual void OnTriggerEnter2D(Collider2D other) { GameObject collidingObj = other.gameObject; if (friendly) { if (collidingObj.tag == "Enemy") { EnemyAI enemyAI = collidingObj.GetComponent <EnemyAI>(); if (!ignore.Contains(collidingObj)) { ignore.Add(collidingObj); int _damage = enemyAI.TakeDamage(attackDmg, armorPiercing); if (_damage > 0 || attackDmg == 0) { AudioManager.Play_Static(hitSound, true); } else if (_damage <= 0 && attackDmg != 0) { AudioManager.Play_Static("MetalHit", true); } foreach (Vector2 debuffID in debuffs) { switch (debuffID.x) { case 0: enemyAI.AddDebuff(new FireDebuff(debuffID.y, enemyAI)); break; case 1: enemyAI.AddDebuff(new SlowDebuff(debuffID.y, enemyAI)); break; default: break; } } OnHit(); } } } if (!friendly) { if (collidingObj.tag == "Tower" || collidingObj.tag == "Wall") { TowerAI towerAI = collidingObj.GetComponent <TowerAI>(); if (!ignore.Contains(collidingObj)) { ignore.Add(collidingObj); AudioManager.Play_Static(hitSound, true); towerAI.TakeDamage(attackDmg); OnHit(); } } } }