feat: 移除自适应性能相关配置并调整动画控制器

移除了Unity自适应性能(Adaptive Performance)的相关配置文件,
包括Adaptive Performance文件夹及其子目录中的所有配置文件,
同时移除了移动通知(NotificationSettings)相关配置,
以及第一章第一关(level_chapter1_level1)的关卡配置文件,
还删除了多个材质文件如AdjustableGlowOrb、AdjustableGlowOrbHalo
和Arena相关材质。另外微调了base-人类士兵.controller中状态机
的位置坐标,将x坐标从320调整为330。
```
This commit is contained in:
huadexuan committed 2026-09-27 20:39:00 +08:00
1 parent 13d0c80335
commit f77fa20f82
413 files changed
+13494 -63858

No files matched your search

+81 -49
View File
@@ -9,8 +9,8 @@ public class UnitBase : MonoBehaviour
public float speed = 5f;
[Header("寻敌视野")]
[Tooltip("检测范围内优先攻击敌方战斗单位;范围外则搜索敌方建筑物")]
public float detectionRange = 25f;
[Tooltip("只在检测范围内寻找敌方战斗单位;范围内没有敌人时原地待机")]
public float detectionRange = 30f;
//攻击范围
public float attackRange = 5f;
@@ -65,18 +65,23 @@ public class UnitBase : MonoBehaviour
// 召唤师:不自动追击远处敌人,只在站定后攻击射程内的目标;移动由 SummonerClickMovement 控制。
public bool summonerMode = false;
//召唤师模式下允许自动攻击的开关(移动时由操控脚本关闭,站定时开启)。
// 召唤师模式下允许自动攻击的开关(移动时由操控脚本关闭,站定后开启)。
private bool summonerAttackEnabled = true;
[Header("无目标回位")]
[Tooltip("开启后,当前没有敌方单位时返回生成时的初始格位;不限制正常追击距离。")]
public bool returnToAnchorWhenIdle = false;
[Min(0.1f)]
public float anchorArrivalDistance = 0.35f;
private Vector3 anchorPosition;
private bool anchorInitialized;
//角色状态
private State state = State.Alert;
//攻击目标
public GameObject target;
//出生使命:出生时快照当时己方标志指向的建筑,之后标志变化不影响本单位(支持分兵)。
private GameObject missionTarget;
// NavMesh 寻路更新间隔(优化性能)
private float nextPathUpdateTime = 0f;
private const float PathUpdateInterval = 0.5f; // 每 0.5 秒更新一次路径
@@ -149,6 +154,8 @@ public class UnitBase : MonoBehaviour
worldHealthBar = GetComponent<WorldHealthBar>();
statusEffectController = EnsureStatusEffectController();
unitSkill = GetComponent<UnitSkill>();
anchorPosition = transform.position;
anchorInitialized = true;
// 如果有 NavMeshAgent,配置它
if (navAgent != null)
@@ -165,13 +172,6 @@ public class UnitBase : MonoBehaviour
// 根运动作用于所有动画:走路摇摆、攻击前冲由 OnAnimatorMove 统一协调
animator.applyRootMotion = true;
//出生使命:快照己方标志当前指向的建筑(之后玩家切换标志不影响本单位)
var myTeam = GetComponent<UnitTeam>();
if (myTeam != null && AttackTargetController.Instance != null)
{
missionTarget = AttackTargetController.Instance.GetTeamTarget(myTeam.teamId);
}
}
private StatusEffectController EnsureStatusEffectController()
@@ -266,6 +266,12 @@ public class UnitBase : MonoBehaviour
//场上没有敌人时进入待机,不再巡逻移动
state = State.Alert;
if (returnToAnchorWhenIdle && anchorInitialized && !IsAtAnchor())
{
ReturnToAnchor();
return;
}
// 召唤师模式下动画由 SummonerClickMovement 控制(移动时 speed=1,站定后 speed=0)
if (!summonerMode)
{
@@ -385,36 +391,66 @@ public class UnitBase : MonoBehaviour
{
}
//目标决策:周围有敌人打敌人(detectionRange 内),否则直奔出生使命建筑(快照,标志变化不影响)。
private GameObject FindTarget()
private bool IsAtAnchor()
{
// Phase 1: detectionRange 内的敌方战斗单位
GameObject enemy = FindNearestEnemyUnit();
if (enemy != null) return enemy;
// Phase 2: 出生使命建筑;只有仍属于敌方的使命建筑才继续攻击。
if (IsTargetValid(missionTarget))
{
return missionTarget;
}
// 使命建筑已被己方占领、失活或销毁时,改攻敌方主城堡。
var myTeam = GetComponent<UnitTeam>();
if (myTeam != null && AttackTargetController.Instance != null)
{
GameObject castle = AttackTargetController.Instance.GetEnemyCastleOfTeam(myTeam.teamId);
missionTarget = castle;
return castle;
}
return null;
if (!anchorInitialized) return true;
Vector3 current = transform.position;
current.y = 0f;
Vector3 anchor = anchorPosition;
anchor.y = 0f;
return Vector3.Distance(current, anchor) <= anchorArrivalDistance;
}
//判断建筑是否我方阵营(含主城堡和已占领资源建筑)
private bool IsFriendlyBuilding(GameObject building)
private void ReturnToAnchor()
{
var myTeam = GetComponent<UnitTeam>();
var buildingTeam = building.GetComponent<UnitTeam>();
return myTeam != null && buildingTeam != null && buildingTeam.teamId == myTeam.teamId;
if (navAgent == null || !anchorInitialized)
{
if (!summonerMode) animator.SetInteger("speed", 0);
return;
}
if (!navAgent.enabled)
{
navAgent.enabled = true;
}
if (!navAgent.isOnNavMesh)
{
if (!summonerMode) animator.SetInteger("speed", 0);
return;
}
if (IsAtAnchor())
{
navAgent.isStopped = true;
navAgent.ResetPath();
transform.position = new Vector3(anchorPosition.x, transform.position.y, anchorPosition.z);
navAgent.nextPosition = transform.position;
if (!summonerMode) animator.SetInteger("speed", 0);
return;
}
navAgent.isStopped = false;
if (Time.time >= nextPathUpdateTime)
{
navAgent.SetDestination(anchorPosition);
nextPathUpdateTime = Time.time + PathUpdateInterval;
}
animator.SetInteger("speed", navAgent.velocity.sqrMagnitude > 0.01f ? 1 : 0);
}
//目标决策:只寻找 detectionRange 内的敌方战斗单位;范围内没有敌人时原地待机或回到锚点。
private GameObject FindTarget()
{
return FindNearestEnemyUnit();
}
// 判断目标是否属于本单位自身的层级树(自身或其子物体)。
// 不能用 transform.root 比较:单位和敌人常挂在同一个场景容器下,会被误判成"自己"而全部跳过。
private bool IsOwnHierarchy(Transform other)
{
if (other == null) return true;
return other == transform || other.IsChildOf(transform) || transform.IsChildOf(other);
}
//查找 detectionRange 内最近的敌方战斗单位
@@ -429,19 +465,15 @@ public class UnitBase : MonoBehaviour
Vector3 myPos = transform.position;
// Phase 1: detectionRange 内的敌方战斗单位
GameObject nearestUnit = null;
float nearestUnitSqr = float.PositiveInfinity;
UnitTeam[] allTeams = FindObjectsOfType<UnitTeam>();
foreach (var unit in allTeams)
{
if (unit.gameObject == gameObject || !myTeam.IsEnemy(unit.gameObject))
if (!myTeam.IsEnemy(unit.gameObject))
continue;
if (unit.transform.root == transform.root)
continue;
// 跳过建筑物(它们有 Building Tag),只找战斗单位
if (unit.CompareTag("Building"))
if (IsOwnHierarchy(unit.transform))
continue;
float sqrDist = (unit.transform.position - myPos).sqrMagnitude;
@@ -810,7 +842,7 @@ public class UnitBase : MonoBehaviour
{
GameObject opponent = targetTeam.gameObject;
if (opponent == null || opponent == gameObject || opponent.transform.root == transform.root)
if (opponent == null || IsOwnHierarchy(opponent.transform))
{
continue;
}
@@ -896,7 +928,7 @@ public class UnitBase : MonoBehaviour
{
GameObject opponent = targetTeam.gameObject;
if (opponent == null || opponent == gameObject || opponent.transform.root == transform.root)
if (opponent == null || IsOwnHierarchy(opponent.transform))
{
continue;
}
@@ -1084,8 +1116,8 @@ public class UnitBase : MonoBehaviour
private void FinishAttack()
{
//攻击动画结束后恢复当前攻速倍率。
animator.speed = attackSpeedMultiplier;
//攻击动画结束后恢复正常 Animator 播放速度,避免攻击动画调速污染走路动画。
animator.speed = 1f;
//攻击结束后只继续攻击当前锁定目标,不在这里重新寻敌。
if (IsTargetValid(target) && IsWithinAttackReach(target))