-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrow.cs
177 lines (159 loc) · 3.1 KB
/
Arrow.cs
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
public class Arrow
{
public int life;
public int ax;
public int ay;
public int axTo;
public int ayTo;
public int avx;
public int avy;
public int adx;
public int ady;
public Char charBelong;
public Arrowpaint arrp;
public static sbyte[] FRAME = new sbyte[25]
{
0, 1, 2, 1, 0, 1, 2, 1, 0, 1,
2, 1, 0, 1, 2, 1, 0, 1, 2, 1,
0, 1, 2, 1, 0
};
public static int[] ARROWINDEX = new int[18]
{
0, 15, 37, 52, 75, 105, 127, 142, 165, 195,
217, 232, 255, 285, 307, 322, 345, 370
};
public static int[] TRANSFORM = new int[16]
{
0, 0, 0, 7, 6, 6, 6, 2, 2, 3,
3, 4, 5, 5, 5, 1
};
public Arrow(Char charBelong, Arrowpaint arrp)
{
this.charBelong = charBelong;
this.arrp = arrp;
}
public void update()
{
if (charBelong.mobFocus == null && charBelong.charFocus == null)
{
endMe();
return;
}
if (charBelong.mobFocus != null)
{
axTo = charBelong.mobFocus.x;
ayTo = charBelong.mobFocus.y - charBelong.mobFocus.h / 4;
}
else if (charBelong.charFocus != null)
{
axTo = charBelong.charFocus.cx;
ayTo = charBelong.charFocus.cy - charBelong.charFocus.ch / 4;
}
int num = axTo - ax;
int num2 = ayTo - ay;
int num3 = 5;
int num4 = 4;
if (num + num2 < 60)
{
num4 = 3;
}
else if (num + num2 < 30)
{
num4 = 2;
}
if (ax != axTo)
{
if (num > 0 && num < num3)
{
ax = axTo;
}
else if (num < 0 && num > -num3)
{
ax = axTo;
}
else
{
avx = axTo - ax << 2;
adx += avx;
ax += adx >> num4;
adx &= 15;
}
}
if (ay != ayTo)
{
if (num2 > 0 && num2 < num3)
{
ay = ayTo;
}
else if (num2 < 0 && num2 > -num3)
{
ay = ayTo;
}
else
{
avy = ayTo - ay << 2;
ady += avy;
ay += ady >> num4;
ady &= 15;
}
}
int num5 = 0;
int num6 = 0;
int num7 = 0;
int num8 = 0;
if (charBelong.mobFocus != null)
{
num5 = axTo - charBelong.mobFocus.w / 4;
num7 = axTo + charBelong.mobFocus.w / 4;
num6 = ayTo - charBelong.mobFocus.h / 4;
num8 = ayTo + charBelong.mobFocus.h / 4;
}
else if (charBelong.charFocus != null)
{
num5 = axTo - charBelong.charFocus.cw / 4;
num7 = axTo + charBelong.charFocus.cw / 4;
num6 = ayTo - charBelong.charFocus.ch / 4;
num8 = ayTo + charBelong.charFocus.ch / 4;
}
if (life > 0)
{
life--;
}
if (life == 0 || (ax >= num5 && ax <= num7 && ay >= num6 && ay <= num8))
{
endMe();
}
}
private void endMe()
{
charBelong.arr = null;
ax = (ay = (axTo = (ayTo = (avx = (avy = (adx = (ady = 0)))))));
charBelong.setAttack();
if (charBelong.me)
{
charBelong.saveLoadPreviousSkill();
}
}
public void paint(mGraphics g)
{
int dx = axTo - ax;
int num = ayTo - ay;
int num2 = findDirIndexFromAngle(Res.angle(dx, -num));
SmallImage.drawSmallImage(g, arrp.imgId[FRAME[num2]], ax, ay, TRANSFORM[num2], mGraphics.VCENTER | mGraphics.HCENTER);
}
public static int findDirIndexFromAngle(int angle)
{
for (int i = 0; i < ARROWINDEX.Length - 1; i++)
{
if (angle >= ARROWINDEX[i] && angle <= ARROWINDEX[i + 1])
{
if (i >= 16)
{
return 0;
}
return i;
}
}
return 0;
}
}