1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Controls; |
---|
6 | using Jypeli.Effects; |
---|
7 | using Jypeli.Widgets; |
---|
8 | |
---|
9 | public class TToDHS : PhysicsGame |
---|
10 | { |
---|
11 | PhysicsObject stein; |
---|
12 | PhysicsObject taistoStein; |
---|
13 | //VAIHDA NIMI NAISESTA NIMEKSI |
---|
14 | PhysicsObject nainen; |
---|
15 | PhysicsObject taistoNainen; |
---|
16 | PhysicsObject mustaTakki; |
---|
17 | PhysicsObject taistoMustaTakki; |
---|
18 | PhysicsObject oviEteen; |
---|
19 | PhysicsObject oviTaakse; |
---|
20 | PhysicsObject inventory; |
---|
21 | double ruutuNelionSivu; |
---|
22 | |
---|
23 | Light valo; |
---|
24 | Timer valoAjastin = new Timer(); |
---|
25 | Vector steinLuontiPiste = new Vector(0, 0); |
---|
26 | |
---|
27 | IntMeter huoneLaskuri = new IntMeter(0); |
---|
28 | IntMeter potionLaskuri = new IntMeter(0); |
---|
29 | IntMeter steinHp = new IntMeter(20); |
---|
30 | IntMeter steinDmg = new IntMeter(6); |
---|
31 | IntMeter steinDef = new IntMeter(4); |
---|
32 | IntMeter steinLvl = new IntMeter(1); |
---|
33 | IntMeter steinExp = new IntMeter(0); |
---|
34 | IntMeter mustaTakkiHp = new IntMeter(10); |
---|
35 | IntMeter mustaTakkiDmg = new IntMeter(6); |
---|
36 | IntMeter mustaTakkiDef = new IntMeter(3); |
---|
37 | |
---|
38 | List<Label> alkuKohdat; |
---|
39 | List<Label> taistoKohdat; |
---|
40 | Label luetDocua; |
---|
41 | Label potionInInv; |
---|
42 | |
---|
43 | //TO DO: Nainen + MustaTakit, TutorialBattle + Stats + Party, Tarinaa ->, muut huoneet, itemit, battlet |
---|
44 | |
---|
45 | public override void Begin() |
---|
46 | { |
---|
47 | //IsFullScreen = true; |
---|
48 | ruutuNelionSivu = Screen.Height / 20; |
---|
49 | AlkuValikko(); |
---|
50 | |
---|
51 | Level.Background.Color = Color.Black; |
---|
52 | Level.AmbientLight = 0; |
---|
53 | |
---|
54 | valo = new Light(); |
---|
55 | valo.Intensity = 0; |
---|
56 | valo.Distance = 1000; |
---|
57 | Add(valo); |
---|
58 | |
---|
59 | PotionienLaskuri(); |
---|
60 | |
---|
61 | steinExp.MaxValue = 32; |
---|
62 | |
---|
63 | //Tee tälle oma aliohjelmansa, joka kutsutaan, kun stein voittaa taistelun! |
---|
64 | |
---|
65 | steinExp.UpperLimit += delegate { steinLvl.Value += 1; }; |
---|
66 | steinExp.UpperLimit += delegate { steinHp.Value += RandomGen.NextInt(1 - 5); }; |
---|
67 | steinExp.UpperLimit += delegate { steinDmg.Value += 1; }; |
---|
68 | steinExp.UpperLimit += delegate { steinDef.Value += 1; }; |
---|
69 | steinExp.UpperLimit += delegate { steinExp.MaxValue *= steinLvl.Value; }; |
---|
70 | steinExp.UpperLimit += delegate { steinExp.Reset(); }; |
---|
71 | } |
---|
72 | |
---|
73 | void AlkuValikko() |
---|
74 | { |
---|
75 | Mouse.IsCursorVisible = true; |
---|
76 | |
---|
77 | Label otsikko = new Label("The Tale of Dr Harvard Stein"); |
---|
78 | otsikko.Position = new Vector(0, 140); |
---|
79 | otsikko.Font = Font.DefaultLargeBold; |
---|
80 | otsikko.TextColor = Color.BrightGreen; |
---|
81 | Add(otsikko); |
---|
82 | |
---|
83 | alkuKohdat = new List<Label>(); |
---|
84 | |
---|
85 | Label alku1 = new Label("New Game"); |
---|
86 | alku1.Position = new Vector(0, 80); |
---|
87 | alku1.Font = Font.DefaultLarge; |
---|
88 | alkuKohdat.Add(alku1); |
---|
89 | |
---|
90 | Label alku2 = new Label("Exit"); |
---|
91 | alku2.Position = new Vector(0, 30); |
---|
92 | alku2.Font = Font.DefaultLarge; |
---|
93 | alkuKohdat.Add(alku2); |
---|
94 | |
---|
95 | |
---|
96 | foreach (Label alkuKohta in alkuKohdat) |
---|
97 | { |
---|
98 | Add(alkuKohta); |
---|
99 | } |
---|
100 | |
---|
101 | Mouse.ListenOn(alku1, MouseButton.Left, ButtonState.Pressed, HuoneenLaskuri, null, 2); |
---|
102 | Mouse.ListenOn(alku2, MouseButton.Left, ButtonState.Pressed, Exit, null); |
---|
103 | Mouse.ListenMovement(1.0, AlkuKohtaHiiri, null); |
---|
104 | } |
---|
105 | |
---|
106 | void AlkuKohtaHiiri(AnalogState hiiri) |
---|
107 | { |
---|
108 | foreach (Label alkuKohta in alkuKohdat) |
---|
109 | { |
---|
110 | if (Mouse.IsCursorOn(alkuKohta)) |
---|
111 | { |
---|
112 | alkuKohta.TextColor = Color.Red; |
---|
113 | } |
---|
114 | |
---|
115 | else |
---|
116 | { |
---|
117 | alkuKohta.TextColor = Color.Blue; |
---|
118 | } |
---|
119 | } |
---|
120 | } |
---|
121 | |
---|
122 | void HuoneenLaskuri(int x) |
---|
123 | { |
---|
124 | Mouse.IsCursorVisible = false; |
---|
125 | |
---|
126 | huoneLaskuri.MinValue = 0; |
---|
127 | huoneLaskuri.MaxValue = 10; |
---|
128 | |
---|
129 | if (huoneLaskuri.Value == 0) |
---|
130 | { |
---|
131 | if (x == 1) |
---|
132 | { |
---|
133 | steinLuontiPiste = new Vector(100, 100); |
---|
134 | } |
---|
135 | |
---|
136 | LuoHuone("Labrahuone"); |
---|
137 | } |
---|
138 | |
---|
139 | else if (huoneLaskuri.Value == 1) |
---|
140 | { |
---|
141 | if (x == 0) |
---|
142 | { |
---|
143 | steinLuontiPiste = new Vector(-200, 200); |
---|
144 | } |
---|
145 | |
---|
146 | else if (x == 1) |
---|
147 | { |
---|
148 | steinLuontiPiste = new Vector(200, -200); |
---|
149 | } |
---|
150 | |
---|
151 | LuoHuone("INSERT ROOM 2 HERE"); |
---|
152 | } |
---|
153 | } |
---|
154 | |
---|
155 | void LuoHuone(String tekstinNimi) |
---|
156 | { |
---|
157 | ClearGameObjects(); |
---|
158 | TileMap huone = TileMap.FromLevelAsset(tekstinNimi); |
---|
159 | huone.SetTileMethod('X', LuoSeina); |
---|
160 | huone.SetTileMethod('S', LuoStein); |
---|
161 | huone.SetTileMethod('D', LuoDoc); |
---|
162 | huone.SetTileMethod('V', LuoVitriini); |
---|
163 | huone.SetTileMethod('A', LuoPotionhuone1); |
---|
164 | huone.SetTileMethod('F', LuoOviEteen); |
---|
165 | huone.SetTileMethod('B', LuoOviTaakse); |
---|
166 | huone.Execute(ruutuNelionSivu, ruutuNelionSivu); |
---|
167 | |
---|
168 | HuoneenValo(0, 1); |
---|
169 | } |
---|
170 | |
---|
171 | void LuoSeina(Vector paikka, double leveys, double korkeus) |
---|
172 | { |
---|
173 | PhysicsObject seina = PhysicsObject.CreateStaticObject(leveys, korkeus); |
---|
174 | seina.Position = paikka; |
---|
175 | seina.Color = Color.Gray; |
---|
176 | seina.CollisionIgnoreGroup = 1; |
---|
177 | seina.Restitution = 0; |
---|
178 | AddCollisionHandler(seina, "stein", PalautaStein); |
---|
179 | Add(seina); |
---|
180 | } |
---|
181 | |
---|
182 | void LuoStein(Vector paikka, double leveys, double korkeus) |
---|
183 | { |
---|
184 | stein = new PhysicsObject(leveys * 0.8, korkeus * 0.8); |
---|
185 | stein.Position = steinLuontiPiste; |
---|
186 | stein.Color = Color.Green; |
---|
187 | stein.Restitution = 0; |
---|
188 | stein.CanRotate = false; |
---|
189 | stein.Tag = "stein"; |
---|
190 | Add(stein); |
---|
191 | |
---|
192 | Camera.Follow(stein); |
---|
193 | Camera.Zoom(0.75); |
---|
194 | |
---|
195 | Timer.SingleShot(1, delegate { SteinKontrollit(0); }); |
---|
196 | } |
---|
197 | |
---|
198 | void SteinKontrollit(int x) |
---|
199 | { |
---|
200 | if (x == 1) |
---|
201 | { |
---|
202 | luetDocua.Destroy(); |
---|
203 | } |
---|
204 | |
---|
205 | ClearControls(); |
---|
206 | |
---|
207 | //Jos muutat nopeutta, moni Timer.Singleshot menee väärään aikaan, mm. PalautaStein, SteinNopeus ja LuetDoc |
---|
208 | Keyboard.Listen(Key.D, ButtonState.Down, AsiaNopeus, null, stein, ruutuNelionSivu * 5, 0.0, 0.0); |
---|
209 | Keyboard.Listen(Key.A, ButtonState.Down, AsiaNopeus, null, stein, -ruutuNelionSivu * 5, 0.0, 0.0); |
---|
210 | Keyboard.Listen(Key.W, ButtonState.Down, AsiaNopeus, null, stein, 0.0, ruutuNelionSivu * 5, 0.0); |
---|
211 | Keyboard.Listen(Key.S, ButtonState.Down, AsiaNopeus, null, stein, 0.0, -ruutuNelionSivu * 5, 0.0); |
---|
212 | Keyboard.Listen(Key.E, ButtonState.Pressed, InventorinTilanMuutos, null, 0); |
---|
213 | } |
---|
214 | |
---|
215 | void AsiaNopeus(PhysicsObject liikkuja, double x, double y, double z) |
---|
216 | { |
---|
217 | liikkuja.Velocity = new Vector(x, y); |
---|
218 | |
---|
219 | if ((x + 1 ) * (y + 1) > 2) |
---|
220 | { |
---|
221 | ClearControls(); |
---|
222 | Timer.SingleShot(0.2, delegate { AsiaNopeus(liikkuja, 0, 0, 0); }); |
---|
223 | } |
---|
224 | |
---|
225 | else if ((x + 1) * (y + 1) < 1) |
---|
226 | { |
---|
227 | ClearControls(); |
---|
228 | Timer.SingleShot(0.2, delegate { AsiaNopeus(liikkuja, 0, 0, 0); }); |
---|
229 | } |
---|
230 | |
---|
231 | else if (z == 0) |
---|
232 | { |
---|
233 | SteinKontrollit(0); |
---|
234 | } |
---|
235 | } |
---|
236 | |
---|
237 | void PalautaStein(PhysicsObject wall, PhysicsObject dr) |
---|
238 | { |
---|
239 | dr.Velocity = dr.Velocity * -1; |
---|
240 | //Määritetty Steinin koosta ja nopeudesta |
---|
241 | Timer.SingleShot( 0.02, delegate { AsiaNopeus(dr, 0, 0, 1); }); |
---|
242 | } |
---|
243 | |
---|
244 | void LuoDoc(Vector paikka, double leveys, double korkeus) |
---|
245 | { |
---|
246 | PhysicsObject doc = PhysicsObject.CreateStaticObject(leveys, korkeus); |
---|
247 | doc.Position = paikka; |
---|
248 | doc.Color = Color.White; |
---|
249 | doc.CollisionIgnoreGroup = 1; |
---|
250 | doc.Restitution = 0; |
---|
251 | AddCollisionHandler(doc, "stein", PalautaStein); |
---|
252 | AddCollisionHandler(doc, "stein", LuetDoc); |
---|
253 | Add(doc); |
---|
254 | } |
---|
255 | |
---|
256 | void LuetDoc(PhysicsObject doku, PhysicsObject dr) |
---|
257 | { |
---|
258 | luetDocua = new Label("It's full of complicated calculations. Better leave it alone."); |
---|
259 | luetDocua.Y = Screen.Bottom + 100; |
---|
260 | luetDocua.Font = Font.DefaultLarge; |
---|
261 | luetDocua.TextColor = Color.Green; |
---|
262 | luetDocua.Color = Color.DarkGray; |
---|
263 | luetDocua.BorderColor = Color.Gray; |
---|
264 | Add(luetDocua); |
---|
265 | |
---|
266 | ClearControls(); |
---|
267 | Timer.SingleShot(0.042, delegate { ClearControls(); }); |
---|
268 | Timer.SingleShot(0.161, delegate { ClearControls(); }); |
---|
269 | |
---|
270 | Timer.SingleShot(1, delegate { Keyboard.Listen(Key.Space, ButtonState.Pressed, SteinKontrollit, null, 1); }); |
---|
271 | } |
---|
272 | |
---|
273 | void LuoVitriini(Vector paikka, double leveys, double korkeus) |
---|
274 | { |
---|
275 | PhysicsObject vitriini = PhysicsObject.CreateStaticObject(leveys * 3, korkeus); |
---|
276 | vitriini.Position = paikka; |
---|
277 | vitriini.CollisionIgnoreGroup = 1; |
---|
278 | vitriini.Restitution = 0; |
---|
279 | AddCollisionHandler(vitriini, "stein", PalautaStein); |
---|
280 | Add(vitriini); |
---|
281 | } |
---|
282 | |
---|
283 | void LuoPotionhuone1(Vector paikka, double leveys, double korkeus) |
---|
284 | { |
---|
285 | PhysicsObject potionhuone1 = PhysicsObject.CreateStaticObject(leveys, korkeus); |
---|
286 | potionhuone1.Position = paikka; |
---|
287 | potionhuone1.Color = Color.Red; |
---|
288 | potionhuone1.IgnoresCollisionResponse = true; |
---|
289 | AddCollisionHandler(potionhuone1, "stein", SaitPotioninHuoneessa1); |
---|
290 | Add(potionhuone1); |
---|
291 | } |
---|
292 | |
---|
293 | void SaitPotioninHuoneessa1(PhysicsObject esine, PhysicsObject dr) |
---|
294 | { |
---|
295 | esine.Destroy(); |
---|
296 | potionLaskuri.Value += 1; |
---|
297 | |
---|
298 | ClearControls(); |
---|
299 | Timer.SingleShot(0.201, delegate { ClearControls(); }); |
---|
300 | Timer.SingleShot(2, Cutscene1); |
---|
301 | } |
---|
302 | |
---|
303 | //Säädä CUTSCENE!!! |
---|
304 | |
---|
305 | void Cutscene1() |
---|
306 | { |
---|
307 | LuoNainen(new Vector(-ruutuNelionSivu * 12, -ruutuNelionSivu * 1), ruutuNelionSivu, ruutuNelionSivu); |
---|
308 | nainen.Velocity = new Vector(ruutuNelionSivu * 5, 0); |
---|
309 | Timer.SingleShot(1, delegate { AsiaNopeus(nainen, 0, 0, 1); |
---|
310 | nainen.Velocity = new Vector(0, -ruutuNelionSivu * 5); }); |
---|
311 | Timer.SingleShot(1.8, delegate { AsiaNopeus(nainen, 0, 0, 1); |
---|
312 | nainen.Velocity = new Vector(ruutuNelionSivu * 5, 0); }); |
---|
313 | Timer.SingleShot(3.2, delegate { AsiaNopeus(nainen, 0, 0, 1); }); |
---|
314 | |
---|
315 | Timer.SingleShot(0.4, delegate { LuoMustaTakki(new Vector(-ruutuNelionSivu * 12, -ruutuNelionSivu * 1), ruutuNelionSivu, ruutuNelionSivu); |
---|
316 | mustaTakki.Velocity = new Vector(ruutuNelionSivu * 5, 0); }); |
---|
317 | Timer.SingleShot(1.4, delegate { AsiaNopeus(mustaTakki, 0, 0, 1); |
---|
318 | mustaTakki.Velocity = new Vector(0, -ruutuNelionSivu * 5); }); |
---|
319 | Timer.SingleShot(2.4, delegate { AsiaNopeus(mustaTakki, 0, 0, 1); |
---|
320 | mustaTakki.Velocity = new Vector(ruutuNelionSivu * 5, 0); }); |
---|
321 | Timer.SingleShot(4, delegate { AsiaNopeus(mustaTakki, 0, 0, 1); |
---|
322 | mustaTakki.Velocity = new Vector(0, ruutuNelionSivu * 5); }); |
---|
323 | Timer.SingleShot(4.02, delegate { AsiaNopeus(mustaTakki, 0, 0, 1); }); |
---|
324 | } |
---|
325 | |
---|
326 | //Vaihda nimi Luo[NaisenNimi] |
---|
327 | //Muista parametrit! |
---|
328 | |
---|
329 | void LuoNainen(Vector paikka, double leveys, double korkeus) |
---|
330 | { |
---|
331 | nainen = new PhysicsObject(leveys, korkeus); |
---|
332 | nainen.Position = paikka; |
---|
333 | nainen.Color = Color.Red; |
---|
334 | nainen.Restitution = 0; |
---|
335 | nainen.CanRotate = false; |
---|
336 | Add(nainen); |
---|
337 | } |
---|
338 | |
---|
339 | //Muista parametrit! |
---|
340 | |
---|
341 | void LuoMustaTakki(Vector paikka, double leveys, double korkeus) |
---|
342 | { |
---|
343 | mustaTakki = new PhysicsObject(leveys, korkeus); |
---|
344 | mustaTakki.Position = paikka; |
---|
345 | mustaTakki.Color = Color.DarkGray; |
---|
346 | mustaTakki.Restitution = 0; |
---|
347 | mustaTakki.CanRotate = false; |
---|
348 | AddCollisionHandler(mustaTakki, "stein", AloitaTaistelu); |
---|
349 | AddCollisionHandler(mustaTakki, "stein", PalautaStein); |
---|
350 | Add(mustaTakki); |
---|
351 | } |
---|
352 | |
---|
353 | void LuoOviEteen(Vector paikka, double leveys, double korkeus) |
---|
354 | { |
---|
355 | oviEteen = PhysicsObject.CreateStaticObject(leveys, korkeus); |
---|
356 | oviEteen.Position = paikka; |
---|
357 | oviEteen.IgnoresCollisionResponse = true; |
---|
358 | AddCollisionHandler(oviEteen, "stein", SeuraavaHuone); |
---|
359 | Add(oviEteen); |
---|
360 | } |
---|
361 | |
---|
362 | void SeuraavaHuone(PhysicsObject door, PhysicsObject dr) |
---|
363 | { |
---|
364 | huoneLaskuri.Value = huoneLaskuri.Value + 1; |
---|
365 | HuoneenValo(0, 2); |
---|
366 | Timer.SingleShot(1.5, delegate { HuoneenLaskuri(0); }); |
---|
367 | } |
---|
368 | |
---|
369 | void LuoOviTaakse(Vector paikka, double leveys, double korkeus) |
---|
370 | { |
---|
371 | oviTaakse = PhysicsObject.CreateStaticObject(leveys, korkeus); |
---|
372 | oviTaakse.Position = paikka; |
---|
373 | oviTaakse.IgnoresCollisionResponse = true; |
---|
374 | AddCollisionHandler(oviTaakse, "stein", EdellinenHuone); |
---|
375 | Add(oviTaakse); |
---|
376 | } |
---|
377 | |
---|
378 | void EdellinenHuone(PhysicsObject door, PhysicsObject dr) |
---|
379 | { |
---|
380 | huoneLaskuri.Value = huoneLaskuri.Value - 1; |
---|
381 | HuoneenValo(0, 2); |
---|
382 | Timer.SingleShot(1.5, delegate { HuoneenLaskuri(1); }); |
---|
383 | } |
---|
384 | |
---|
385 | void HuoneenValo(int x, int y) |
---|
386 | { |
---|
387 | if (x == 1) |
---|
388 | { |
---|
389 | valo.Intensity += 0.067; |
---|
390 | } |
---|
391 | |
---|
392 | else if (x == 2) |
---|
393 | { |
---|
394 | valo.Intensity -= 0.067; |
---|
395 | } |
---|
396 | |
---|
397 | else if (x == 0) |
---|
398 | { |
---|
399 | valoAjastin.Interval = 0.05; |
---|
400 | valoAjastin.Timeout += delegate { HuoneenValo(y, 0); }; |
---|
401 | valoAjastin.Start(15); |
---|
402 | } |
---|
403 | } |
---|
404 | |
---|
405 | void PotionienLaskuri() |
---|
406 | { |
---|
407 | potionLaskuri.MinValue = 0; |
---|
408 | potionLaskuri.MaxValue = 10; |
---|
409 | } |
---|
410 | |
---|
411 | //Laita Label("Inventory") Inventoryn yläosaan! |
---|
412 | |
---|
413 | void InventorinTilanMuutos(int x) |
---|
414 | { |
---|
415 | if (x == 0) |
---|
416 | { |
---|
417 | ClearControls(); |
---|
418 | Keyboard.Listen(Key.E, ButtonState.Pressed, InventorinTilanMuutos, null, 1); |
---|
419 | |
---|
420 | inventory = PhysicsObject.CreateStaticObject(ruutuNelionSivu * 10, ruutuNelionSivu * 20); |
---|
421 | inventory.Color = Color.LightGray; |
---|
422 | inventory.IgnoresCollisionResponse = true; |
---|
423 | inventory.CollisionIgnoreGroup = 1; |
---|
424 | inventory.Position = new Vector(0, 0); |
---|
425 | Add(inventory); |
---|
426 | |
---|
427 | if (potionLaskuri.Value > 0) |
---|
428 | { |
---|
429 | potionInInv = new Label("Potion"); |
---|
430 | potionInInv.Position = new Vector(-inventory.Width / 4, inventory.Height / 7 * 2.3); |
---|
431 | potionInInv.Font = Font.DefaultLarge; |
---|
432 | potionInInv.TextColor = Color.Red; |
---|
433 | Add(potionInInv); |
---|
434 | } |
---|
435 | } |
---|
436 | |
---|
437 | else if (x == 1 && potionLaskuri.Value > 0) |
---|
438 | { |
---|
439 | inventory.Destroy(); |
---|
440 | potionInInv.Destroy(); |
---|
441 | SteinKontrollit(0); |
---|
442 | } |
---|
443 | |
---|
444 | else if (x== 1) |
---|
445 | { |
---|
446 | inventory.Destroy(); |
---|
447 | SteinKontrollit(0); |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | //Selvitä miksi valo ei vähene HuoneenValo(0,2); -komennolla |
---|
452 | |
---|
453 | void AloitaTaistelu(PhysicsObject vastus, PhysicsObject dr) |
---|
454 | { |
---|
455 | steinLuontiPiste = stein.Position; |
---|
456 | HuoneenValo(0, 2); |
---|
457 | |
---|
458 | Timer.SingleShot(0.75, delegate { ClearGameObjects(); |
---|
459 | //HuoneenValo(0, 1); |
---|
460 | TileMap taistelu = TileMap.FromLevelAsset("Taistelu"); |
---|
461 | taistelu.SetTileMethod('V', LuoTaistoon, 0); |
---|
462 | taistelu.SetTileMethod('S', LuoTaistoon, 1); |
---|
463 | taistelu.SetTileMethod('N', LuoTaistoon, 2); |
---|
464 | taistelu.Execute(ruutuNelionSivu, ruutuNelionSivu); }); |
---|
465 | Timer.SingleShot(1.5, delegate { LuoTaistoValikko(); }); |
---|
466 | } |
---|
467 | |
---|
468 | void LuoTaistoon(Vector paikka, double leveys, double korkeus, int x) |
---|
469 | { |
---|
470 | if (x == 0) |
---|
471 | { |
---|
472 | taistoMustaTakki = LuoTaistoOtus(paikka, leveys, korkeus, Color.DarkGray); |
---|
473 | } |
---|
474 | |
---|
475 | else if (x == 1) |
---|
476 | { |
---|
477 | taistoStein = LuoTaistoOtus(paikka, leveys, korkeus, Color.Green); |
---|
478 | } |
---|
479 | |
---|
480 | else if (x == 2) |
---|
481 | { |
---|
482 | taistoNainen = LuoTaistoOtus(paikka, leveys, korkeus, Color.Red); |
---|
483 | } |
---|
484 | } |
---|
485 | |
---|
486 | PhysicsObject LuoTaistoOtus(Vector paikka, double leveys, double korkeus, Color vari) |
---|
487 | { |
---|
488 | PhysicsObject taistelija = new PhysicsObject(leveys, korkeus); |
---|
489 | taistelija.Position = paikka; |
---|
490 | taistelija.Color = vari; |
---|
491 | Add(taistelija); |
---|
492 | return (taistelija); |
---|
493 | } |
---|
494 | |
---|
495 | void LuoTaistoValikko() |
---|
496 | { |
---|
497 | Mouse.IsCursorVisible = true; |
---|
498 | |
---|
499 | taistoKohdat = new List<Label>(); |
---|
500 | |
---|
501 | Label taisto1 = new Label("Attack"); |
---|
502 | taisto1.Position = new Vector(-160, -30); |
---|
503 | taisto1.Font = Font.DefaultLarge; |
---|
504 | taistoKohdat.Add(taisto1); |
---|
505 | |
---|
506 | Label taisto2 = new Label("Defend"); |
---|
507 | taisto2.Position = new Vector(-10, -30); |
---|
508 | taisto2.Font = Font.DefaultLarge; |
---|
509 | taistoKohdat.Add(taisto2); |
---|
510 | |
---|
511 | Label taisto3 = new Label("Inventory"); |
---|
512 | taisto3.Position = new Vector(140, -30); |
---|
513 | taisto3.Font = Font.DefaultLarge; |
---|
514 | taistoKohdat.Add(taisto3); |
---|
515 | |
---|
516 | foreach (Label taistoKohta in taistoKohdat) |
---|
517 | { |
---|
518 | Add(taistoKohta); |
---|
519 | } |
---|
520 | |
---|
521 | Mouse.ListenOn(taisto1, MouseButton.Left, ButtonState.Pressed, SteinAttack, null); |
---|
522 | Mouse.ListenOn(taisto2, MouseButton.Left, ButtonState.Pressed, SteinDefend, null); |
---|
523 | Mouse.ListenOn(taisto3, MouseButton.Left, ButtonState.Pressed, InventorinTilanMuutos, null, 0); |
---|
524 | Mouse.ListenMovement(1.0, TaistoKohtaHiiri, null); |
---|
525 | } |
---|
526 | |
---|
527 | void TaistoKohtaHiiri(AnalogState hiiri) |
---|
528 | { |
---|
529 | foreach (Label taistoKohta in taistoKohdat) |
---|
530 | { |
---|
531 | if (Mouse.IsCursorOn(taistoKohta)) |
---|
532 | { |
---|
533 | taistoKohta.TextColor = Color.Red; |
---|
534 | } |
---|
535 | |
---|
536 | else |
---|
537 | { |
---|
538 | taistoKohta.TextColor = Color.Blue; |
---|
539 | } |
---|
540 | } |
---|
541 | } |
---|
542 | |
---|
543 | void SteinAttack() |
---|
544 | { |
---|
545 | mustaTakkiHp.Value -= (steinDmg.Value -= mustaTakkiDef.Value); |
---|
546 | } |
---|
547 | |
---|
548 | void SteinDefend() |
---|
549 | { |
---|
550 | steinDef.Value += 1; |
---|
551 | } |
---|
552 | } |
---|