|
|
@@ -148,15 +148,31 @@ public class Demonic : MoveCharacter
|
|
|
switch (searchState)
|
|
|
{
|
|
|
case SearchState.NoTarget:
|
|
|
- //if (PlayerController.instance.bodyTrans.localScale.x > 0)
|
|
|
- //{
|
|
|
- // moveDir = Vector3.left;
|
|
|
- //}
|
|
|
- //else
|
|
|
- //{
|
|
|
- // moveDir = Vector3.right;
|
|
|
- //}
|
|
|
- moveDir = Vector3.left;
|
|
|
+ if(TowerMap.enemyTowers.Count == 0)
|
|
|
+ {
|
|
|
+ moveDir = Vector3.left;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ float minDistance =
|
|
|
+ Vector3.Distance(transform.position, TowerMap.enemyTowers[0].transform.position);
|
|
|
+ int id = 0;
|
|
|
+ for (int i = 1; i < TowerMap.enemyTowers.Count; i++)
|
|
|
+ {
|
|
|
+ float distance = Vector3.Distance(transform.position, TowerMap.enemyTowers[i].transform.position);
|
|
|
+ if (distance < minDistance)
|
|
|
+ {
|
|
|
+ minDistance = distance;
|
|
|
+ id = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (bodyTrans.position.x > TowerMap.enemyTowers[id].transform.position.x)
|
|
|
+ {
|
|
|
+ moveDir = Vector3.left;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ moveDir = Vector3.right;
|
|
|
+ }
|
|
|
break;
|
|
|
case SearchState.InSearchScope:
|
|
|
if (targetCharacter)
|