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
|
using System;
using UILib;
using UnityEngine;
using XMainClient.UI.UICommon;
using XUpdater;
using XUtliPoolLib;
namespace XMainClient
{
internal class BroadMiniDlg : DlgBase<BroadMiniDlg, BroadcastMiniBehaviour>
{
public override string fileName
{
get
{
return "GameSystem/BroadcastMiniDlg";
}
}
public override bool autoload
{
get
{
return true;
}
}
public override bool isMainUI
{
get
{
return true;
}
}
public override bool isHideChat
{
get
{
return false;
}
}
private const int width = 1136;
private const int height = 640;
private bool isPressing = false;
private bool checkPos = false;
private Vector3 from = Vector3.zero;
private Vector3 target = new Vector3(-533f, -180f, 0f);
private float tagTime = 0f;
public bool isBroadcast = false;
public Camera uiCamera;
protected override void Init()
{
base.Init();
base.uiBehaviour.m_btn.gameObject.transform.localPosition = this.target;
this.uiCamera = XSingleton<UIManager>.singleton.UIRoot.Find("Camera").GetComponent<Camera>();
}
public override void RegisterEvent()
{
base.RegisterEvent();
base.uiBehaviour.m_btn.RegisterDragEventHandler(new ButtonDragEventHandler(this.OnButtonDrag));
base.uiBehaviour.m_btn.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnPressHandler));
base.uiBehaviour.m_btn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnIconClick));
}
protected override void OnShow()
{
base.OnShow();
this.isPressing = false;
}
protected override void OnHide()
{
base.OnHide();
this.isPressing = false;
}
public override void OnUpdate()
{
base.OnUpdate();
bool flag = !this.isPressing && this.checkPos;
if (flag)
{
bool flag2 = Vector3.Distance(this.from, this.target) < 1f;
if (flag2)
{
base.uiBehaviour.m_btn.gameObject.transform.localPosition = this.target;
this.checkPos = false;
}
else
{
base.uiBehaviour.m_btn.gameObject.transform.localPosition = Vector3.Lerp(this.from, this.target, (Time.time - this.tagTime) / 0.2f);
}
}
}
public void Show(bool show)
{
this.SetVisible(false, true);
}
private void OnButtonDrag(IXUIButton btn, Vector2 delta)
{
bool flag = this.isPressing;
if (flag)
{
Vector3 mousePosition = Input.mousePosition;
bool flag2 = this.uiCamera != null;
if (flag2)
{
mousePosition.x = Mathf.Clamp01(mousePosition.x / (float)Screen.width);
mousePosition.y = Mathf.Clamp01(mousePosition.y / (float)Screen.height);
base.uiBehaviour.m_btn.gameObject.transform.position = this.uiCamera.ViewportToWorldPoint(mousePosition);
bool orthographic = this.uiCamera.orthographic;
if (orthographic)
{
Vector3 localPosition = base.uiBehaviour.m_btn.gameObject.transform.localPosition;
localPosition.x = Mathf.Round(localPosition.x);
localPosition.y = Mathf.Round(localPosition.y);
base.uiBehaviour.m_btn.gameObject.transform.localPosition = localPosition;
}
}
else
{
mousePosition.x -= (float)Screen.width * 0.5f;
mousePosition.y -= (float)Screen.height * 0.5f;
mousePosition.x = Mathf.Round(mousePosition.x);
mousePosition.y = Mathf.Round(mousePosition.y);
base.uiBehaviour.m_btn.gameObject.transform.localPosition = mousePosition;
}
}
}
private void OnPressHandler(IXUIButton btn, bool press)
{
bool flag = !press;
if (flag)
{
this.AttachBounds();
}
this.isPressing = press;
}
private bool OnIconClick(IXUIButton btn)
{
DlgBase<BroadcastDlg, BroadcastBehaviour>.singleton.SetVisible(true, true);
DlgBase<BroadcastDlg, BroadcastBehaviour>.singleton.ShowList();
this.SetVisible(false, true);
return true;
}
private void AttachBounds()
{
Vector3 localPosition = base.uiBehaviour.m_btn.gameObject.transform.localPosition;
float x = localPosition.x;
float y = localPosition.y;
float num = x + 568f;
float num2 = 568f - x;
float num3 = 320f - y;
float num4 = y + 320f;
float num5 = Mathf.Min(new float[]
{
num,
num2,
num3,
num4
});
bool flag = num == num5;
if (flag)
{
this.target = new Vector3(-533f, y, 0f);
}
else
{
bool flag2 = num2 == num5;
if (flag2)
{
this.target = new Vector3(533f, y, 0f);
}
else
{
bool flag3 = num3 == num5;
if (flag3)
{
this.target = new Vector3(x, 288f, 0f);
}
else
{
this.target = new Vector3(x, -288f, 0f);
}
}
}
this.tagTime = Time.time;
this.from = base.uiBehaviour.m_btn.gameObject.transform.localPosition;
this.checkPos = true;
}
public Vector3 GetIconPos()
{
return base.uiBehaviour.m_btn.gameObject.transform.localPosition;
}
public void StopBroad()
{
bool flag = this.isBroadcast;
if (flag)
{
try
{
XSingleton<XUpdater.XUpdater>.singleton.XBroadCast.StopBroadcast();
}
catch
{
}
}
}
}
}
|