protected override void onTargetReached(GameObject obj) { TDWorld world = TDWorld.getWorld(); GameObject player = world.getPlayer(); if (obj == player) { return; } TDEnemy tdEnemy = world.getTDEnemy(obj); if (null != tdEnemy) { m_state = State.eFight; return; } if (world.isFakeTarget(obj)) { DestroyObject(obj); } m_state = State.ePatrol; }
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); }
private void patrol() { m_path = null; TDWorld world = TDWorld.getWorld(); GameObject [] aEnemies = world.getAllEnemiesUnsafe(); foreach (GameObject enemy in aEnemies) { if ((enemy.transform.position - transform.position).magnitude < world.m_configuration.heroPatrolRadius) { TDEnemy tdEnemy = world.getTDEnemy(enemy); if (tdEnemy.canFly()) { continue; } if (hasPathTo(enemy)) { m_state = State.eWalk; break; } } } }