少年修仙传客户端代码仓库
hch
2025-03-03 28785d6ddf9c08e49527ede9405c7b6c93c6ed32
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
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<MainInterfaceWin>();
 
        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<MainInterfaceWin>();
 
        markRay.RemoveAllListeners();
        skip.RemoveAllListeners();
        markRay.AddListener(OnMarkRayClick);
        skip.AddListener(OnSkipClick);
 
        GuideDialogueModel _model = ModelCenter.Instance.GetModel<GuideDialogueModel>();
 
        if (_model.dialogID == -1)
        {
            Debug.LogWarningFormat("打开对话界面但是没有设置对话内容ID...");
            WindowCenter.Instance.Close<GuideDialogueWin>();
            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<GuideDialogueWin>();
    }
 
    private void OnSkipClick()
    {
        if (m_WaitForClosed > 0)
        {
            return;
        }
 
        WindowCenter.Instance.Close<GuideDialogueWin>();
    }
 
    private void InitDialogInfo(int id)
    {
        m_DialogConfig = DialogConfig.Get(id);
 
        if (m_DialogConfig == null)
        {
            Debug.LogWarningFormat("ID: {0} 的对话内容找不到对应的配置...", id);
            WindowCenter.Instance.Close<GuideDialogueWin>();
            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);
        }
    }
}