summaryrefslogtreecommitdiff
path: root/Client/Assets/Scripts/XMainClient/XChatMaqueeView.cs
blob: 9eaf8290a7abd16213dee1d41d4a8ae37442b57b (plain)
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
using System;
using System.Collections.Generic;
using KKSG;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;

namespace XMainClient
{
	internal class XChatMaqueeView : DlgBase<XChatMaqueeView, XChatMaqueeBehaviour>
	{
		public override string fileName
		{
			get
			{
				return "GameSystem/ChatMaqueeDlg";
			}
		}

		public override bool isHideChat
		{
			get
			{
				return false;
			}
		}

		public override int group
		{
			get
			{
				return 1;
			}
		}

		public override bool autoload
		{
			get
			{
				return true;
			}
		}

		public override bool needOnTop
		{
			get
			{
				return true;
			}
		}

		private XChatDocument _doc = null;

		private bool m_IsPlaying;

		private List<MaqueeInfo> m_MaqueeFirst = new List<MaqueeInfo>();

		private List<MaqueeInfo> m_MaqueeSecond = new List<MaqueeInfo>();

		private List<MaqueeInfo> m_MaqueeThird = new List<MaqueeInfo>();

		private int m_OffsetStart = 0;

		private int m_OffsetEnd = 0;

		private int m_CurOffset = 0;

		private float m_CurShowTime = 0f;

		private bool m_MaqueeSwitch = true;

		private MaqueeInfo m_PlayingMaquee;

		protected override void Init()
		{
			this._doc = XDocuments.GetSpecificDocument<XChatDocument>(XChatDocument.uuID);
			this._doc.ChatMaqueeView = this;
		}

		public override void RegisterEvent()
		{
		}

		protected override void OnShow()
		{
			base.OnShow();
		}

		protected override void OnUnload()
		{
			this._doc = null;
			this.m_IsPlaying = false;
			this.m_MaqueeThird.Clear();
			base.OnUnload();
		}

		public void ShowMaquee()
		{
			this.SetVisible(true, true);
		}

		public void HideMaquee()
		{
			this.SetVisible(false, true);
		}

		public void SetMaqueeSwitch(bool enable)
		{
			this.m_MaqueeSwitch = enable;
			bool flag = !base.IsLoaded();
			if (!flag)
			{
				bool flag2 = !enable;
				if (flag2)
				{
					this.m_IsPlaying = false;
					this.SetVisible(false, true);
				}
				else
				{
					this.PlayFinished();
				}
			}
		}

		public void ReceiveChatInfo(KKSG.ChatInfo chatinfo)
		{
			SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
			bool flag = sceneType != SceneType.SCENE_HALL && sceneType != SceneType.SCENE_GUILD_HALL && sceneType != SceneType.SCENE_BATTLE && sceneType != SceneType.SCENE_FAMILYGARDEN && sceneType != SceneType.SCENE_ABYSSS && sceneType != SceneType.SCENE_TOWER && sceneType != SceneType.SCENE_NEST && sceneType != SceneType.SCENE_LEISURE;
			if (!flag)
			{
				bool flag2 = !this.m_MaqueeSwitch;
				if (!flag2)
				{
					bool flag3 = chatinfo.level <= XSingleton<XAttributeMgr>.singleton.XPlayerData.Level;
					if (flag3)
					{
						bool flag4 = chatinfo.channel == 5u;
						if (flag4)
						{
							this.AddMaqueeNormalInfo(chatinfo.info, 0f);
						}
						else
						{
							this.AddMaqueeNormalInfo(chatinfo.info, 5f);
						}
					}
				}
			}
		}

		public void AddMaqueeNormalInfo(string info, float stopTime)
		{
			bool flag = info == null;
			if (!flag)
			{
				this.ShowMaquee();
				MaqueeInfo maqueeInfo = new MaqueeInfo();
				maqueeInfo.content = info;
				maqueeInfo.playTimes = 1;
				maqueeInfo.showTime = stopTime;
				maqueeInfo.playSpeed = XSingleton<XGlobalConfig>.singleton.GetInt("MaqueeSpeed");
				this.m_MaqueeThird.Add(maqueeInfo);
				bool flag2 = !this.m_IsPlaying;
				if (flag2)
				{
					this.StartPlayMaquee(maqueeInfo);
				}
			}
		}

		public void StartPlayMaquee(MaqueeInfo maquee)
		{
			string text = XLabelSymbolHelper.RemoveFormatInfo(maquee.content);
			bool flag = !base.IsVisible();
			if (flag)
			{
				this.SetVisible(true, true);
			}
			base.uiBehaviour.m_MaqueeText.SetText(text);
			Vector2 printSize = base.uiBehaviour.m_MaqueeText.GetPrintSize();
			base.uiBehaviour.m_MaqueeTextSymbol.InputText = text;
			this.m_PlayingMaquee = maquee;
			this.m_IsPlaying = true;
			this.m_CurShowTime = maquee.showTime;
			this.m_OffsetStart = (int)(printSize.x / 2f) + base.uiBehaviour.m_MaqueeBoard.spriteWidth / 2 + 20;
			this.m_OffsetEnd = -1 * this.m_OffsetStart;
			this.m_CurOffset = this.m_OffsetStart;
			base.uiBehaviour.m_MaqueeTween.PlayTween(true, -1f);
		}

		public void UpdateMaquee(float delta)
		{
			bool flag = !this.m_IsPlaying || !base.IsVisible();
			if (!flag)
			{
				bool flag2 = this.m_CurOffset <= 0 && this.m_CurShowTime > 0f;
				if (flag2)
				{
					this.m_CurShowTime -= delta;
				}
				else
				{
					this.m_CurOffset -= (int)(delta * (float)this.m_PlayingMaquee.playSpeed);
					base.uiBehaviour.m_MaqueeText.gameObject.transform.localPosition = new Vector3((float)this.m_CurOffset, base.uiBehaviour.m_MaqueeText.gameObject.transform.localPosition.y, base.uiBehaviour.m_MaqueeText.gameObject.transform.localPosition.z);
					bool flag3 = this.m_CurOffset <= this.m_OffsetEnd;
					if (flag3)
					{
						this.PlayFinished();
					}
				}
			}
		}

		public void PlayFinished()
		{
			bool flag = this.m_PlayingMaquee == null;
			if (!flag)
			{
				bool flag2 = this.m_PlayingMaquee.playTimes > 1;
				if (flag2)
				{
					this.m_CurOffset = this.m_OffsetStart;
					this.m_PlayingMaquee.playTimes--;
					this.m_CurShowTime = this.m_PlayingMaquee.showTime;
				}
				else
				{
					this.m_MaqueeThird.RemoveAt(0);
					bool flag3 = this.m_MaqueeThird.Count > 0;
					if (flag3)
					{
						this.StartPlayMaquee(this.m_MaqueeThird[0]);
					}
					else
					{
						this.m_IsPlaying = false;
						base.uiBehaviour.m_MaqueeTween.PlayTween(false, -1f);
						base.UnLoad(false);
					}
				}
			}
		}
	}
}