This commit is contained in:
2026-07-31 17:31:51 +08:00
parent ab190ed6f8
commit 23a2af6e47
6 changed files with 154 additions and 12 deletions
@@ -133,6 +133,57 @@ public class MonsterContral : MonoBehaviour
/// <summary>冰冻特效(预制体内子物体,null 则跳过)</summary>
public GameObject bingDongEffect;
[Header("锁定控制(可选)")]
[Tooltip("是否需要锁定事件控制。默认false=一直可锁定;true=出场/切换状态期间不可锁定,需调用 NotifyLockable() 后才可锁定")]
public bool needLockEvent = false;
/// <summary>
/// 当前是否可锁定。
/// - needLockEvent=false → 一直 true
/// - needLockEvent=true → 初始 false,等 NotifyLockable() 调用后变 true
/// ⭐ 用于嫦娥(出场→移动两步)和小白龙(多动画片段切换)等特殊鱼
/// </summary>
[System.NonSerialized]
public bool isLockable = true;
/// <summary>可锁定事件:needLockEvent=true 的鱼首次可锁定时触发,GameMainPanel 订阅用于自动锁定</summary>
public event Action<MonsterContral> OnLockable;
/// <summary>
/// 通知此鱼现在可以锁定了。needLockEvent=true 的鱼在出场结束/状态切换完成时调用。
/// </summary>
public void NotifyLockable()
{
if (!isLockable)
{
isLockable = true;
OnLockable?.Invoke(this);
}
}
/// <summary>
/// 切换锁定点(不切换锁定对象)。
/// ⭐ 用于小白龙等切换模型/动画片段后锁定点也随之变化的情况:
/// 重新从 colliderList 找第一个激活的碰撞器,更新为新的锁定锚点。
/// 如果当前没有被锁定则不做任何事。
/// 调用方(GameMainPanel_FishBase)负责更新 monCotl_Lock_Position。
/// </summary>
public Transform SwitchLockPoint()
{
// 优先用 lockPoint(若激活)
if (lockPoint != null && lockPoint.gameObject.activeInHierarchy)
return lockPoint;
// 其次 colliderList 第一个激活的
if (colliderList != null)
{
for (int i = 0; i < colliderList.Count; i++)
{
var col = colliderList[i];
if (col != null && col.gameObject.activeInHierarchy)
return col;
}
}
return null;
}
[Header("创建视频(可选)")]
[Tooltip("鱼创建时播放的入场视频片段,播放结束后才开始移动。为空则无入场视频。播放控件由 GameMainPanel_FishBase 提供")]
public UnityEngine.Video.VideoClip createVideoClip;
@@ -178,6 +229,9 @@ public class MonsterContral : MonoBehaviour
// (金龙/雷龙/玉龙等不走路径,直到爆奖结束销毁)
// - 冰冻中重新激活的鱼,末尾会覆盖为 false,安全
isMove = baseMmove;
// ⭐ 重置可锁定状态:needLockEvent=true 的鱼每次重新生成都需等 NotifyLockable()
// needLockEvent=false 的鱼一直可锁定
isLockable = !needLockEvent;
fishenum = (FishTypeEnum)monsterData.fishTypeConfig.fishType;
uirootRect = UIManager.Instance.uiRoot.GetComponent<RectTransform>();
mainCamera = Camera.main;