From ec503bd3f1553070edb093497ef6971fd1af8d5b Mon Sep 17 00:00:00 2001 From: yangbear Date: Fri, 10 Jul 2026 02:51:52 +0800 Subject: [PATCH] Fix final chanrao audio, smooth camera3 transition, show TipPanel for 2s, and play tuoxiezi video --- Assets/Scripts/Audio/AudioManager.cs | 52 +++++++++++++++++-- .../Scripts/Interaction/PingClickHandler.cs | 4 +- .../Scripts/Interaction/ShoseClickHandler.cs | 8 +++ Assets/Scripts/UI/PageController.cs | 23 ++++++++ 4 files changed, 83 insertions(+), 4 deletions(-) diff --git a/Assets/Scripts/Audio/AudioManager.cs b/Assets/Scripts/Audio/AudioManager.cs index b6062f7..7c87cbc 100644 --- a/Assets/Scripts/Audio/AudioManager.cs +++ b/Assets/Scripts/Audio/AudioManager.cs @@ -98,11 +98,57 @@ public class AudioManager : MonoBehaviour public void StopVoice() { _voiceSource.Stop(); } public void SwitchToCamera3() + { + StartCoroutine(SmoothSwitchCameraCoroutine()); + } + + private System.Collections.IEnumerator SmoothSwitchCameraCoroutine() { var cam2 = GameObject.Find("camera2"); var cam3 = GameObject.Find("camera3"); - if (cam2 != null) { var c = cam2.GetComponent(); if (c != null) c.enabled = false; } - if (cam3 != null) { var c = cam3.GetComponent(); if (c != null) c.enabled = true; } - Debug.Log("[AudioManager] camera2→camera3 直接切换完成"); + + if (cam2 == null || cam3 == null) + { + if (cam2 != null) { var c = cam2.GetComponent(); if (c != null) c.enabled = false; } + if (cam3 != null) { var c = cam3.GetComponent(); if (c != null) c.enabled = true; } + yield break; + } + + var c2 = cam2.GetComponent(); + var c3 = cam3.GetComponent(); + + if (c2 == null || c3 == null) yield break; + + // 保存 camera3 原本的目标位置和旋转 + Vector3 targetPos = cam3.transform.position; + Quaternion targetRot = cam3.transform.rotation; + + // 将 camera3 放到 camera2 的位置 + cam3.transform.position = cam2.transform.position; + cam3.transform.rotation = cam2.transform.rotation; + + // 切换激活状态,这样任何挂在 camera3 上的后期特效立刻生效,但视角还没变 + c2.enabled = false; + c3.enabled = true; + + float duration = 1.0f; + float elapsed = 0f; + + while (elapsed < duration) + { + elapsed += Time.deltaTime; + float t = elapsed / duration; + // 加上平滑曲线 (EaseInOut) + t = t * t * (3f - 2f * t); + + cam3.transform.position = Vector3.Lerp(cam2.transform.position, targetPos, t); + cam3.transform.rotation = Quaternion.Slerp(cam2.transform.rotation, targetRot, t); + yield return null; + } + + cam3.transform.position = targetPos; + cam3.transform.rotation = targetRot; + + Debug.Log("[AudioManager] camera2→camera3 平滑过渡完成"); } } diff --git a/Assets/Scripts/Interaction/PingClickHandler.cs b/Assets/Scripts/Interaction/PingClickHandler.cs index 164c688..e663857 100644 --- a/Assets/Scripts/Interaction/PingClickHandler.cs +++ b/Assets/Scripts/Interaction/PingClickHandler.cs @@ -115,7 +115,9 @@ public class PingClickHandler : MonoBehaviour int activePingCount = 0; foreach (var p in remainingPings) { - if (p.gameObject.activeInHierarchy) activePingCount++; + // In phase 2, finished pings have their collider disabled and _isBlinking set to false. + var col = p.GetComponent(); + if (col != null && col.enabled) activePingCount++; } if (activePingCount == 0) diff --git a/Assets/Scripts/Interaction/ShoseClickHandler.cs b/Assets/Scripts/Interaction/ShoseClickHandler.cs index 7a3b5bf..89f99f0 100644 --- a/Assets/Scripts/Interaction/ShoseClickHandler.cs +++ b/Assets/Scripts/Interaction/ShoseClickHandler.cs @@ -148,6 +148,14 @@ public class ShoseClickHandler : MonoBehaviour { audioManager.SwitchToCamera3(); } + + // 显示 VideoPanel 并播放视频 + var videoController = FindObjectOfType(true); + if (videoController != null) + { + videoController.gameObject.SetActive(true); + videoController.PlayVideo("tuoXieZi.mp4"); + } } public void ResetState() diff --git a/Assets/Scripts/UI/PageController.cs b/Assets/Scripts/UI/PageController.cs index e99b343..243fdb1 100644 --- a/Assets/Scripts/UI/PageController.cs +++ b/Assets/Scripts/UI/PageController.cs @@ -450,12 +450,35 @@ public class PageController : MonoBehaviour } Debug.Log($"PageController: 开始等待 {waitTime} 秒以切换摄像机并激活鞋子"); + + // --- 新增:展示 TipPanel 2秒 --- + var tipPanel = GameObject.Find("TipPanel"); + if (tipPanel == null) + { + var allT = Resources.FindObjectsOfTypeAll(); + foreach(var t in allT) { if (t.name == "TipPanel") { tipPanel = t.gameObject; break; } } + } + if (tipPanel != null) + { + tipPanel.SetActive(true); + // 这里你可以修改 TipPanel 上的文字,如果不修改,它将保持默认内容 + // 等待2秒后再隐藏 + StartCoroutine(HideTipPanelAfterDelay(tipPanel, 2.0f)); + } + // ------------------------------- + yield return new WaitForSeconds(waitTime); // 2. 切换到 camera3 if (am != null) am.SwitchToCamera3(); } + private System.Collections.IEnumerator HideTipPanelAfterDelay(GameObject tipPanel, float delay) + { + yield return new WaitForSeconds(delay); + if (tipPanel != null) tipPanel.SetActive(false); + } + private void HideShose() { var shose = GameObject.Find("Shose");