public override void onTargetReached() { Vector3 explodePosition = m_target.transform.position; if (m_target != null) { DestroyObject(m_target); } GameObject [] aAllEnemies = TDWorld.getWorld().getAllEnemiesUnsafe(); foreach (GameObject thisObject in aAllEnemies) { if (thisObject == null) { continue; } if ((thisObject.transform.position - explodePosition).magnitude > TDWorld.getWorld().m_configuration.towerCanonBallDamageRadius) { continue; } TDEnemy enemy = TDWorld.getWorld().getTDEnemy(thisObject); if (enemy == null) { continue; } if (enemy.canFly()) { continue; } enemy.receiveDamage(m_damage.clone(enemy), null); } }
private void fight() { TDWorld world = TDWorld.getWorld(); TDEnemy tdEnemy = world.getTDEnemy(target()); if (null == tdEnemy) { m_state = State.ePatrol; return; } if ((target().transform.position - transform.position).magnitude > world.m_configuration.heroFightRadius) { if (hasPathTo(target())) { m_state = State.eWalk; } else { m_state = State.ePatrol; } return; } TDDamage damage = new TDDamage(TDDamage.Type.ePhysical, world.m_configuration.heroPhysicalDamagePerSec * Time.deltaTime, 0f); tdEnemy.receiveDamage(damage, this); }