blob: 11d1d98e53579e515a226e0a748a43b1882176cb (
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
|
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient.UI
{
internal class XBuffIcon
{
private static float DISAPPEAR_START_LEFT_TIME = 3f;
private GameObject m_Go;
private IXUISprite m_uiIcon;
private IXUILabel m_uiLeftTime;
private IXUILabel m_uiCount;
private IXUITweenTool m_Tween;
private Vector3 m_OriginPos;
private float m_fLeftTime;
private int m_nLeftTime;
private float m_fStartTime;
private float m_fStartLeftTime;
private bool m_bActive = false;
private bool m_bPermernent = false;
private bool m_bShowTime = true;
private XBuffIcon.AnimState m_AnimState = XBuffIcon.AnimState.AS_NORMAL;
private enum AnimState
{
AS_NORMAL,
AS_DISAPPEARING
}
public void Init(GameObject go, bool bShowTime)
{
this.m_Go = go;
this.m_OriginPos = go.transform.localPosition;
this.m_uiIcon = (go.transform.Find("Icon").GetComponent("XUISprite") as IXUISprite);
this.m_uiLeftTime = (go.transform.Find("Time").GetComponent("XUILabel") as IXUILabel);
this.m_uiCount = (go.transform.Find("Count").GetComponent("XUILabel") as IXUILabel);
this.m_Tween = (go.GetComponent("XUIPlayTween") as IXUITweenTool);
this.m_bShowTime = bShowTime;
this.m_uiLeftTime.SetVisible(this.m_bShowTime);
this.Hide();
}
public void Set(UIBuffInfo buffInfo)
{
this.m_Go.transform.localPosition = this.m_OriginPos;
this.m_uiIcon.SetSprite(buffInfo.buffInfo.BuffIcon);
bool flag = buffInfo.stackCount <= 1u;
if (flag)
{
this.m_uiCount.SetText(string.Empty);
}
else
{
this.m_uiCount.SetText(XSingleton<XCommon>.singleton.StringCombine("[b]", buffInfo.stackCount.ToString()));
}
this.m_bPermernent = (buffInfo.buffInfo.BuffDuration < 0f);
XBuffIcon.AnimState animState = XBuffIcon.AnimState.AS_NORMAL;
bool flag2 = !this.m_bPermernent && buffInfo.leftTime <= XBuffIcon.DISAPPEAR_START_LEFT_TIME;
if (flag2)
{
animState = XBuffIcon.AnimState.AS_DISAPPEARING;
}
bool flag3 = animState != this.m_AnimState;
if (flag3)
{
this._ResetAnimState();
XBuffIcon.AnimState animState2 = animState;
if (animState2 == XBuffIcon.AnimState.AS_DISAPPEARING)
{
this._PlayStartDisappearAnim();
}
}
this.m_nLeftTime = 0;
this.m_fStartTime = buffInfo.startTime;
this.m_fStartLeftTime = buffInfo.leftTime;
this.m_fLeftTime = buffInfo.leftTime - (this._GetCurTime() - buffInfo.startTime);
this.m_bActive = true;
this._UpdateTime();
}
public void Hide()
{
this.m_Go.transform.localPosition = XGameUI.Far_Far_Away;
this._ResetAnimState();
this.m_bActive = false;
}
private float _GetCurTime()
{
bool syncMode = XSingleton<XGame>.singleton.SyncMode;
float result;
if (syncMode)
{
result = Time.realtimeSinceStartup;
}
else
{
result = Time.time;
}
return result;
}
private void _PlayStartDisappearAnim()
{
bool flag = this.m_Tween != null;
if (flag)
{
this.m_Tween.PlayTween(true, -1f);
this.m_AnimState = XBuffIcon.AnimState.AS_DISAPPEARING;
}
}
private void _ResetAnimState()
{
bool flag = this.m_AnimState == XBuffIcon.AnimState.AS_DISAPPEARING;
if (flag)
{
bool flag2 = this.m_Tween != null;
if (flag2)
{
this.m_Tween.ResetTween(true);
}
}
this.m_AnimState = XBuffIcon.AnimState.AS_NORMAL;
}
public void OnUpdate()
{
bool flag = !this.m_bActive;
if (!flag)
{
bool flag2 = !this.m_bPermernent && this.m_bShowTime;
if (flag2)
{
this.m_fLeftTime = this.m_fStartLeftTime - (this._GetCurTime() - this.m_fStartTime);
this._UpdateTime();
}
}
}
private void _UpdateTime()
{
bool bPermernent = this.m_bPermernent;
if (bPermernent)
{
this.m_uiLeftTime.SetText("");
this.m_uiLeftTime.Alpha = 1f;
}
else
{
int num = Mathf.CeilToInt(this.m_fLeftTime);
bool flag = num != this.m_nLeftTime;
if (flag)
{
this.m_nLeftTime = num;
bool flag2 = num <= 0 || (float)num > XSingleton<XGlobalConfig>.singleton.BuffMaxDisplayTime;
if (flag2)
{
this.m_uiLeftTime.Alpha = 0f;
}
else
{
this.m_uiLeftTime.SetText(XSingleton<XCommon>.singleton.StringCombine("[b]", num.ToString()));
this.m_uiLeftTime.Alpha = 1f;
}
}
}
}
}
}
|