using UnityEngine; using UnityEngine.UI; using vnxbqy.UI; public class GuideDialogueWin : Window { public GameObject playerPanel; public GameObject npcPanel; public Button markRay; public Button skip; public Text playerName; public Text npcName; public RawImage playerIcon; public RawImage npcIcon; public Text playerContent; public Text npcContent; private DialogConfig m_DialogConfig; public UnityEngine.Events.UnityAction onClose; private float m_WaitForClosed; protected override void AddListeners() { } protected override void BindController() { } protected override void OnAfterClose() { WindowCenter.Instance.Open(); if (onClose != null) { onClose(); onClose = null; } } protected override void OnAfterOpen() { } protected override void OnPreClose() { UI3DModelExhibition.Instance.StopShow(); markRay.RemoveAllListeners(); skip.RemoveAllListeners(); } protected override void OnPreOpen() { WindowCenter.Instance.Close(); markRay.RemoveAllListeners(); skip.RemoveAllListeners(); markRay.AddListener(OnMarkRayClick); skip.AddListener(OnSkipClick); GuideDialogueModel _model = ModelCenter.Instance.GetModel(); if (_model.dialogID == -1) { Debug.LogWarningFormat("打开对话界面但是没有设置对话内容ID..."); WindowCenter.Instance.Close(); return; } if (_model.onClose != null) { onClose = _model.onClose; } InitDialogInfo(_model.dialogID); m_WaitForClosed = 1; } protected override void LateUpdate() { base.LateUpdate(); m_WaitForClosed -= Time.deltaTime; } private void OnMarkRayClick() { if (m_WaitForClosed > 0) { return; } if (m_DialogConfig == null) { return; } if (m_DialogConfig.nextID != 0) { InitDialogInfo(m_DialogConfig.nextID); return; } WindowCenter.Instance.Close(); } private void OnSkipClick() { if (m_WaitForClosed > 0) { return; } WindowCenter.Instance.Close(); } private void InitDialogInfo(int id) { m_DialogConfig = DialogConfig.Get(id); if (m_DialogConfig == null) { Debug.LogWarningFormat("ID: {0} 的对话内容找不到对应的配置...", id); WindowCenter.Instance.Close(); return; } if (m_DialogConfig.npcId == 0) { playerPanel.SetActive(true); npcPanel.SetActive(false); playerName.text = PlayerDatas.Instance.baseData.PlayerName; playerContent.text = m_DialogConfig.content; UI3DModelExhibition.Instance.ShowPlayer(playerIcon, PlayerDatas.Instance.baseData.Job, true); } else { playerPanel.SetActive(false); npcPanel.SetActive(true); npcName.text = m_DialogConfig.name; npcContent.text = m_DialogConfig.content; var npcConfig = NPCConfig.Get(m_DialogConfig.npcId); var data = new UI3DNPCExhibitionData() { npcId = m_DialogConfig.npcId, isDialogue = true, }; UI3DModelExhibition.Instance.ShowNPC(npcIcon, data); } if (m_DialogConfig.TalkID != 0) { SoundPlayer.Instance.PlayNpcAudio(m_DialogConfig.TalkID); } } }