This commit is contained in:
2026-07-27 23:30:25 +08:00
parent 738b2b2d36
commit 44a1029070
17 changed files with 611 additions and 21 deletions
@@ -130,6 +130,15 @@ public class MonsterContral : MonoBehaviour
/// <summary>冰冻特效(预制体内子物体,null 则跳过)</summary>
public GameObject bingDongEffect;
[Header("创建视频(可选)")]
[Tooltip("鱼创建时播放的入场视频片段,播放结束后才开始移动。为空则无入场视频。播放控件由 GameMainPanel_FishBase 提供")]
public UnityEngine.Video.VideoClip createVideoClip;
/// <summary>createVideoClip 实际播放时长(秒),用于计算 moveTime 偏移。<=0 表示未播放/无视频</summary>
protected float _createVideoDuration = 0f;
/// <summary>当前是否正在播放创建视频(由外部播放器 isPlaying 判断)</summary>
protected bool _isPlayingCreateVideo = false;
/// <summary>是否存活(活跃且未被回收)</summary>
public bool IsAlive => gameObject.activeInHierarchy;
@@ -170,6 +179,10 @@ public class MonsterContral : MonoBehaviour
uirootRect = UIManager.Instance.uiRoot.GetComponent<RectTransform>();
mainCamera = Camera.main;
moveTime = 0f;
// ⭐ 重置创建视频状态:池回收的鱼 _isPlayingCreateVideo 可能残留 true,
// 重新生成时重置,由 Init 决定是否重新播放
_createVideoDuration = 0f;
_isPlayingCreateVideo = false;
InitAnimList();
ChangeState(CharacterStateType.move);
@@ -254,6 +267,11 @@ public class MonsterContral : MonoBehaviour
if (!isMove)
transform.position = Vector3.zero;
// ⭐ 创建视频启动逻辑由子类负责:
// - MonsterControl_BossBase 在自己 Init 里启动 createVideo
// - 普通鱼走父类 Init,但普通鱼一般不配 createVideo
// OnMoveUpdata 会检测 createVideo.isPlaying,视频播放期间不移动
// 路径结束后自动销毁
//StartCoroutine(yanchi(gameObject, time, isyuzhen));
}
@@ -319,6 +337,16 @@ public class MonsterContral : MonoBehaviour
public virtual void OnMoveUpdata()
{
if (!isMove) return; // 冰冻中不计时
// ⭐ 创建视频播放期间不移动、不累计 moveTime
// 视频结束后才开始走路线;视频时长不计入 moveTime(单独累计到 _createVideoDuration)
// 隐藏控件由 loopPointReached 回调负责(OnCreateVideoFinished)
if (_isPlayingCreateVideo)
{
_createVideoDuration += Time.deltaTime;
return;
}
moveTime += Time.deltaTime;
if (isyz)
@@ -115,6 +115,24 @@ public class MonsterControl_BossBase : MonsterContral
isyz = isyuzhen;
this.yzID = yzID;
// ⭐ 创建视频处理:配置了 createVideoClip 时通过 GameMainPanel 的播放器播放
// 播放期间 OnMoveUpdata 会跳过移动,视频结束后才开始走路线
_createVideoDuration = 0f;
_isPlayingCreateVideo = false;
var videoPlayer = CreateFishManager.Instance?.currGameType?.createVideoPlayer;
if (createVideoClip != null && videoPlayer != null)
{
// 显示视频控件
videoPlayer.gameObject.SetActive(true);
videoPlayer.Stop();
videoPlayer.clip = createVideoClip;
// ⭐ 注册播放结束回调:视频播完自动隐藏控件 + 重置状态
videoPlayer.loopPointReached -= OnCreateVideoFinished;
videoPlayer.loopPointReached += OnCreateVideoFinished;
videoPlayer.Play();
_isPlayingCreateVideo = true;
}
// Boss 进场播报
if (GameManager.Instance.gameData.currGameType == GameType.XJMH)
{
@@ -137,6 +155,21 @@ public class MonsterControl_BossBase : MonsterContral
}
}
/// <summary>
/// 创建视频播放结束回调:隐藏视频控件 + 重置播放状态
/// (用 loopPointReached 事件,比 OnMoveUpdata 检测更可靠,
/// 因为 isMove=false 的 Boss 不会进入 OnMoveUpdata 的视频检测分支)
/// </summary>
private void OnCreateVideoFinished(UnityEngine.Video.VideoPlayer player)
{
_isPlayingCreateVideo = false;
if (player != null)
{
player.Stop();
player.gameObject.SetActive(false);
}
}
// ==================== 爆奖(公共) ====================
/// <summary>确保分数显示文本存在(自动创建)</summary>