-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCharacter.java
322 lines (267 loc) · 7.62 KB
/
Character.java
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
package ca.spiralmachines.limbscyberpunk;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.graphics.Paint;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.Random;
public class Character {
static final int MaxEquippedLimbs = 9;
static final int MaxSpareLimbs = 12;
private int absoluteIndexX;
private int absoluteIndexY;
private int dungeonId;
private ArrayList<Limb> equippedLimbs = new ArrayList<Limb>();
private Paint errorPaint;
private boolean freeRoam = true;
private int height;
private int id;
private Bitmap image;
private boolean isAlive = true;
private boolean isHostile = false;
private boolean isNpc = true;
private String name;
private boolean questCharacter = false;
private Random random;
private ArrayList<Limb> spareLimbs = new ArrayList<Limb>();
private int width;
public Character(int paramInt, String paramString, ArrayList<Limb> paramArrayList) {
this.name = paramString;
this.id = paramInt;
Paint paint = new Paint();
this.errorPaint = paint;
paint.setColor(-65281);
this.random = new Random();
assignLimbs(paramArrayList);
baseCoordinatesOnZero();
setWidthAndHeight();
setAvatarImage(300, 300);
}
private void assignLimbs(ArrayList<Limb> paramArrayList) {
for (Limb limb : paramArrayList) {
if (limb.isEquipped()) {
this.equippedLimbs.add(limb);
continue;
}
this.spareLimbs.add(limb);
}
}
static Bitmap getResizedBitmap(Bitmap paramBitmap, int paramInt1, int paramInt2) {
int j = paramBitmap.getWidth();
int i = paramBitmap.getHeight();
float f1 = paramInt1 / j;
float f2 = paramInt2 / i;
Matrix matrix = new Matrix();
matrix.postScale(f1, f2);
return Bitmap.createBitmap(paramBitmap, 0, 0, j, i, matrix, false);
}
public void baseCoordinatesOnZero() {
ArrayList<Limb> arrayList = this.equippedLimbs;
if (arrayList == null)
return;
if (arrayList.size() < 1)
return;
int j = 999999999;
int i = 999999999;
for (Limb limb : this.equippedLimbs) {
int k = j;
if (limb.getX() < j)
k = limb.getX();
int m = i;
if (limb.getY() < i)
m = limb.getY();
j = k;
i = m;
}
for (Limb limb : this.equippedLimbs) {
limb.setX(limb.getX() - j);
limb.setY(limb.getY() - i);
}
}
public int getAbsoluteIndexX() {
return this.absoluteIndexX;
}
public int getAbsoluteIndexY() {
return this.absoluteIndexY;
}
public ArrayList<Limb> getAllLimbs() {
ArrayList<Limb> arrayList = new ArrayList();
Iterator<Limb> iterator = this.equippedLimbs.iterator();
while (iterator.hasNext())
arrayList.add(iterator.next());
iterator = this.spareLimbs.iterator();
while (iterator.hasNext())
arrayList.add(iterator.next());
return arrayList;
}
public int getDamage() {
ArrayList<Limb> arrayList = this.equippedLimbs;
if (arrayList == null)
return 0;
if (arrayList.size() < 1)
return 0;
int i = 0;
Iterator<Limb> iterator = this.equippedLimbs.iterator();
while (iterator.hasNext())
i += ((Limb)iterator.next()).getDamage();
if (0.0F < 1.0F);
return (int)(((i / 3 + i) / this.equippedLimbs.size()) * (this.random.nextInt(4) + 19) / (this.random.nextInt(4) + 19));
}
public int getDungeonId() {
return this.dungeonId;
}
public ArrayList<Limb> getEquippedLimbs() {
return this.equippedLimbs;
}
public int getHeight() {
return this.height;
}
public int getId() {
return this.id;
}
public Bitmap getImage() {
if (this.image == null)
setAvatarImage(300, 300);
return this.image;
}
public int getIntelligence() {
ArrayList<Limb> arrayList = this.equippedLimbs;
if (arrayList == null)
return 0;
if (arrayList.size() < 1)
return 0;
float f1 = 0.0F;
Iterator<Limb> iterator = this.equippedLimbs.iterator();
while (iterator.hasNext())
f1 += ((Limb)iterator.next()).getIntelligence();
float f2 = f1;
if (f1 < 1.0F)
f2 = 1.0F;
return (int)((f2 / 3.0F + f2) / this.equippedLimbs.size() * (this.random.nextInt(4) + 19) / (this.random.nextInt(4) + 19));
}
public String getName() {
return this.name;
}
public ArrayList<Limb> getSpareLimbs() {
return this.spareLimbs;
}
public int getWidth() {
return this.width;
}
public boolean isAlive() {
return this.isAlive;
}
public boolean isFreeRoam() {
return this.freeRoam;
}
public boolean isHostile() {
return this.isHostile;
}
public boolean isNpc() {
return this.isNpc;
}
public boolean isQuestCharacter() {
return this.questCharacter;
}
public void setAlive(boolean paramBoolean) {
this.isAlive = paramBoolean;
}
public void setAvatarImage(int paramInt1, int paramInt2) {
setWidthAndHeight();
if (this.equippedLimbs.size() < 1) {
Bitmap bitmap1 = Bitmap.createBitmap(paramInt1, paramInt2, Bitmap.Config.ARGB_8888);
(new Canvas(bitmap1)).drawRect(0.0F, 0.0F, paramInt1, paramInt2, this.errorPaint);
this.image = bitmap1;
return;
}
int j = this.width;
int i = this.height;
if (j > i) {
i = j;
} else {
j = i;
}
Bitmap bitmap = Bitmap.createBitmap(j, i, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
for (Limb limb : this.equippedLimbs)
canvas.drawBitmap(limb.getImage(), limb.getX(), limb.getY(), null);
this.image = getResizedBitmap(bitmap, paramInt1, paramInt2);
}
public void setEquippedLimbs(ArrayList<Limb> paramArrayList) {
this.equippedLimbs = paramArrayList;
}
public void setFreeRoam(boolean paramBoolean) {
this.freeRoam = paramBoolean;
}
public void setHostile(boolean paramBoolean) {
this.isHostile = paramBoolean;
}
public void setImage(Bitmap paramBitmap) {
this.image = paramBitmap;
}
public void setLimbs(ArrayList<Limb> paramArrayList) {
assignLimbs(paramArrayList);
setWidthAndHeight();
}
public void setLocation(int paramInt1, int paramInt2, int paramInt3) {
this.dungeonId = paramInt1;
this.absoluteIndexX = paramInt2;
this.absoluteIndexY = paramInt3;
}
public void setName(String paramString) {
this.name = paramString;
}
public void setNpc(boolean paramBoolean) {
this.isNpc = paramBoolean;
}
public void setQuestCharacter(boolean paramBoolean) {
this.questCharacter = paramBoolean;
}
public void setSpareLimbs(ArrayList<Limb> paramArrayList) {
this.spareLimbs = paramArrayList;
}
public void setWidthAndHeight() {
ArrayList<Limb> arrayList = this.equippedLimbs;
if (arrayList == null) {
this.width = 1;
this.height = 1;
return;
}
if (arrayList.size() < 1) {
this.width = 1;
this.height = 1;
return;
}
int m = 999999999;
int k = 999999999;
int j = 0;
int i = 0;
for (Limb limb : this.equippedLimbs) {
int n = m;
if (limb.getX() < m)
n = limb.getX();
int i1 = k;
if (limb.getY() < k)
i1 = limb.getY();
int i2 = j;
if (limb.getX() > j)
i2 = limb.getX() + limb.getImage().getWidth();
int i3 = i;
if (limb.getY() > i)
i3 = limb.getY() + limb.getImage().getHeight();
m = n;
k = i1;
j = i2;
i = i3;
}
j -= m;
this.width = j;
i -= k;
this.height = i;
if (j < 1)
this.width = 1;
if (i < 1)
this.height = 1;
}
}