-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStats.cs
297 lines (259 loc) · 6.12 KB
/
Stats.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
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
using Game.Loggers;
using Game.Units.Effects;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Game.Units.Heroes
{
class Stats
{
public Stats(int[] p, int AS, int[] s, double[] i, Hero h)
{
damage = p[0];
def = p[1];
basicHealth = p[2];
baseAttackSpeed = AS;
baseSTR = s[0];
baseDEX = s[1];
baseINT = s[2];
strI = i[0];
dexI = i[1];
intI = i[2];
clas = s[3];
Prepare();
buffs = new Buffs(h);
}
public void Prepare()
{
currentHealth = MaxHealth;
sp = 0;
dead = false;
CalculateStats();
}
private void CalculateStats()
{
curSTR = baseSTR + (int)(strI * level);
curDEX = baseDEX + (int)(dexI * level);
curINT = baseINT + (int)(intI * level);
currentAttackSpeed = baseAttackSpeed;
}
//stats part
private int clas;
private int baseSTR;
private int baseDEX;
private int baseINT;
private double strI;
private double dexI;
private double intI;
private int curSTR;
private int curDEX;
private int curINT;
public int this[int i]
{
get
{
switch (i)
{
case 1: return curSTR;
case 2: return curDEX;
case 3: return curINT;
default: return 0;
}
}
}
public int Class
{
get
{
return clas;
}
}
//attack speed part
private int baseAttackSpeed;
private int currentAttackSpeed;
private long lastAttack = 0;
public int AttackSpeed
{
get
{
return currentAttackSpeed;
}
}
public bool AttackReady(long currentTime)
{
if (currentTime - currentAttackSpeed > lastAttack)
{
return true;
}
return false;
}
public void Attack(long currentTime)
{
lastAttack = currentTime;
}
//damage part
private int damage;
public int Damage
{
get
{
switch (clas)
{
case 1:
return damage + curSTR;
case 2:
return damage + curDEX * 2;
case 3:
return (int)(damage + curINT * 0.5);
default:
return damage;
}
}
}
//def part
private int def;
public int Def
{
get
{
return (int)(def + 0.1 * curDEX);
}
}
//magicdef part
private int magicDef;
public int MagicDef
{
get
{
return (int)(magicDef + 0.1 * curINT);
}
}
//health part
private long basicHealth;
private long currentHealth;
public long MaxHealth
{
get
{
return basicHealth + curSTR * 15 + 5 * level;
}
}
public long CurrentHealth
{
get
{
return currentHealth;
}
}
public double CurrentHealthPercent
{
get
{
return currentHealth / MaxHealth;
}
}
public void HealthAffect(long a)
{
currentHealth -= a;
if (currentHealth > MaxHealth)
{
currentHealth = MaxHealth;
}
else if (currentHealth <= 0)
{
currentHealth = 0;
dead = true;
}
}
//exp part
private int level = 0;
private long exp;
private long nextLevelExp;
public int Level
{
get
{
return level;
}
}
public long CurrentExp
{
get
{
return exp;
}
}
public void AddExp(long e)
{
exp += e;
if (exp >= nextLevelExp)
{
level += 1;
exp -= nextLevelExp;
nextLevelExp += 50 * level;
}
}
public void SetLevel(int level, long exp)
{
this.level = level;
this.exp = exp;
CalculateNextLevelExp();
}
private void CalculateNextLevelExp()
{
nextLevelExp = 50 + 25 * (level - 1)*level/2;
}
//dead part
private bool dead;
public bool isDead
{
get
{
return dead;
}
}
//sp part
private double sp;
public double SP
{
get
{
return sp;
}
}
public void AddSP(double d)
{
sp += d + (clas == 3 ? (((double)curINT) / 500) : 0);
}
public bool SpellReady
{
get
{
if (sp >= 1)
{
sp = 0;
return true;
}
else
{
return false;
}
}
}
//effects part
Buffs buffs;
public void AddEffect(Effect effect)
{
buffs.Add(effect);
}
public void Update(long currentTime)
{
for (int i = 0; i < buffs.Count; i++)
{
buffs[i].Update(currentTime);
}
}
}
}