|
@@ -78,7 +78,13 @@ public class Enemy : MoveCharacter
|
|
|
public bool canEscape = false;
|
|
public bool canEscape = false;
|
|
|
private bool ShowEscapeValue() => canEscape;
|
|
private bool ShowEscapeValue() => canEscape;
|
|
|
[ShowIf("ShowEscapeValue")] public float stopEscapeCD;
|
|
[ShowIf("ShowEscapeValue")] public float stopEscapeCD;
|
|
|
- [ShowIf("ShowEscapeValue")] public float escapeSpeed;
|
|
|
|
|
|
|
+ [ShowIf("ShowEscapeValue")] public float escapeSpeed; //逃跑距离
|
|
|
|
|
+ [ShowIf("ShowEscapeValue")] public float distanceToTowerDeviation; //怪物逃跑靠近塔的距离偏差,防止怪物堆在一起
|
|
|
|
|
+ [ShowIf("ShowEscapeValue")] public float distanceToTowerBase; //怪物逃跑靠近塔的基础距离
|
|
|
|
|
+ [ShowIf("ShowEscapeValue")] public float distanceToEnemyDeviation; //怪物逃跑靠近坦克敌人的距离偏差,防止怪物堆在一起
|
|
|
|
|
+ [ShowIf("ShowEscapeValue")] public float distanceToEnemyBase; //怪物逃跑靠近坦克敌人的基础距离
|
|
|
|
|
+ private float distanceToTower;
|
|
|
|
|
+ private float distanceToEnemy;
|
|
|
private float stopEscapeTimer;
|
|
private float stopEscapeTimer;
|
|
|
private EscapeTrigger escapeTrigger;
|
|
private EscapeTrigger escapeTrigger;
|
|
|
|
|
|
|
@@ -96,6 +102,8 @@ public class Enemy : MoveCharacter
|
|
|
{
|
|
{
|
|
|
am = attackController.attackMethod;
|
|
am = attackController.attackMethod;
|
|
|
len = am.Length;
|
|
len = am.Length;
|
|
|
|
|
+ distanceToTower = distanceToTowerBase;
|
|
|
|
|
+ distanceToEnemy = distanceToEnemyBase;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
private void OnEnable()
|
|
@@ -569,11 +577,11 @@ public class Enemy : MoveCharacter
|
|
|
}
|
|
}
|
|
|
rb.velocity = velocity;
|
|
rb.velocity = velocity;
|
|
|
AdjustHeight();
|
|
AdjustHeight();
|
|
|
- if (Time.time - stopEscapeTimer > stopEscapeCD && escapeTrigger.IsSafe())
|
|
|
|
|
|
|
+ if (/*Time.time - stopEscapeTimer > stopEscapeCD && */escapeTrigger.IsSafe(distanceToEnemy))
|
|
|
{
|
|
{
|
|
|
ChangeState(CharacterState.Run);
|
|
ChangeState(CharacterState.Run);
|
|
|
}
|
|
}
|
|
|
- else if (escapeTrigger.IsInEnemyTower())
|
|
|
|
|
|
|
+ else if (escapeTrigger.IsInEnemyTower(distanceToTower))
|
|
|
{
|
|
{
|
|
|
ChangeState(CharacterState.WaitForTank);
|
|
ChangeState(CharacterState.WaitForTank);
|
|
|
}
|
|
}
|
|
@@ -583,7 +591,7 @@ public class Enemy : MoveCharacter
|
|
|
{
|
|
{
|
|
|
Turn();
|
|
Turn();
|
|
|
}
|
|
}
|
|
|
- if (escapeTrigger.IsSafe())
|
|
|
|
|
|
|
+ if (escapeTrigger.IsSafe(distanceToEnemy))
|
|
|
{
|
|
{
|
|
|
ChangeState(CharacterState.Run);
|
|
ChangeState(CharacterState.Run);
|
|
|
}
|
|
}
|
|
@@ -665,6 +673,8 @@ public class Enemy : MoveCharacter
|
|
|
DropSouls();
|
|
DropSouls();
|
|
|
break;
|
|
break;
|
|
|
case CharacterState.Escape:
|
|
case CharacterState.Escape:
|
|
|
|
|
+ distanceToTower = distanceToTowerBase + Random.Range(-distanceToTowerDeviation, distanceToTowerDeviation);
|
|
|
|
|
+ distanceToEnemy = distanceToEnemyBase + Random.Range(-distanceToEnemyDeviation, distanceToEnemyDeviation);
|
|
|
ani.Play("walk", 0, 0);
|
|
ani.Play("walk", 0, 0);
|
|
|
stopEscapeTimer = Time.time;
|
|
stopEscapeTimer = Time.time;
|
|
|
Turn();
|
|
Turn();
|
|
@@ -854,7 +864,7 @@ public class Enemy : MoveCharacter
|
|
|
|
|
|
|
|
private bool CheckEscape()
|
|
private bool CheckEscape()
|
|
|
{
|
|
{
|
|
|
- return canEscape && !escapeTrigger.IsSafe() && !escapeTrigger.IsInEnemyTower();
|
|
|
|
|
|
|
+ return canEscape && !escapeTrigger.IsSafe(distanceToEnemy) && !escapeTrigger.IsInEnemyTower(distanceToTower);
|
|
|
}
|
|
}
|
|
|
public void Attack_summon()
|
|
public void Attack_summon()
|
|
|
{
|
|
{
|