Assets/Scripts/Utility/Stats.cs (view raw)
1using System.Collections;
2using System.Collections.Generic;
3using UnityEngine;
4
5[System.Serializable]
6public class Stats
7{
8 #region Private
9 private string name;
10
11 private double hp;
12 private double mp;
13 private double atk;
14 private double def;
15 private double agl;
16 private double lck;
17
18 private double maxHP;
19 private double maxMP;
20 private double maxATK;
21 private double maxDEF;
22 private double maxAGL;
23 private double maxLCK;
24
25 private List<Ability> abilities;
26 #endregion
27
28 #region Constructors
29 public Stats(string name, double HP, double MP, double ATK, double DEF, double AGL, double LCK, List<Ability> abilities)
30 {
31 this.name = name;
32 hp = maxHP = HP;
33 mp = maxMP = MP;
34 atk = maxATK = ATK;
35 def = maxDEF = DEF;
36 agl = maxAGL = AGL;
37 lck = maxLCK = LCK;
38
39 this.abilities = new List<Ability>(abilities);
40 }
41
42 public Stats(Stats s) //copy stats
43 {
44 name = s.name;
45
46 maxHP = s.MaxHP;
47 maxMP = s.MaxMP;
48 maxATK = s.MaxATK;
49 maxDEF = s.MaxDEF;
50 maxAGL = s.MaxAGL;
51 maxLCK = s.MaxLCK;
52
53 hp = s.HP;
54 mp = s.MP;
55 atk = s.ATK;
56 def = s.DEF;
57 agl = s.AGL;
58 lck = s.LCK;
59
60 abilities = new List<Ability>(s.abilities);
61 }
62 #endregion
63
64 #region Stats DB
65 public Stats(string key)
66 {
67 name = key;
68 abilities = new List<Ability>();
69 abilities.Add(new Attack());
70 switch (key)
71 {
72 case "Paladin":
73 hp = maxHP = 500;
74 mp = maxMP = 0;
75 atk = maxATK = 50;
76 def = maxDEF = 63;
77 agl = maxAGL = 30;
78 lck = maxLCK = 15;
79 abilities.Add(new Defend());
80 break;
81 case "Archer":
82 hp = maxHP = 400;
83 mp = maxMP = 400;
84 atk = maxATK = 40;
85 def = maxDEF = 50;
86 agl = maxAGL = 35;
87 lck = maxLCK = 40;
88 abilities.Add(new Defend());
89 abilities.Add(new Heal());
90 abilities.Add(new ReviveHalf());
91 break;
92 case "Boxer":
93 hp = maxHP = 600;
94 mp = maxMP = 0;
95 atk = maxATK = 30;
96 def = maxDEF = 80;
97 agl = maxAGL = 28;
98 lck = maxLCK = 25;
99 abilities.Add(new Defend());
100 break;
101 case "Mage":
102 hp = maxHP = 375;
103 mp = maxMP = 600;
104 atk = maxATK = 30;
105 def = maxDEF = 50;
106 agl = maxAGL = 32;
107 lck = maxLCK = 5;
108 abilities.Add(new HealBig());
109 abilities.Add(new FireBall());
110 abilities.Add(new ReviveFull());
111 break;
112 case "Orc":
113 hp = maxHP = 300;
114 mp = maxMP = 0;
115 atk = maxATK = 40;
116 def = maxDEF = 55;
117 agl = maxAGL = 25;
118 lck = maxLCK = 15;
119 break;
120 case "Mutant":
121 hp = maxHP = 500;
122 mp = maxMP = 0;
123 atk = maxATK = 43;
124 def = maxDEF = 60;
125 agl = maxAGL = 27;
126 lck = maxLCK = 20;
127 break;
128 case "Brady":
129 hp = maxHP = 1000;
130 mp = maxMP = 500;
131 atk = maxATK = 50;
132 def = maxDEF = 60;
133 agl = maxAGL = 30;
134 lck = maxLCK = 35;
135 abilities.Add(new FireBall());
136 abilities.Add(new HealBig());
137 break;
138 case "Ganfaul":
139 hp = maxHP = 2000;
140 mp = maxMP = 700;
141 atk = maxATK = 55;
142 def = maxDEF = 60;
143 agl = maxAGL = 32;
144 lck = maxLCK = 30;
145 abilities.Add(new FireBall());
146 abilities.Add(new HealBig());
147 break;
148 default:
149
150 break;
151 }
152 }
153 #endregion
154
155 #region Getters and Setters
156 public string Name { get => name; protected set => name = value; }
157
158 public double HP
159 {
160 get
161 {
162 return hp;
163 }
164 set
165 {
166 if (value > MaxHP)
167 {
168 hp = MaxHP;
169 }
170 else
171 if(value < 0)
172 {
173 hp = 0;
174 }
175 else
176 {
177 hp = value;
178 }
179 }
180 }
181 public double MP
182 {
183 get
184
185 {
186 return mp;
187 }
188 set
189 {
190 if (value > MaxMP)
191 {
192 mp = MaxMP;
193 }
194 else
195 if (value < 0)
196 {
197 mp = 0;
198 }
199 else
200 {
201 mp = value;
202 }
203 }
204 }
205 public double ATK
206 {
207 get
208 {
209 return atk;
210 }
211 set
212 {
213 if (value < 1)
214 {
215 atk = 1;
216 } else
217 {
218 atk = value;
219 }
220 }
221 }
222 public double DEF
223 {
224 get
225 {
226 return def;
227 }
228 set
229 {
230 if (value < 1)
231 {
232 def = 1;
233 }
234 else
235 {
236 def = value;
237 }
238 }
239 }
240 public double AGL
241 {
242 get
243 {
244 return agl;
245 }
246 set
247 {
248 if (value < 1)
249 {
250 agl = 1;
251 }
252 else
253 {
254 agl = value;
255 }
256 }
257 }
258 public double LCK
259 {
260 get
261 {
262 return lck;
263 }
264 set
265 {
266 if (value < 1)
267 {
268 lck = 1;
269 }
270 else
271 {
272 lck = value;
273 }
274 }
275 }
276
277 public double MaxHP { get => maxHP; protected set => maxHP = value; }
278 public double MaxMP { get => maxMP; protected set => maxMP = value; }
279 public double MaxATK { get => maxATK; protected set => maxATK = value; }
280 public double MaxDEF { get => maxDEF; protected set => maxDEF = value; }
281 public double MaxAGL { get => maxAGL; protected set => maxAGL = value; }
282 public double MaxLCK { get => maxLCK; protected set => maxLCK = value; }
283
284 public List<Ability> GetAbilities()
285 {
286 return new List<Ability>(abilities);
287 }
288 #endregion
289
290
291 public override string ToString()
292 {
293 return "HP: " + (int)hp + "/" + (int)maxHP + "\n" +
294 "MP: " + (int)mp + "/" + (int)maxMP + "\n" +
295 "ATK: " + (int)atk + "\n" +
296 "DEF: " + (int)def + "\n" +
297 "AGL: " + (int)agl + "\n" +
298 "LCK: " + (int)lck;
299 }
300}