blob: 679b3431bd2d1a2369f21b65be8cfb80bad0c0f8 (
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
|
using System;
using UILib;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient.UI.UICommon
{
internal class VirtualJoystick : DlgBase<VirtualJoystick, VirtualJoystickBehaviour>
{
public override string fileName
{
get
{
return "Common/VirtualJoyStick";
}
}
public override int layer
{
get
{
return 1;
}
}
public override bool autoload
{
get
{
return true;
}
}
private bool _bLogicalVisible;
protected override void Init()
{
this.Hide();
}
protected void Hide()
{
bool flag = !base.IsLoaded();
if (!flag)
{
base.uiBehaviour.m_Panel.gameObject.transform.localPosition = new Vector3((float)XGameUI._far_far_away, (float)XGameUI._far_far_away, 0f);
this._bLogicalVisible = false;
}
}
public void ShowPanel(bool bShow, Vector2 screenPos = default(Vector2))
{
Debug.Log("screenPos=" + screenPos);
if (bShow)
{
bool flag = !base.IsVisible();
if (flag)
{
this.SetVisible(true, true);
}
Vector3 vector = XSingleton<XGameUI>.singleton.UICamera.ScreenToWorldPoint(screenPos);
Vector3 vec = this.m_uiBehaviour.transform.InverseTransformPoint(vector);
Vector3 finalPos = /*this.LimitPosition(*/vec/*)*/;
Debug.Log("Virtual Joystick Pos = " + finalPos);
base.uiBehaviour.m_Panel.gameObject.transform.localPosition = finalPos;
bool flag2 = !this._bLogicalVisible;
if (flag2)
{
IXUITweenTool ixuitweenTool = base.uiBehaviour.m_Direction.GetComponent("XUIPlayTween") as IXUITweenTool;
ixuitweenTool.PlayTween(true, -1f);
}
this._bLogicalVisible = true;
}
else
{
this.Hide();
}
}
public void SetJoystickPos(float radius, float angle)
{
float num = this.GetPanelRadius() + this.GetJoystickRadius();
float num2 = (radius > num) ? num : radius;
float num3 = angle / 180f * 3.14159274f;
float num4 = Mathf.Cos(num3) * num2;
float num5 = -Mathf.Sin(num3) * num2;
base.uiBehaviour.m_Direction.gameObject.transform.localPosition = new Vector3(num4, num5, 0f);
}
public float GetPanelRadius()
{
bool flag = !this.m_bLoaded && this.autoload;
if (flag)
{
base.Load();
}
return (float)(base.uiBehaviour.m_Panel.spriteWidth / 2);
}
public float GetJoystickRadius()
{
bool flag = !this.m_bLoaded && this.autoload;
if (flag)
{
base.Load();
}
return (float)(base.uiBehaviour.m_Joystick.spriteWidth / 2 - 15);
}
protected Vector3 LimitPosition(Vector3 vec)
{
Vector3 result = vec;
int base_UI_Width = XSingleton<XGameUI>.singleton.Base_UI_Width;
int base_UI_Height = XSingleton<XGameUI>.singleton.Base_UI_Height;
float num = this.GetPanelRadius() + this.GetJoystickRadius() * 2f;
bool flag = vec.x - num < (float)(-(float)base_UI_Width / 2);
if (flag)
{
result.x = (float)(-(float)base_UI_Width / 2) + num;
}
bool flag2 = vec.x + num > (float)(base_UI_Width / 2);
if (flag2)
{
result.x = (float)(base_UI_Width / 2) - num;
}
bool flag3 = vec.y + num > (float)(base_UI_Height / 2);
if (flag3)
{
result.y = (float)(base_UI_Height / 2) - num;
}
bool flag4 = vec.y - num < (float)(-(float)base_UI_Height / 2);
if (flag4)
{
result.y = (float)(-(float)base_UI_Height / 2) + num;
}
return result;
}
}
}
|