|
|
@@ -493,6 +493,20 @@ public class Enemy : MoveCharacter
|
|
|
if(targetCharacter == null)
|
|
|
{
|
|
|
ChosePlayer();
|
|
|
+ if(targetCharacter == null)
|
|
|
+ {
|
|
|
+ ChangeState(CharacterState.FinishRush);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (targetCharacter.isRevive &&
|
|
|
+ targetCharacter.GetComponent<PlayerController>().isBaseBtnOut)
|
|
|
+ {
|
|
|
+ targetCharacter = null;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
if (Mathf.Abs(transform.position.x-targetCharacter.transform.position.x)
|
|
|
< hateDistance)
|
|
|
@@ -1007,24 +1021,31 @@ public class Enemy : MoveCharacter
|
|
|
}
|
|
|
public void ChosePlayer()
|
|
|
{
|
|
|
- float distance0 = 1000;
|
|
|
- float distance1 = 1000;
|
|
|
- if (PlayersInput.instance[0])
|
|
|
+ float distance0 = Mathf.Infinity;
|
|
|
+ float distance1 = Mathf.Infinity;
|
|
|
+ PlayerController player0 = PlayersInput.instance[0];
|
|
|
+ PlayerController player1 = PlayersInput.instance[1];
|
|
|
+ if (player0!=null && !player0.isRevive && !player0.isBaseBtnOut)
|
|
|
{
|
|
|
- distance0 = Mathf.Abs(PlayersInput.instance[0].transform.position.x
|
|
|
+ distance0 = Mathf.Abs(player0.transform.position.x
|
|
|
- transform.position.x);
|
|
|
}
|
|
|
- if (PlayersInput.instance[1])
|
|
|
+ if (player1!=null && !player1.isRevive && !player1.isBaseBtnOut)
|
|
|
{
|
|
|
- distance1 = Mathf.Abs(PlayersInput.instance[1].transform.position.x
|
|
|
+ distance1 = Mathf.Abs(player1.transform.position.x
|
|
|
- transform.position.x);
|
|
|
}
|
|
|
+ if(distance0 == Mathf.Infinity && distance1 == Mathf.Infinity)
|
|
|
+ {
|
|
|
+ targetCharacter = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
if (distance0 <= distance1)
|
|
|
{
|
|
|
- targetCharacter = PlayersInput.instance[0];
|
|
|
- if (!PlayersInput.instance[0].beTargetCharacter.Exists(t => t == this))
|
|
|
+ targetCharacter = player0;
|
|
|
+ if (!player0.beTargetCharacter.Exists(t => t == this))
|
|
|
{
|
|
|
- PlayersInput.instance[0].beTargetCharacter.Add(this);
|
|
|
+ player0.beTargetCharacter.Add(this);
|
|
|
}
|
|
|
|
|
|
distance = distance0;
|
|
|
@@ -1032,10 +1053,10 @@ public class Enemy : MoveCharacter
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- targetCharacter = PlayersInput.instance[1];
|
|
|
- if (!PlayersInput.instance[1].beTargetCharacter.Exists(t => t == this))
|
|
|
+ targetCharacter = player1;
|
|
|
+ if (!player1.beTargetCharacter.Exists(t => t == this))
|
|
|
{
|
|
|
- PlayersInput.instance[1].beTargetCharacter.Add(this);
|
|
|
+ player1.beTargetCharacter.Add(this);
|
|
|
}
|
|
|
|
|
|
distance = distance1;
|