```
feat(gameplay): 调整单位属性和纹理设置并优化主角移动系统 - 修改多个纹理资源的最大尺寸从2048降至512,并添加PlayableAds平台设置 - 调整第一、二章多个单位的移动速度、攻击力和攻击持续时间参数 - 重命名精锐士兵预制体名称,移除"新"字后缀 - 降低精锐士兵的攻击力和攻击持续时间 - 为主角战斗组件添加detectRange字段,实现寻敌和攻击范围分离 - 重构主角移动系统,从点击移动改为自动巡逻模式,增加栓绳机制防止远离基地 - 实现巡逻和追击状态切换,在发现敌人时停止巡逻进行攻击 -
This commit is contained in:
1 parent
769aea30f3
commit
8d43961f67
28 files changed
+443
-125
No files matched your search
@@ -7,6 +7,9 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
[Min(0f)]
|
||||
public float attackRange = 8f;
|
||||
|
||||
[Min(0f)]
|
||||
public float detectRange = 10f;
|
||||
|
||||
[Min(0f)]
|
||||
public float attackPower = 50f;
|
||||
|
||||
@@ -86,13 +89,39 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
|
||||
if (movement == null || movement.IsMoving || animator == null)
|
||||
if (animator == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 巡逻中也能发现敌人;发现后停止巡逻,没有敌人则恢复巡逻
|
||||
target = FindNearestEnemy();
|
||||
if (target == null || attackCooldown > 0f)
|
||||
if (target == null)
|
||||
{
|
||||
if (movement != null)
|
||||
{
|
||||
movement.ClearChaseTarget();
|
||||
movement.SetPatrolEnabled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (movement != null)
|
||||
{
|
||||
movement.SetPatrolEnabled(false);
|
||||
|
||||
// 寻敌范围内但超出攻击范围:主动走近敌人再攻击(受基地栓绳限制)
|
||||
float targetDistance = GetHorizontalDistance(target.transform.position);
|
||||
if (targetDistance > attackRange)
|
||||
{
|
||||
movement.SetChaseTarget(target.transform.position);
|
||||
return;
|
||||
}
|
||||
|
||||
movement.ClearChaseTarget();
|
||||
}
|
||||
|
||||
if (attackCooldown > 0f)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -165,7 +194,7 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
|
||||
if (movement != null)
|
||||
{
|
||||
movement.StopMovement();
|
||||
movement.SetPatrolEnabled(false);
|
||||
}
|
||||
|
||||
if (attacking)
|
||||
@@ -334,8 +363,7 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
|
||||
private bool IsInsideMovementBounds(Vector3 position)
|
||||
{
|
||||
return movement == null || (position.x >= movement.xLimits.x && position.x <= movement.xLimits.y
|
||||
&& position.z >= movement.zLimits.x && position.z <= movement.zLimits.y);
|
||||
return movement == null || movement.IsWithinLeash(position);
|
||||
}
|
||||
|
||||
private void CheckSummonFinished()
|
||||
@@ -466,10 +494,18 @@ public class MainCharacterCombat : MonoBehaviour
|
||||
animator.SetInteger("speed", 0);
|
||||
}
|
||||
|
||||
private float GetHorizontalDistance(Vector3 position)
|
||||
{
|
||||
Vector3 offset = position - transform.position;
|
||||
offset.y = 0f;
|
||||
return offset.magnitude;
|
||||
}
|
||||
|
||||
private GameObject FindNearestEnemy()
|
||||
{
|
||||
// 索敌范围使用较小的 detectRange,主角不主动远离基地寻找敌人
|
||||
GameObject nearest = null;
|
||||
float nearestDistance = attackRange * attackRange;
|
||||
float nearestDistance = detectRange * detectRange;
|
||||
|
||||
foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy"))
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user