diff --git a/Assets/MyGame/Scripts/Characters/Monster/MonsterContral.cs b/Assets/MyGame/Scripts/Characters/Monster/MonsterContral.cs index 5d2693143..443416ac4 100644 --- a/Assets/MyGame/Scripts/Characters/Monster/MonsterContral.cs +++ b/Assets/MyGame/Scripts/Characters/Monster/MonsterContral.cs @@ -127,6 +127,9 @@ public class MonsterContral : MonoBehaviour public List colliderList; /// 锁定点(colliderList 为空时使用,null 则用自身坐标) public Transform lockPoint; + /// 手动锁定时记录被点击的碰撞器,用于锁定锚点优先级(运行时赋值,不序列化) + [System.NonSerialized] + public Transform hitCollider; /// 冰冻特效(预制体内子物体,null 则跳过) public GameObject bingDongEffect; diff --git a/Assets/MyGame/aa/Game/HHWK/Boss/YiLong/Game177_yilong.prefab b/Assets/MyGame/aa/Game/HHWK/Boss/YiLong/Game177_yilong.prefab index c95b7fb68..7e0d7f6df 100644 --- a/Assets/MyGame/aa/Game/HHWK/Boss/YiLong/Game177_yilong.prefab +++ b/Assets/MyGame/aa/Game/HHWK/Boss/YiLong/Game177_yilong.prefab @@ -24,12 +24,12 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 4812048865189221932} serializedVersion: 2 - m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} - m_LocalPosition: {x: 0.4, y: 0, z: 0} - m_LocalScale: {x: 1, y: 1, z: 1} + m_LocalRotation: {x: 0.58257, y: 0.19029318, z: 0.7657747, w: -0.19490936} + m_LocalPosition: {x: -8.265814, y: 3.3801832, z: 5.62196} + m_LocalScale: {x: 1.6666664, y: 1.6666669, z: 1.6666667} m_ConstrainProportionsScale: 0 m_Children: [] - m_Father: {fileID: 851339252447298365} + m_Father: {fileID: 851532665510979932} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &5917594796932175695 PrefabInstance: @@ -1075,7 +1075,7 @@ PrefabInstance: - {fileID: 7621483054875922705, guid: 3a2d8052104ea1a45aab65e5511276c0, type: 3} - {fileID: 652958895766593643, guid: 3a2d8052104ea1a45aab65e5511276c0, type: 3} m_AddedGameObjects: - - targetCorrespondingSourceObject: {fileID: 6471414929694938226, guid: 3a2d8052104ea1a45aab65e5511276c0, + - targetCorrespondingSourceObject: {fileID: 6471326799031434771, guid: 3a2d8052104ea1a45aab65e5511276c0, type: 3} insertIndex: -1 addedObject: {fileID: 4281476599764317452} @@ -1186,12 +1186,6 @@ Transform: type: 3} m_PrefabInstance: {fileID: 5917594796932175695} m_PrefabAsset: {fileID: 0} ---- !u!4 &851339252447298365 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 6471414929694938226, guid: 3a2d8052104ea1a45aab65e5511276c0, - type: 3} - m_PrefabInstance: {fileID: 5917594796932175695} - m_PrefabAsset: {fileID: 0} --- !u!4 &851345481893981482 stripped Transform: m_CorrespondingSourceObject: {fileID: 6471412260508744293, guid: 3a2d8052104ea1a45aab65e5511276c0, diff --git a/Assets/MyGame/aa/UI/Game/GameMainPanel_FishBase.cs b/Assets/MyGame/aa/UI/Game/GameMainPanel_FishBase.cs index 51acd3a2b..20948d6ad 100644 --- a/Assets/MyGame/aa/UI/Game/GameMainPanel_FishBase.cs +++ b/Assets/MyGame/aa/UI/Game/GameMainPanel_FishBase.cs @@ -1534,16 +1534,40 @@ public class GameMainPanel_FishBase : GameMainPanel_Base /// 所有设置锁定位置的地方都应该调用此方法,避免不同地方用不同优先级导致锁定图标位置和子弹终点不一致。 /// 注意:Unity 序列化字段未赋值时是"假 null",?? 运算符无法识别,必须用 == null 判断。 /// - private Transform ResolveLockTransform(MonsterContral monster, out int colliderIndex) + /// + /// 解析锁定锚点 Transform。 + /// ⭐ useHitCollider=true(手动锁定):点击碰撞器 → colliderList 激活项 → lockPoint + /// ⭐ useHitCollider=false(自动锁定/三发):直接用 lockPoint → colliderList 激活项 → transform + /// (自动锁定没有点击的碰撞器,优先用固定锁定点更稳定) + /// + private Transform ResolveLockTransform(MonsterContral monster, out int colliderIndex, bool useHitCollider = false) { colliderIndex = -1; if (monster == null) return null; - // 1. ⭐ 优先用 lockPoint(锁定锚点,鱼身中心),图标和子弹目标都到这里 - if (monster.lockPoint != null && monster.lockPoint.gameObject.activeInHierarchy) + // ① 手动锁定:优先用点击的碰撞器(hitCollider) + if (useHitCollider && monster.hitCollider != null && monster.hitCollider.gameObject.activeInHierarchy) + { + // 在 colliderList 里找到对应索引,用于网络同步 + if (monster.colliderList != null) + { + for (int i = 0; i < monster.colliderList.Count; i++) + { + if (monster.colliderList[i] == monster.hitCollider) + { + colliderIndex = i; + break; + } + } + } + return monster.hitCollider; + } + + // ② 自动锁定:直接用 lockPoint(锁定锚点) + if (!useHitCollider && monster.lockPoint != null && monster.lockPoint.gameObject.activeInHierarchy) return monster.lockPoint; - // 2. 其次用 colliderList 中第一个活跃的碰撞器 + // ③ 兜底:colliderList 第一个活跃碰撞器(手动/自动都走) if (monster.colliderList != null && monster.colliderList.Count > 0) { for (int i = 0; i < monster.colliderList.Count; i++) @@ -1557,14 +1581,18 @@ public class GameMainPanel_FishBase : GameMainPanel_Base } } - // 3. 兜底用 monster.transform + // ④ 手动锁定兜底:lockPoint + if (useHitCollider && monster.lockPoint != null && monster.lockPoint.gameObject.activeInHierarchy) + return monster.lockPoint; + + // ⑤ 最终兜底:monster.transform return monster.transform; } /// 简化重载,不关心 colliderIndex 时用 private Transform ResolveLockTransform(MonsterContral monster) { - return ResolveLockTransform(monster, out _); + return ResolveLockTransform(monster, out _, false); } #endregion @@ -1580,10 +1608,14 @@ public class GameMainPanel_FishBase : GameMainPanel_Base /// 计算鱼在路径上的进度 [0, 1]。 /// 进度 = moveTime / monsterData.moveLine.moveTime /// 0 = 刚出生,1 = 即将离场 + /// ⭐ isMove=false 的鱼(爆奖Boss等)不走路径,固定在场景中 → 返回中间值 0.5 表示可锁定 /// private float GetFishPathProgress(MonsterContral m) { - if (m == null || m.monsterData == null || m.monsterData.moveLine == null) return 1f; + if (m == null) return 1f; + // ⭐ isMove=false 的鱼不走路径(如金龙/雷龙等爆奖Boss),一直可用 + if (!m.isMove) return 0.5f; + if (m.monsterData == null || m.monsterData.moveLine == null) return 1f; float total = m.monsterData.moveLine.moveTime; if (total <= 0f) return 1f; return Mathf.Clamp01(m.moveTime / total); @@ -1744,7 +1776,7 @@ public class GameMainPanel_FishBase : GameMainPanel_Base foreach (var hit in hits) { float depth = hit.collider.transform.position.z; - if (depth > bestDepth) // 更大 Z → 更近 + if (depth < bestDepth) // 更大 Z → 更远 { bestDepth = depth; bestHit = hit; @@ -1753,10 +1785,12 @@ public class GameMainPanel_FishBase : GameMainPanel_Base // 处理选中的最佳命中 MonsterContral monster = bestHit.collider.GetComponentInParent(); - // ⭐ 统一用 ResolveLockTransform:colliderList 第一个活跃 → lockPoint → transform - // 返回的 colliderIndex 用于网络同步,其他客户端按此索引取同一碰撞器 + // ⭐ 记录被点击的碰撞器,用于 ResolveLockTransform 优先级判断 + if (monster != null) + monster.hitCollider = bestHit.collider.transform; + // ⭐ 手动锁定:useHitCollider=true → 点击碰撞器 → colliderList 激活项 → lockPoint int colliderIndex; - Transform lockTr = ResolveLockTransform(monster, out colliderIndex); + Transform lockTr = ResolveLockTransform(monster, out colliderIndex, true); currSitData.SetLockTarget(monster, lockTr); SyncLock(new List { monster?.guid }, colliderIndex);