|
|
@@ -11,6 +11,8 @@ public class ESpirits_KiteNinja : Enemy
|
|
|
[LabelText("锁敌逻辑")] public Vector2 lockingLogic;
|
|
|
[LabelText("复活次数")] public int revivesNum;
|
|
|
[LabelText("复活范围")] public Vector2 revivesPos;
|
|
|
+ [LabelText("逃跑距离")] public float fleeDistance;
|
|
|
+ [LabelText("逃跑速度比例")] public float fleeSpeedRate;
|
|
|
public bool targetIsPlayer;
|
|
|
public int lockingNum;
|
|
|
private PlayerController player;
|
|
|
@@ -43,6 +45,33 @@ public class ESpirits_KiteNinja : Enemy
|
|
|
0);
|
|
|
}
|
|
|
return;
|
|
|
+ case CharacterState.Attack:
|
|
|
+ float distance = player.transform.position.x - transform.position.x;
|
|
|
+ if (distance > 0.3f)
|
|
|
+ {
|
|
|
+ if (bodyTrans.localScale.x > 0)
|
|
|
+ {
|
|
|
+ Turn();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (distance < -0.3f)
|
|
|
+ {
|
|
|
+ if (bodyTrans.localScale.x < 0)
|
|
|
+ {
|
|
|
+ Turn();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Mathf.Abs(distance) < fleeDistance)
|
|
|
+ {
|
|
|
+ Vector3 velocity = Vector3.right * moveSpeed * fleeSpeedRate;
|
|
|
+ if (distance > 0)
|
|
|
+ {
|
|
|
+ velocity.x = -velocity.x;
|
|
|
+ }
|
|
|
+ rb.velocity = velocity * moveSpeedScale;
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
}
|
|
|
base.OnState();
|
|
|
}
|