This commit is contained in:
2026-07-31 16:24:35 +08:00
parent 5ea4fe85d5
commit 23e4658b90
2 changed files with 40 additions and 10 deletions
@@ -1585,8 +1585,8 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
if (useHitCollider && monster.lockPoint != null && monster.lockPoint.gameObject.activeInHierarchy)
return monster.lockPoint;
// ⑤ 最终兜底:monster.transform
return monster.transform;
// ⑤ ⭐ lockPoint 和 colliderList 全部未激活 → 返回 null,调用方应换一条鱼
return null;
}
/// <summary>简化重载,不关心 colliderIndex 时用</summary>
@@ -1595,6 +1595,27 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
return ResolveLockTransform(monster, out _, false);
}
/// <summary>
/// ⭐ 判断鱼是否有激活的锁定锚点(lockPoint 或 colliderList 中任一碰撞器)。
/// 鱼出场效果期间 lockPoint 和 collider 都未激活 → 不可锁定,应换一条鱼。
/// </summary>
private bool HasActiveLockPoint(MonsterContral monster)
{
if (monster == null) return false;
// lockPoint 激活
if (monster.lockPoint != null && monster.lockPoint.gameObject.activeInHierarchy) return true;
// colliderList 任一激活
if (monster.colliderList != null)
{
for (int i = 0; i < monster.colliderList.Count; i++)
{
var col = monster.colliderList[i];
if (col != null && col.gameObject.activeInHierarchy) return true;
}
}
return false;
}
#endregion
#region 路径进度过滤(锁定范围控制)
@@ -1696,9 +1717,12 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
if (selected.Contains(m.guid)) continue; // 跳过已选中的
// ⭐ 路径进度过滤:刚出生(< 0.2)或即将离场(> 0.8)的鱼不作为目标
if (!IsFishPathLockable(m)) continue;
// ⭐ 锚点过滤:出场效果期间 lockPoint 和 collider 都未激活 → 跳过换下一条
if (!HasActiveLockPoint(m)) continue;
// ⭐ 统一用 ResolveLockTransform:colliderList → lockPoint → transform
// ⭐ 统一用 ResolveLockTransform:lockPoint → colliderList → (null则不选)
Transform pos = ResolveLockTransform(m);
if (pos == null) continue;
result.Add((m, pos));
selected.Add(m.guid);
@@ -1791,6 +1815,8 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
// ⭐ 手动锁定:useHitCollider=true → 点击碰撞器 → colliderList 激活项 → lockPoint
int colliderIndex;
Transform lockTr = ResolveLockTransform(monster, out colliderIndex, true);
// ⭐ lockPoint 和 colliderList 全部未激活 → 不锁定这条鱼
if (lockTr == null) return;
currSitData.SetLockTarget(monster, lockTr);
SyncLock(new List<string> { monster?.guid }, colliderIndex);
@@ -1920,9 +1946,11 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
MonsterContral target = FindAutoLockTarget();
if (target != null)
{
// ⭐ 统一用 ResolveLockTransform:colliderList 第一个活跃 → lockPoint → transform
// ⭐ 自动锁定:useHitCollider=false → lockPoint → colliderList → null
int colliderIndex;
Transform lockTr = ResolveLockTransform(target, out colliderIndex);
// ⭐ lockPoint 和 colliderList 全部未激活(出场效果中) → 不锁定,等下一帧再找
if (lockTr == null) return;
currSitData.SetLockTarget(target, lockTr);
SyncLock(new List<string> { target?.guid }, colliderIndex);
@@ -1930,7 +1958,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
if (currSitData.lockFX != null && target.gameObject.activeInHierarchy)
{
if (!currSitData.lockFX.activeSelf) currSitData.lockFX.SetActive(true);
Vector3 p = (lockTr != null && lockTr.gameObject.activeInHierarchy) ? lockTr.position : target.transform.position;
Vector3 p = lockTr.position;
p.z = Camera.main.transform.position.z + 1;
currSitData.lockFX.transform.position = p;
}
@@ -1972,6 +2000,8 @@ public class GameMainPanel_FishBase : GameMainPanel_Base
if (m == null || !m.gameObject.activeInHierarchy) continue;
// ⭐ 路径进度过滤:刚出生(< 0.2)或即将离场(> 0.8)的鱼不作为自动锁定目标
if (!IsFishPathLockable(m)) continue;
// ⭐ 锚点过滤:出场效果期间 lockPoint 和 collider 都未激活 → 跳过换下一条
if (!HasActiveLockPoint(m)) continue;
int pri = GetFishLockPriority(m);