2026-06-24 05:24:09 +08:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
public class PageController : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
[Header("=== 三个主页面 ===")]
|
|
|
|
|
|
[SerializeField] private GameObject _homePagePanel;
|
|
|
|
|
|
[SerializeField] private GameObject _modeSelectPanel;
|
|
|
|
|
|
[SerializeField] private GameObject _fixationPanel;
|
|
|
|
|
|
|
2026-06-25 04:55:41 +08:00
|
|
|
|
[Header("=== 实验页面 ===")]
|
|
|
|
|
|
[SerializeField] private GameObject _experimentPanel;
|
|
|
|
|
|
[SerializeField] private Button _btnExperimentBack;
|
|
|
|
|
|
|
2026-06-24 05:24:09 +08:00
|
|
|
|
[Header("=== 实验内 UI(由 UIManager 管理)===")]
|
|
|
|
|
|
[SerializeField] private UIManager _uiManager;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("=== 首页控件 ===")]
|
|
|
|
|
|
[SerializeField] private Button _btnStart;
|
|
|
|
|
|
[SerializeField] private Button _btnExit;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("=== 模式选择页控件 ===")]
|
|
|
|
|
|
[SerializeField] private Button _btnBack;
|
|
|
|
|
|
[SerializeField] private Button _btnPracticeMode;
|
|
|
|
|
|
[SerializeField] private Button _btnExamMode;
|
|
|
|
|
|
[SerializeField] private Text _modeDescText;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("=== 固定方式选择页控件 ===")]
|
|
|
|
|
|
[SerializeField] private Button _btnFixationBack;
|
|
|
|
|
|
[SerializeField] private Button _btnLimbFixation;
|
|
|
|
|
|
[SerializeField] private Button _btnSplintFixation;
|
|
|
|
|
|
|
|
|
|
|
|
[Header("=== 模式说明文案 ===")]
|
|
|
|
|
|
[SerializeField] [TextArea(2, 4)] private string _practiceModeDesc =
|
2026-06-25 04:55:41 +08:00
|
|
|
|
"模拟练习模式:不限时长,可反复练习。系统不评分,帮助您熟悉实验流程和操作步骤。";
|
2026-06-24 05:24:09 +08:00
|
|
|
|
[SerializeField] [TextArea(2, 4)] private string _examModeDesc =
|
2026-06-25 04:55:41 +08:00
|
|
|
|
"考核评估模式:限定时间,完成后系统自动评分,并提供详细反馈报告。";
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
2026-06-24 06:05:55 +08:00
|
|
|
|
[Header("=== 编辑器预览(仅 Editor 模式有效)===")]
|
|
|
|
|
|
[SerializeField] private EditorPreviewPage _editorPreview = EditorPreviewPage.None;
|
|
|
|
|
|
|
|
|
|
|
|
public enum Page { Home, ModeSelect, Fixation, Experiment }
|
|
|
|
|
|
public enum EditorPreviewPage { None, Home, ModeSelect, Fixation, Experiment }
|
|
|
|
|
|
|
2026-06-24 05:24:09 +08:00
|
|
|
|
private Page _currentPage = Page.Home;
|
|
|
|
|
|
private ExperimentMode _selectedMode = ExperimentMode.Learn;
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("=== PageController 初始化开始 ===");
|
|
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
// 一开始就隐藏鞋子,以免在主页或开场动画时穿帮
|
|
|
|
|
|
HideShose();
|
|
|
|
|
|
|
2026-07-01 21:56:12 +08:00
|
|
|
|
// 关掉多余AudioListener(只留Main Camera的)
|
|
|
|
|
|
var cam2 = GameObject.Find("camera2"); if (cam2 != null) { var al = cam2.GetComponent<AudioListener>(); if (al != null) al.enabled = false; }
|
|
|
|
|
|
var cam3 = GameObject.Find("camera3"); if (cam3 != null) { var al = cam3.GetComponent<AudioListener>(); if (al != null) al.enabled = false; }
|
2026-06-30 23:42:26 +08:00
|
|
|
|
|
2026-06-24 05:24:09 +08:00
|
|
|
|
// 绑定首页按钮
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnStart != null) { _btnStart.onClick.AddListener(OnStartClicked); Debug.Log("PageController: _btnStart 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnStart 未赋值!");
|
2026-06-27 13:25:58 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnExit != null) { _btnExit.onClick.AddListener(OnExitClicked); Debug.Log("PageController: _btnExit 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnExit 未赋值!");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnBack != null) { _btnBack.onClick.AddListener(OnModeBackClicked); Debug.Log("PageController: _btnBack 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnBack 未赋值!");
|
2026-06-27 13:25:58 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnPracticeMode != null) { _btnPracticeMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Learn)); Debug.Log("PageController: _btnPracticeMode 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnPracticeMode 未赋值!");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnExamMode != null) { _btnExamMode.onClick.AddListener(() => OnModeSelected(ExperimentMode.Exam)); Debug.Log("PageController: _btnExamMode 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnExamMode 未赋值!");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnFixationBack == null && _fixationPanel != null) { var fb = _fixationPanel.transform.Find("BtnBack"); if (fb != null) { _btnFixationBack = fb.GetComponent<Button>(); Debug.Log("PageController: 自动绑定 FixationPanel/BtnBack"); } }
|
|
|
|
|
|
if (_btnFixationBack != null) { _btnFixationBack.onClick.AddListener(OnFixationBackClicked); Debug.Log("PageController: _btnFixationBack 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnFixationBack 未找到!");
|
2026-06-27 13:25:58 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnLimbFixation != null) { _btnLimbFixation.onClick.AddListener(() => OnFixationSelected(FixationMethod.LimbFixation)); Debug.Log("PageController: _btnLimbFixation 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnLimbFixation 未赋值!");
|
2026-06-27 13:25:58 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnSplintFixation != null) { _btnSplintFixation.onClick.AddListener(() => OnFixationSelected(FixationMethod.SplintFixation)); Debug.Log("PageController: _btnSplintFixation 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnSplintFixation 未赋值!");
|
2026-06-27 13:25:58 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_btnExperimentBack == null && _experimentPanel != null) { var eb = _experimentPanel.transform.Find("Navbar/BtnBack"); if (eb != null) { _btnExperimentBack = eb.GetComponent<Button>(); Debug.Log("PageController: 自动绑定 ExperimentPanel/Navbar/BtnBack"); } }
|
|
|
|
|
|
if (_btnExperimentBack != null) { _btnExperimentBack.onClick.AddListener(OnExperimentBackClicked); Debug.Log("PageController: _btnExperimentBack 绑定成功"); }
|
|
|
|
|
|
else Debug.LogError("PageController: _btnExperimentBack 未找到!");
|
2026-06-25 04:55:41 +08:00
|
|
|
|
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (_modeDescText != null) { _modeDescText.text = _practiceModeDesc + "\n\n" + _examModeDesc; }
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
|
|
|
|
|
ShowPage(Page.Home);
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("=== PageController 初始化完成 ===");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-24 06:05:55 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
private void OnValidate()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (Application.isPlaying) return;
|
|
|
|
|
|
|
|
|
|
|
|
UnityEditor.EditorApplication.delayCall += () =>
|
|
|
|
|
|
{
|
|
|
|
|
|
if (this == null) return;
|
|
|
|
|
|
if (Application.isPlaying) return;
|
|
|
|
|
|
|
|
|
|
|
|
switch (_editorPreview)
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
case EditorPreviewPage.None: break;
|
|
|
|
|
|
case EditorPreviewPage.Home: ShowPageEditMode(Page.Home); break;
|
|
|
|
|
|
case EditorPreviewPage.ModeSelect: ShowPageEditMode(Page.ModeSelect); break;
|
|
|
|
|
|
case EditorPreviewPage.Fixation: ShowPageEditMode(Page.Fixation); break;
|
|
|
|
|
|
case EditorPreviewPage.Experiment: ShowPageEditMode(Page.Experiment); break;
|
2026-06-24 06:05:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_editorPreview = EditorPreviewPage.None;
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void ShowPageEditMode(Page page)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_homePagePanel != null) _homePagePanel.SetActive(page == Page.Home);
|
|
|
|
|
|
if (_modeSelectPanel != null) _modeSelectPanel.SetActive(page == Page.ModeSelect);
|
|
|
|
|
|
if (_fixationPanel != null) _fixationPanel.SetActive(page == Page.Fixation);
|
2026-06-25 04:55:41 +08:00
|
|
|
|
if (_experimentPanel != null) _experimentPanel.SetActive(page == Page.Experiment);
|
2026-07-01 22:42:39 +08:00
|
|
|
|
if (_uiManager != null) _uiManager.enabled = (page == Page.Experiment);
|
|
|
|
|
|
if (page == Page.Home) FindObjectOfType<AudioManager>()?.PlayHomeBg();
|
2026-06-24 06:05:55 +08:00
|
|
|
|
if (_uiManager != null)
|
|
|
|
|
|
_uiManager.enabled = (page == Page.Experiment);
|
2026-07-01 22:39:36 +08:00
|
|
|
|
if (page == Page.Home) FindObjectOfType<AudioManager>()?.PlayHomeBg(); // 背景音乐: 首页播 homeBg, 选固定方式时停, 实验启动时播 experimentBg
|
|
|
|
|
|
if (page == Page.Home) FindObjectOfType<AudioManager>()?.PlayHomeBg();
|
2026-06-24 06:05:55 +08:00
|
|
|
|
Debug.Log($"PageController(编辑器预览): 切换到 [{page}]");
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
2026-06-24 05:24:09 +08:00
|
|
|
|
#region 页面切换
|
|
|
|
|
|
|
2026-06-25 04:55:41 +08:00
|
|
|
|
private void ShowPage(Page page)
|
2026-06-24 05:24:09 +08:00
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log($"PageController: 页面切换 [{_currentPage}] → [{page}]");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
_currentPage = page;
|
|
|
|
|
|
|
|
|
|
|
|
if (_homePagePanel != null) _homePagePanel.SetActive(page == Page.Home);
|
|
|
|
|
|
if (_modeSelectPanel != null) _modeSelectPanel.SetActive(page == Page.ModeSelect);
|
|
|
|
|
|
if (_fixationPanel != null) _fixationPanel.SetActive(page == Page.Fixation);
|
2026-06-25 04:55:41 +08:00
|
|
|
|
if (_experimentPanel != null) _experimentPanel.SetActive(page == Page.Experiment);
|
2026-07-01 22:42:39 +08:00
|
|
|
|
if (_uiManager != null) _uiManager.enabled = (page == Page.Experiment);
|
|
|
|
|
|
if (page == Page.Home) FindObjectOfType<AudioManager>()?.PlayHomeBg();
|
2026-06-24 05:24:09 +08:00
|
|
|
|
}
|
2026-06-27 13:25:58 +08:00
|
|
|
|
|
2026-06-29 20:25:57 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 隐藏所有页面,用于播放片头动画时清空 UI
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void HideAllPages()
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("PageController: [HideAllPages] 隐藏所有 UI 面板");
|
|
|
|
|
|
if (_homePagePanel != null) _homePagePanel.SetActive(false);
|
|
|
|
|
|
if (_modeSelectPanel != null) _modeSelectPanel.SetActive(false);
|
|
|
|
|
|
if (_fixationPanel != null) _fixationPanel.SetActive(false);
|
|
|
|
|
|
if (_experimentPanel != null) _experimentPanel.SetActive(false);
|
2026-06-30 01:22:54 +08:00
|
|
|
|
|
|
|
|
|
|
var tipPanel = GameObject.Find("TipPanel");
|
|
|
|
|
|
if (tipPanel != null) tipPanel.SetActive(false);
|
2026-06-30 01:37:40 +08:00
|
|
|
|
|
|
|
|
|
|
var dialogue = GameObject.Find("DialogueBubble");
|
|
|
|
|
|
if (dialogue != null) dialogue.SetActive(false);
|
2026-06-29 20:25:57 +08:00
|
|
|
|
}
|
2026-06-24 05:24:09 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 按钮回调
|
|
|
|
|
|
|
|
|
|
|
|
private void OnStartClicked()
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("PageController: [BtnStart] 点击 -> 切换到 ModeSelect");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
ShowPage(Page.ModeSelect);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnExitClicked()
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("PageController: [BtnExit] 点击 -> 退出应用");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
UnityEditor.EditorApplication.isPlaying = false;
|
|
|
|
|
|
#else
|
|
|
|
|
|
Application.Quit();
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnModeBackClicked()
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("PageController: [BtnBack(Mode)] 点击 -> 返回 Home");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
ShowPage(Page.Home);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnModeSelected(ExperimentMode mode)
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log($"PageController: [ModeSelected] 点击 -> 模式 [{mode}] -> 切换到 Fixation");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
_selectedMode = mode;
|
|
|
|
|
|
|
|
|
|
|
|
ShowPage(Page.Fixation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void OnFixationBackClicked()
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("PageController: [BtnFixationBack] 点击 -> 返回 ModeSelect");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
if (_modeDescText != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
_modeDescText.text = _practiceModeDesc + "\n\n" + _examModeDesc;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ShowPage(Page.ModeSelect);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 04:55:41 +08:00
|
|
|
|
private void OnExperimentBackClicked()
|
|
|
|
|
|
{
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log("PageController: [BtnExperimentBack] 点击 -> 返回 Fixation");
|
2026-06-25 04:55:41 +08:00
|
|
|
|
ShowPage(Page.Fixation);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-24 05:24:09 +08:00
|
|
|
|
private void OnFixationSelected(FixationMethod method)
|
|
|
|
|
|
{
|
2026-06-29 20:25:57 +08:00
|
|
|
|
Debug.Log($"PageController: [FixationSelected] 点击 -> 固定方式 [{method}]");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
var gm = GameManager.Instance;
|
|
|
|
|
|
if (gm == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogError("PageController: GameManager.Instance 为空!");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
gm.CurrentMode = _selectedMode;
|
|
|
|
|
|
gm.CurrentFixationMethod = method;
|
2026-06-27 13:25:58 +08:00
|
|
|
|
Debug.Log($"PageController: GameManager 已设置 Mode=[{gm.CurrentMode}] Fixation=[{gm.CurrentFixationMethod}]");
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
2026-06-29 20:25:57 +08:00
|
|
|
|
// 隐藏所有UI面板,准备播放片头动画
|
2026-07-01 22:39:36 +08:00
|
|
|
|
FindObjectOfType<AudioManager>()?.StopBgMusic();
|
2026-07-01 22:42:39 +08:00
|
|
|
|
FindObjectOfType<AudioManager>()?.StopBgMusic();
|
2026-07-01 20:19:17 +08:00
|
|
|
|
HideAllPages();
|
2026-06-24 05:24:09 +08:00
|
|
|
|
|
2026-06-29 20:25:57 +08:00
|
|
|
|
// 找到 OpeningFlowController 播放片头动画
|
|
|
|
|
|
var openingFlow = FindObjectOfType<OpeningFlowController>();
|
|
|
|
|
|
if (openingFlow != null)
|
2026-06-24 05:24:09 +08:00
|
|
|
|
{
|
2026-06-29 20:25:57 +08:00
|
|
|
|
Debug.Log("PageController: 开始播放片头动画,ExperimentPanel 将在动画结束后显示");
|
|
|
|
|
|
openingFlow.PlayOpeningFlow(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("PageController: 片头动画完成,显示 ExperimentPanel");
|
2026-06-30 02:26:32 +08:00
|
|
|
|
ActivateExperimentObjects();
|
2026-06-30 14:32:30 +08:00
|
|
|
|
var smW = FindObjectOfType<StepManager>(); if (smW != null) smW.InitWomanSteps(); ShowPage(Page.Experiment);
|
2026-06-29 20:25:57 +08:00
|
|
|
|
|
|
|
|
|
|
var stepManager = FindObjectOfType<StepManager>();
|
|
|
|
|
|
if (stepManager != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.LogWarning("PageController: 未找到 StepManager,实验步骤不会自动初始化");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2026-06-27 13:25:58 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2026-06-29 20:25:57 +08:00
|
|
|
|
Debug.LogWarning("PageController: 未找到 OpeningFlowController,直接显示 ExperimentPanel");
|
|
|
|
|
|
ShowPage(Page.Experiment);
|
|
|
|
|
|
|
|
|
|
|
|
var stepManager = FindObjectOfType<StepManager>();
|
|
|
|
|
|
if (stepManager != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
}
|
2026-06-24 05:24:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-30 02:19:13 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 激活实验场景物件(medicalBox等),在动画完成后调用
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private void ActivateExperimentObjects()
|
|
|
|
|
|
{
|
|
|
|
|
|
Debug.Log("PageController: [ActivateExperimentObjects] 显示实验物件");
|
2026-06-30 02:26:32 +08:00
|
|
|
|
|
2026-07-05 02:23:53 +08:00
|
|
|
|
// 强制确保所有 ping/chanrao/chanraotuibu 隐藏
|
|
|
|
|
|
var miClean = GameObject.Find("manInjury");
|
|
|
|
|
|
if (miClean != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (Transform child in miClean.transform)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (child.name.Contains("ping") || child.name.Contains("chanrao"))
|
|
|
|
|
|
{
|
|
|
|
|
|
child.gameObject.SetActive(false);
|
|
|
|
|
|
Debug.Log("PageController: 强制隐藏 " + child.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-01 22:39:36 +08:00
|
|
|
|
FindObjectOfType<AudioManager>()?.PlayExperimentBg();
|
2026-07-01 22:42:39 +08:00
|
|
|
|
|
|
|
|
|
|
FindObjectOfType<AudioManager>()?.PlayExperimentBg();
|
2026-06-30 23:42:26 +08:00
|
|
|
|
|
2026-06-30 02:26:32 +08:00
|
|
|
|
var allObjects = FindObjectsOfType<GameObject>(true);
|
|
|
|
|
|
foreach (var go in allObjects)
|
|
|
|
|
|
{
|
2026-06-30 23:42:26 +08:00
|
|
|
|
if (go.name == "medicalBox") { go.SetActive(true); Debug.Log("PageController: medicalBox 已显示"); break; }
|
2026-06-30 02:26:32 +08:00
|
|
|
|
}
|
2026-06-30 02:49:27 +08:00
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
// 隐藏所有的 point1, 2, 3,不要让它们显示出来
|
|
|
|
|
|
var touchArray = GameObject.Find("touchArray");
|
|
|
|
|
|
if (touchArray != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
foreach (Transform child in touchArray.transform)
|
|
|
|
|
|
{
|
|
|
|
|
|
child.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 把 woman 直接放到 point1 的位置
|
|
|
|
|
|
var woman = GameObject.Find("woman");
|
|
|
|
|
|
var point1 = GameObject.Find("womanPointArray/point1");
|
|
|
|
|
|
if (woman != null && point1 != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
woman.transform.position = point1.transform.position;
|
|
|
|
|
|
woman.transform.rotation = point1.transform.rotation;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 启动语音、等待及切换摄像机并激活鞋子的流程
|
|
|
|
|
|
StartCoroutine(StartInitialVoiceAndCameraRoutine());
|
2026-06-30 23:42:26 +08:00
|
|
|
|
|
|
|
|
|
|
var tipPanel = GameObject.Find("TipPanel");
|
|
|
|
|
|
if (tipPanel != null) tipPanel.SetActive(true);
|
|
|
|
|
|
var dialogue = GameObject.Find("DialogueBubble");
|
|
|
|
|
|
if (dialogue != null) dialogue.SetActive(true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 04:37:45 +08:00
|
|
|
|
public void ReturnToHome()
|
|
|
|
|
|
{
|
2026-06-30 02:19:13 +08:00
|
|
|
|
Debug.Log("PageController: [ReturnToHome] 返回首页并重置场景");
|
|
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
HideShose();
|
|
|
|
|
|
|
2026-06-30 02:19:13 +08:00
|
|
|
|
var man = GameObject.Find("man");
|
|
|
|
|
|
if (man != null) man.SetActive(true);
|
|
|
|
|
|
var man2 = GameObject.Find("man2");
|
|
|
|
|
|
if (man2 != null) man2.SetActive(true);
|
|
|
|
|
|
|
|
|
|
|
|
var woman = GameObject.Find("woman");
|
|
|
|
|
|
if (woman != null) woman.SetActive(false);
|
|
|
|
|
|
var manInjury = GameObject.Find("manInjury");
|
|
|
|
|
|
if (manInjury != null) manInjury.SetActive(false);
|
|
|
|
|
|
var medicalBox = GameObject.Find("medicalBox");
|
|
|
|
|
|
if (medicalBox != null) medicalBox.SetActive(false);
|
2026-07-04 16:48:30 +08:00
|
|
|
|
// 隐藏所有 ping/chanrao/chanraotuibu
|
|
|
|
|
|
var mi = GameObject.Find("manInjury");
|
|
|
|
|
|
if (mi != null) {
|
|
|
|
|
|
foreach (Transform child in mi.transform) {
|
|
|
|
|
|
if (child.name.Contains("ping") || child.name.Contains("chanrao"))
|
|
|
|
|
|
child.gameObject.SetActive(false);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2026-06-30 02:19:13 +08:00
|
|
|
|
|
2026-06-30 14:55:40 +08:00
|
|
|
|
// 用名字找主摄像机(Camera.main 在禁用后返回 null)
|
|
|
|
|
|
var mainGo = GameObject.Find("Main Camera");
|
|
|
|
|
|
if (mainGo != null) { var c = mainGo.GetComponent<Camera>(); if (c != null) c.enabled = true; }
|
|
|
|
|
|
var cam2Go = GameObject.Find("camera2");
|
|
|
|
|
|
if (cam2Go != null) { var c = cam2Go.GetComponent<Camera>(); if (c != null) c.enabled = false; }
|
2026-07-08 09:38:42 +08:00
|
|
|
|
var cam3Go = GameObject.Find("camera3");
|
|
|
|
|
|
if (cam3Go != null) { var c = cam3Go.GetComponent<Camera>(); if (c != null) c.enabled = false; }
|
2026-06-30 02:19:13 +08:00
|
|
|
|
|
|
|
|
|
|
var manAnim = man != null ? man.GetComponent<Animator>() : null;
|
2026-06-30 15:09:31 +08:00
|
|
|
|
if (manAnim != null) { manAnim.SetBool("IsStart", false); manAnim.SetBool("IsFull", false); manAnim.Play("manIdle", 0, 0f); }
|
2026-06-30 02:19:13 +08:00
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
// 重置 woman 动画
|
|
|
|
|
|
if (woman != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var wAnim = woman.GetComponent<Animator>();
|
|
|
|
|
|
if (wAnim != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
wAnim.SetBool("isCrouch", false);
|
|
|
|
|
|
wAnim.Play("Idle", 0, 0f); // 假设其默认闲置动画为 Idle 或类似名称
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重置 manInjury 动画
|
|
|
|
|
|
if (mi != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var mAnim = mi.GetComponent<Animator>();
|
|
|
|
|
|
if (mAnim != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
mAnim.SetBool("CheckFoot", false);
|
|
|
|
|
|
mAnim.Play("manInjury", 0, 0f); // 默认动画
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 重置所有的 Handler 状态
|
|
|
|
|
|
foreach (var handler in mi.GetComponentsInChildren<PingClickHandler>(true)) handler.ResetState();
|
|
|
|
|
|
foreach (var handler in mi.GetComponentsInChildren<ChanraoTuibuHandler>(true)) handler.ResetState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// 找到 Shose 重置点击状态
|
|
|
|
|
|
var shose = GameObject.Find("Shose");
|
|
|
|
|
|
if (shose == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var allTransforms = Resources.FindObjectsOfTypeAll<Transform>();
|
|
|
|
|
|
foreach(var t in allTransforms) { if (t.parent == null && t.name == "Shose") { shose = t.gameObject; break; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
if (shose != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var h = shose.GetComponent<ShoseClickHandler>();
|
|
|
|
|
|
if (h != null) h.ResetState();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-25 04:37:45 +08:00
|
|
|
|
ShowPage(Page.Home);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
private System.Collections.IEnumerator StartInitialVoiceAndCameraRoutine()
|
|
|
|
|
|
{
|
|
|
|
|
|
float waitTime = 1f; // 默认等1秒
|
|
|
|
|
|
var am = FindObjectOfType<AudioManager>();
|
|
|
|
|
|
|
|
|
|
|
|
// 实验刚开始,立刻激活鞋子,不等语音播完
|
|
|
|
|
|
var shose = GameObject.Find("Shose");
|
|
|
|
|
|
if (shose == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
// 如果被禁用了,找它的最顶层引用
|
|
|
|
|
|
var allTransforms = Resources.FindObjectsOfTypeAll<Transform>();
|
|
|
|
|
|
foreach(var t in allTransforms) { if (t.parent == null && t.name == "Shose") { shose = t.gameObject; break; } }
|
|
|
|
|
|
}
|
|
|
|
|
|
if (shose != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var h = shose.GetComponent<ShoseClickHandler>();
|
|
|
|
|
|
if (h == null) h = shose.AddComponent<ShoseClickHandler>();
|
|
|
|
|
|
h.targetPoint = GameObject.Find("ShosePoint")?.transform;
|
|
|
|
|
|
if (h.nextObject == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var chanraotuibu = GameObject.Find("chanraotuibu");
|
|
|
|
|
|
if (chanraotuibu == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
var mi = GameObject.Find("manInjury");
|
|
|
|
|
|
if (mi != null) chanraotuibu = mi.transform.Find("chanraotuibu")?.gameObject;
|
|
|
|
|
|
}
|
|
|
|
|
|
h.nextObject = chanraotuibu;
|
|
|
|
|
|
}
|
|
|
|
|
|
shose.SetActive(false);
|
|
|
|
|
|
shose.SetActive(true);
|
|
|
|
|
|
Debug.Log("PageController: 开场动画结束,Shose 已立刻激活");
|
|
|
|
|
|
}
|
2026-07-01 21:18:34 +08:00
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
// 1. 强制播放第一句语音:“周围环境安全,我是救护志愿者,我可以帮助您吗”
|
|
|
|
|
|
if (am != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
#if UNITY_EDITOR
|
|
|
|
|
|
var autoClip = UnityEditor.AssetDatabase.LoadAssetAtPath<AudioClip>("Assets/Audio/people/周围环境安全,我是救护志愿者,我可以帮助您吗.mp3");
|
|
|
|
|
|
if (autoClip != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
am.PlayVoice(autoClip);
|
|
|
|
|
|
waitTime = autoClip.length + 1f;
|
|
|
|
|
|
}
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Debug.Log($"PageController: 开始等待 {waitTime} 秒以切换摄像机并激活鞋子");
|
|
|
|
|
|
yield return new WaitForSeconds(waitTime);
|
|
|
|
|
|
|
|
|
|
|
|
// 2. 切换到 camera3
|
|
|
|
|
|
if (am != null) am.SwitchToCamera3();
|
|
|
|
|
|
}
|
2026-07-01 21:18:34 +08:00
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
private void HideShose()
|
|
|
|
|
|
{
|
|
|
|
|
|
var shose = GameObject.Find("Shose");
|
|
|
|
|
|
if (shose != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
shose.SetActive(false);
|
|
|
|
|
|
}
|
2026-07-01 21:18:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2026-07-01 21:18:34 +08:00
|
|
|
|
|
2026-07-08 09:38:42 +08:00
|
|
|
|
}
|