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
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
|
using System;
using KKSG;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUtliPoolLib;
namespace XMainClient
{
internal class XCharacterShowChatComponent : XComponent
{
public override uint ID
{
get
{
return XCharacterShowChatComponent.uuID;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("CharacterShowChatComponent");
public static string FEAST_TEMPLATE = "UI/Billboard/FeastingBill";
public static string CHAT_TEMPLATE = "UI/Billboard/ChatbubbleBill";
private bool _inited = false;
private IXUILabel _homeRemainTimeLabel;
private GameObject _gardenFeastObj;
private GameObject _chatBubbleObj;
private IXUITweenTool _chatTween;
private IXUISprite _chatBg;
private IXUILabelSymbol _chatLabelSymbol;
private IXUILabel _chatLabel;
private XBillboardComponent bbComp;
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._inited = false;
}
public override void Attached()
{
base.Attached();
}
private void Init()
{
this._gardenFeastObj = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(XCharacterShowChatComponent.FEAST_TEMPLATE, this._entity.EngineObject.Position, this._entity.EngineObject.Rotation, true, false);
this._chatBubbleObj = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(XCharacterShowChatComponent.CHAT_TEMPLATE, this._entity.EngineObject.Position, this._entity.EngineObject.Rotation, true, false);
this._homeRemainTimeLabel = (this._gardenFeastObj.GetComponent("XUILabel") as IXUILabel);
this._homeRemainTimeLabel.gameObject.SetActive(false);
this._chatLabelSymbol = (this._chatBubbleObj.transform.Find("Content/text").GetComponent("XUILabelSymbol") as IXUILabelSymbol);
this._chatLabel = (this._chatBubbleObj.transform.Find("Content/text").GetComponent("XUILabel") as IXUILabel);
this._chatTween = (this._chatBubbleObj.GetComponent("XUIPlayTween") as IXUITweenTool);
this._chatBg = (this._chatBubbleObj.transform.Find("Content/p").GetComponent("XUISprite") as IXUISprite);
this._gardenFeastObj.gameObject.SetActive(false);
this._chatBubbleObj.gameObject.SetActive(false);
this._inited = true;
}
protected override void EventSubscribe()
{
base.RegisterEvent(XEventDefine.XEvent_HomeFeasting, new XComponent.XEventHandler(this.OnFeastTimeChange));
}
public override void PostUpdate(float fDeltaT)
{
bool flag = !this._inited;
if (!flag)
{
bool flag2 = Time.frameCount % 15 == 0;
if (flag2)
{
float dis = Vector3.Distance(XSingleton<XScene>.singleton.GameCamera.UnityCamera.transform.position, this._chatBubbleObj.transform.position);
bool flag3 = this._entity != null;
if (flag3)
{
this.SetBoardDepth(this._entity.IsPlayer, dis);
}
}
XEntity xentity = this._host as XEntity;
XPlayer player = XSingleton<XEntityMgr>.singleton.Player;
bool flag4 = xentity == null || player == null || this.bbComp == null;
if (!flag4)
{
float num = Vector3.Distance(xentity.EngineObject.Position, player.EngineObject.Position);
bool flag5 = num > this.bbComp.viewDistance;
if (flag5)
{
bool flag6 = !this.bbComp.alwaysShow;
if (flag6)
{
this._chatTween.ResetTween(false);
}
}
}
}
}
private bool OnFeastTimeChange(XEventArgs e)
{
bool flag = !this._inited;
bool result;
if (flag)
{
result = false;
}
else
{
XEvent_HomeFeastingArgs xevent_HomeFeastingArgs = e as XEvent_HomeFeastingArgs;
SceneType sceneType = XSingleton<XScene>.singleton.SceneType;
bool flag2 = sceneType == SceneType.SCENE_FAMILYGARDEN;
if (flag2)
{
bool flag3 = xevent_HomeFeastingArgs.time < 1u;
if (flag3)
{
this.UnAttachFeastCdTime();
this._homeRemainTimeLabel.gameObject.SetActive(false);
}
else
{
this._homeRemainTimeLabel.gameObject.SetActive(true);
string @string = XSingleton<XStringTable>.singleton.GetString("HomeFeasting");
uint num = xevent_HomeFeastingArgs.time / 60u;
uint num2 = xevent_HomeFeastingArgs.time - 60u * num;
this._homeRemainTimeLabel.SetText(string.Concat(new object[]
{
@string,
"\n",
num,
":",
num2
}));
}
}
else
{
this.UnAttachFeastCdTime();
this._homeRemainTimeLabel.gameObject.SetActive(false);
}
result = true;
}
return result;
}
public void AttachChatBubble()
{
bool flag = !this._inited;
if (flag)
{
this.Init();
}
this.bbComp = this._entity.BillBoard;
bool flag2 = this.bbComp != null;
if (flag2)
{
bool flag3 = this.bbComp.AttachChild(this._chatBubbleObj.transform, false, 60f);
if (flag3)
{
this._chatBubbleObj.SetActive(true);
}
bool flag4 = this._chatTween != null;
if (flag4)
{
this._chatTween.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnChatPlayFinish));
}
}
}
private void OnChatPlayFinish(IXUITweenTool tween)
{
this.UnAttachChatBubble();
}
public void UnAttachChatBubble()
{
bool flag = !this._inited;
if (!flag)
{
XBillboardComponent billBoard = this._entity.BillBoard;
bool flag2 = billBoard != null;
if (flag2)
{
bool flag3 = billBoard.UnAttachChild(this._chatBubbleObj.transform);
if (flag3)
{
this._chatBubbleObj.SetActive(false);
}
}
}
}
public void DealWithChat(string content)
{
bool flag = !this._inited;
if (!flag)
{
bool flag2 = !XEntity.ValideEntity(this._entity);
if (!flag2)
{
bool flag3 = XSingleton<XGame>.singleton.CurrentStage.Stage == EXStage.Hall;
if (flag3)
{
bool flag4 = this._chatTween != null && this._chatLabelSymbol != null && this._chatBubbleObj != null;
if (flag4)
{
this._chatTween.ResetTween(true);
this._chatTween.PlayTween(true, -1f);
string text = "";
string text2 = "";
bool isPlayer = this._entity.IsPlayer;
if (isPlayer)
{
XPrerogativeDocument specificDocument = XDocuments.GetSpecificDocument<XPrerogativeDocument>(XPrerogativeDocument.uuID);
text = specificDocument.GetPreContent(PrerogativeType.PreChatBubble);
}
else
{
bool isRole = this._entity.IsRole;
if (isRole)
{
XRoleAttributes xroleAttributes = this._entity.Attributes as XRoleAttributes;
text = XPrerogativeDocument.ConvertTypeToPreContent(PrerogativeType.PreChatBubble, xroleAttributes.PrerogativeSetID);
}
}
bool flag5 = !string.IsNullOrEmpty(text);
if (flag5)
{
string[] array = text.Split(new char[]
{
'='
});
bool flag6 = array.Length == 3;
if (flag6)
{
this._chatBg.SetSprite(array[1], array[0], false);
text2 = array[2];
}
}
bool flag7 = string.IsNullOrEmpty(text2);
if (flag7)
{
this._chatLabelSymbol.InputText = DlgBase<ChatEmotionView, ChatEmotionBehaviour>.singleton.OnParseEmotion(content);
}
else
{
this._chatLabelSymbol.InputText = string.Format("[c][{0}]{1}[/c]", text2, DlgBase<ChatEmotionView, ChatEmotionBehaviour>.singleton.OnParseEmotion(content));
}
this._chatBg.spriteHeight = this._chatLabel.spriteHeight + 30;
int num = content.Length * (2 + this._chatLabel.fontSize);
this._chatBg.spriteWidth = Mathf.Min(this._chatLabel.spriteWidth, num) + 48;
}
}
}
}
}
public void AttachFeastCdTime()
{
bool flag = !this._inited;
if (flag)
{
this.Init();
}
XBillboardComponent billBoard = this._entity.BillBoard;
bool flag2 = billBoard != null;
if (flag2)
{
this._gardenFeastObj.transform.parent = null;
bool flag3 = billBoard.AttachChild(this._gardenFeastObj.transform, true, 45f);
if (flag3)
{
this._gardenFeastObj.SetActive(true);
}
}
}
public void UnAttachFeastCdTime()
{
bool flag = !this._inited;
if (!flag)
{
XBillboardComponent billBoard = this._entity.BillBoard;
bool flag2 = billBoard != null;
if (flag2)
{
bool flag3 = billBoard.UnAttachChild(this._gardenFeastObj.transform);
if (flag3)
{
this._gardenFeastObj.SetActive(false);
}
}
}
}
public override void OnDetachFromHost()
{
this.UnAttachChatBubble();
this.UnAttachFeastCdTime();
this.DestroyGameObjects();
base.OnDetachFromHost();
}
private void DestroyGameObjects()
{
XResourceLoaderMgr.SafeDestroy(ref this._chatBubbleObj, true);
XResourceLoaderMgr.SafeDestroy(ref this._gardenFeastObj, true);
}
private void SetBoardDepth(bool isMy, float dis = 0f)
{
int num = isMy ? 10 : (-(int)(dis * 100f));
bool flag = this._chatBg != null && this._chatLabel != null;
if (flag)
{
this._chatBg.spriteDepth = num + 1;
this._chatLabel.spriteDepth = num + 2;
this._chatLabelSymbol.UpdateDepth(num + 2);
}
}
}
}
|