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
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
|
using System;
using UILib;
using UnityEngine;
using XMainClient.UI;
using XUtliPoolLib;
namespace XMainClient
{
internal sealed class XMobaBillboardComponent : XComponent
{
public override uint ID
{
get
{
return XMobaBillboardComponent.uuID;
}
}
public new static readonly uint uuID = XSingleton<XCommon>.singleton.XHash("Moba_Billboard");
private XMobaBattleDocument _mobaDoc;
private Transform _billboard = null;
private IUIDummy _uiDummy = null;
private IUIBloodGrid _bloodGrid = null;
private IXUIProgress _bloodBar;
private IXUIProgress _indureBar;
public IXUILabelSymbol _name;
public IXUILabel _level;
public IXUISprite _exp;
public string NameStr = "";
private XBuffMonitorHandler _buffMonitor;
private bool InitByMaster = false;
private float _heroHeight = 10f;
private static float k = 0.007f;
private float _viewDistance = 10f;
private int _alwaysHide = 0;
public static string HPBAR_TEMPLATE = "UI/Billboard/MobaBillboard";
private static readonly string MILITARY_ATLAS = "common/Billboard";
public static readonly string billboardString_red = "[e8280c]";
public static readonly string billboardString_green = "[53d103]";
public static readonly string billboardString_blue = "[0aabd0]";
public static readonly Color billboard_red = new Color32(232, 40, 12, byte.MaxValue);
public static readonly Color billboard_green = new Color32(83, 209, 3, byte.MaxValue);
public static readonly Color billboard_blue = new Color32(10, 171, 208, byte.MaxValue);
private BillboardUsage _secondbar_usage = BillboardUsage.MP;
public override void OnAttachToHost(XObject host)
{
base.OnAttachToHost(host);
this._mobaDoc = XDocuments.GetSpecificDocument<XMobaBattleDocument>(XMobaBattleDocument.uuID);
GameObject gameObject = XSingleton<XResourceLoaderMgr>.singleton.CreateFromPrefab(XMobaBillboardComponent.HPBAR_TEMPLATE, this._entity.EngineObject.Position, this._entity.EngineObject.Rotation, true, false);
bool flag = gameObject != null;
if (flag)
{
this._billboard = gameObject.transform;
}
this._uiDummy = (this._billboard.GetComponent("UIDummy") as IUIDummy);
IUIRect parent = XSingleton<XGameUI>.singleton.HpbarRoot.UIComponent as IUIRect;
XSingleton<UiUtility>.singleton.AddChild(parent, gameObject, XSingleton<XGameUI>.singleton.HpbarRoot);
}
protected override void EventSubscribe()
{
base.RegisterEvent(XEventDefine.XEvent_BillboardShowCtrl, new XComponent.XEventHandler(this.OnShowCtrl));
base.RegisterEvent(XEventDefine.XEvent_BuffChange, new XComponent.XEventHandler(this.OnBuffChange));
}
public override void Attached()
{
base.Attached();
this._bloodBar = (this._billboard.Find("Hpbar").GetComponent("XUIProgress") as IXUIProgress);
this._bloodGrid = (this._billboard.Find("Hpbar/BloodGrid").GetComponent("UIBloodGrid") as IUIBloodGrid);
this._bloodGrid.SetMAXHP((int)this._entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total));
this._indureBar = (this._billboard.Find("Indure").GetComponent("XUIProgress") as IXUIProgress);
this._name = (this._billboard.Find("Name").GetComponent("XUILabelSymbol") as IXUILabelSymbol);
this._level = (this._billboard.Find("Level").GetComponent("XUILabel") as IXUILabel);
this._exp = (this._level.gameObject.transform.Find("frame").GetComponent("XUISprite") as IXUISprite);
GameObject gameObject = this._billboard.transform.Find("BuffFrame").gameObject;
DlgHandlerBase.EnsureCreate<XBuffMonitorHandler>(ref this._buffMonitor, gameObject, null, true);
bool isPlayer = this._entity.IsPlayer;
if (isPlayer)
{
this._bloodBar.SetForegroundColor(XMobaBillboardComponent.billboard_green);
}
else
{
bool flag = XSingleton<XEntityMgr>.singleton.IsOpponent(this._entity);
if (flag)
{
this._bloodBar.SetForegroundColor(XMobaBillboardComponent.billboard_red);
}
else
{
this._bloodBar.SetForegroundColor(XMobaBillboardComponent.billboard_blue);
}
}
bool isRole = this._entity.IsRole;
if (isRole)
{
uint num = this._entity.IsPlayer ? XSingleton<XAttributeMgr>.singleton.XPlayerData.MilitaryRank : (this._entity.Attributes as XRoleAttributes).MilitaryRank;
bool flag2 = num == 0u;
if (flag2)
{
this.SetNameStr(this._entity.Attributes.Name);
}
else
{
MilitaryRankByExploit.RowData byMilitaryRank = XMilitaryRankDocument._militaryReader.GetByMilitaryRank(num);
this.SetNameStr(XLabelSymbolHelper.FormatImage(XMobaBillboardComponent.MILITARY_ATLAS, byMilitaryRank.Icon) + this._entity.Attributes.Name);
}
}
else
{
this._name.SetVisible(false);
}
bool flag3 = this._buffMonitor != null;
if (flag3)
{
this._buffMonitor.InitMonitor(XSingleton<XGlobalConfig>.singleton.BuffMaxDisplayCountTeam, true, false);
}
this._heroHeight = this._entity.Height;
this._billboard.transform.localScale = Vector3.one * XMobaBillboardComponent.k;
this._uiDummy.alpha = 0f;
}
private void SetNameStr(string str)
{
this.NameStr = str;
this._name.InputText = str;
}
private void DestroyGameObjects()
{
bool flag = this._billboard != null;
if (flag)
{
XSingleton<XResourceLoaderMgr>.singleton.UnSafeDestroy(this._billboard.gameObject, true, false);
this._billboard = null;
}
}
public override void OnDetachFromHost()
{
this._alwaysHide = 0;
this.DestroyGameObjects();
base.OnDetachFromHost();
}
private bool OnShowCtrl(XEventArgs e)
{
XBillboardShowCtrlEventArgs xbillboardShowCtrlEventArgs = e as XBillboardShowCtrlEventArgs;
bool flag = xbillboardShowCtrlEventArgs.type == BillBoardHideType.Invalid;
bool result;
if (flag)
{
XSingleton<XDebug>.singleton.AddErrorLog("undefine billboard hide type. check code or contect pyc.", null, null, null, null, null);
result = false;
}
else
{
bool show = xbillboardShowCtrlEventArgs.show;
if (show)
{
this._alwaysHide &= ~(1 << XFastEnumIntEqualityComparer<BillBoardHideType>.ToInt(xbillboardShowCtrlEventArgs.type));
}
else
{
this._alwaysHide |= 1 << XFastEnumIntEqualityComparer<BillBoardHideType>.ToInt(xbillboardShowCtrlEventArgs.type);
}
result = true;
}
return result;
}
private bool OnBuffChange(XEventArgs args)
{
XBuffChangeEventArgs xbuffChangeEventArgs = args as XBuffChangeEventArgs;
bool isRole = xbuffChangeEventArgs.entity.IsRole;
if (isRole)
{
XBuffComponent buffs = xbuffChangeEventArgs.entity.Buffs;
bool flag = buffs != null;
if (flag)
{
this._buffMonitor.OnBuffChanged(buffs.GetUIBuffList());
}
}
return true;
}
private void SetBillBoardSameByMaster()
{
bool flag = XEntity.ValideEntity(this._entity.MobbedBy);
if (flag)
{
XMobaBillboardComponent xmobaBillboardComponent = this._entity.MobbedBy.GetXComponent(XMobaBillboardComponent.uuID) as XMobaBillboardComponent;
this._name.SetVisible(true);
this._name.InputText = xmobaBillboardComponent.NameStr;
this._level.SetText(xmobaBillboardComponent._level.GetText());
}
}
public override void PostUpdate(float fDeltaT)
{
XEntity xentity = this._host as XEntity;
bool flag = xentity == null;
if (!flag)
{
bool flag2 = !this.InitByMaster && this._entity.MobbedBy != null;
if (flag2)
{
this.InitByMaster = true;
XOthersAttributes xothersAttributes = this._entity.Attributes as XOthersAttributes;
bool sameBillBoardByMaster = xothersAttributes.SameBillBoardByMaster;
if (sameBillBoardByMaster)
{
this.SetBillBoardSameByMaster();
}
}
bool flag3 = !XEntity.ValideEntity(xentity);
if (flag3)
{
this._uiDummy.alpha = 0f;
}
else
{
bool flag4 = this._alwaysHide != 0;
if (flag4)
{
this._uiDummy.alpha = 0f;
}
else
{
XPlayer player = XSingleton<XEntityMgr>.singleton.Player;
bool flag5 = player == null || player.EngineObject == null;
if (flag5)
{
this.DestroyGameObjects();
}
else
{
float num = Vector3.Distance(xentity.EngineObject.Position, player.EngineObject.Position);
bool flag6 = num > this._viewDistance;
if (flag6)
{
bool flag7 = this._billboard != null;
if (flag7)
{
this._uiDummy.alpha = 0f;
return;
}
}
bool flag8 = this._billboard != null;
if (flag8)
{
this.UpdateHpBar();
}
}
}
}
}
}
private void UpdateHpBar()
{
bool flag = this._uiDummy.alpha == 0f;
if (flag)
{
this._uiDummy.alpha = 1f;
}
float num = 0.2f;
bool flag2 = !this._bloodBar.gameObject.activeSelf;
if (flag2)
{
num -= 0.05f;
}
bool flag3 = !this._indureBar.gameObject.activeSelf;
if (flag3)
{
num -= 0.05f;
}
Vector3 position = this._entity.EngineObject.Position;
Vector3 position2;
position2= new Vector3(position.x, position.y + this._heroHeight + num, position.z);
this._billboard.position = position2;
this._billboard.rotation = XSingleton<XScene>.singleton.GameCamera.Rotaton;
bool flag4 = XSingleton<XEntityMgr>.singleton.Player != null;
if (flag4)
{
float num2 = 6.27f;
float num3 = Vector3.Distance(XSingleton<XScene>.singleton.GameCamera.UnityCamera.transform.position, this._billboard.position);
float num4 = XMobaBillboardComponent.k * num3 / num2;
this._billboard.localScale = new Vector3(num4, num4, num4);
}
bool isRole = this._entity.IsRole;
if (isRole)
{
int num5;
float fillAmount;
this._mobaDoc.GetRoleLevelAndExp(this._entity.ID, out num5, out fillAmount);
this._level.SetText(num5.ToString());
this._exp.SetFillAmount(fillAmount);
}
double attr = this._entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxHP_Total);
bool flag5 = this._bloodGrid.MAXHP != (int)attr;
if (flag5)
{
this._bloodGrid.SetMAXHP((int)attr);
}
double num6 = this._entity.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentHP_Basic);
bool flag6 = num6 < 0.0;
if (flag6)
{
num6 = 0.0;
}
this._bloodBar.value = (float)(num6 / attr);
bool activeInHierarchy = this._indureBar.gameObject.activeInHierarchy;
if (activeInHierarchy)
{
bool flag7 = this._secondbar_usage == BillboardUsage.MP;
if (flag7)
{
double attr2 = this._entity.Attributes.GetAttr(XAttributeDefine.XAttr_MaxMP_Total);
double attr3 = this._entity.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentMP_Basic);
bool flag8 = attr3 < attr2;
if (flag8)
{
this._indureBar.value = (float)(attr3 / attr2);
}
else
{
this._indureBar.value = 1f;
}
}
}
}
}
}
|