1 | using System; |
---|
2 | |
---|
3 | using Jypeli; |
---|
4 | using Jypeli.Widgets; |
---|
5 | using Jypeli.Assets; |
---|
6 | using Jypeli.Controls; |
---|
7 | |
---|
8 | public class Pelaaja : PlatformCharacter |
---|
9 | { |
---|
10 | public bool voikoPoimiaAseen { get; set; } |
---|
11 | public Pelaaja(double width, double height, Shape shape) |
---|
12 | : base(width, height, shape) |
---|
13 | { |
---|
14 | voikoPoimiaAseen = true; |
---|
15 | } |
---|
16 | } |
---|
17 | |
---|
18 | // Yksinkertainen tasohyppely. |
---|
19 | public class Kynari : PhysicsGame |
---|
20 | { |
---|
21 | #region Muuttujat |
---|
22 | |
---|
23 | const double liikeVoima = 400; |
---|
24 | const double hyppyVoima = 800; |
---|
25 | |
---|
26 | Pelaaja pelaaja1; |
---|
27 | Pelaaja pelaaja2; |
---|
28 | DoubleMeter HitPoint1 = new DoubleMeter(100); |
---|
29 | DoubleMeter HitPoint2 = new DoubleMeter(100); |
---|
30 | |
---|
31 | Image kranaatinheittimenkuva = LoadImage("grenade"); |
---|
32 | Image magnumkuva = LoadImage("magnum"); |
---|
33 | Image norsu = LoadImage("norsu"); |
---|
34 | Image haulikonkuva = LoadImage("shotgun"); |
---|
35 | Image pistoolinkuva = LoadImage("pistol"); |
---|
36 | Image kivaarinkuva = LoadImage("assaultrifle"); |
---|
37 | bool saaAmpua = false; |
---|
38 | //bool peliohi = false; |
---|
39 | |
---|
40 | SoundEffect hyppyAani = LoadSoundEffect("hyppays"); |
---|
41 | |
---|
42 | ProgressBar hpNaytto; |
---|
43 | ProgressBar hpNaytto2; |
---|
44 | |
---|
45 | IntMeter pelaajan1Pisteet; |
---|
46 | IntMeter pelaajan2Pisteet; |
---|
47 | |
---|
48 | #endregion |
---|
49 | |
---|
50 | #region Alustukset |
---|
51 | public override void Begin() |
---|
52 | { |
---|
53 | pelaajan1Pisteet = new IntMeter(0); |
---|
54 | pelaajan2Pisteet = new IntMeter(0); |
---|
55 | |
---|
56 | |
---|
57 | DrawPerimeter = false; // ei haluta piirtää kentän reunoja |
---|
58 | |
---|
59 | // Asetetaan painovoima |
---|
60 | |
---|
61 | // Zoomataan lähemmäksi |
---|
62 | //Camera.ZoomFactor = 0.73; |
---|
63 | LuoAlkuValikko(); |
---|
64 | //aloitaUusiPeli(); |
---|
65 | } |
---|
66 | |
---|
67 | void aloitaUusiPeli() |
---|
68 | { |
---|
69 | |
---|
70 | MessageDisplay.Clear(); |
---|
71 | // ladataan kenttä |
---|
72 | seuraavaKentta(); |
---|
73 | LisaaLaskurit(); |
---|
74 | naytaTiedot(); |
---|
75 | //peliohi = false; |
---|
76 | saaAmpua = false; |
---|
77 | Timer.SingleShot(0.1, delegate |
---|
78 | { |
---|
79 | saaAmpua = true; |
---|
80 | }); |
---|
81 | } |
---|
82 | #endregion |
---|
83 | |
---|
84 | |
---|
85 | #region KentanLataus |
---|
86 | void seuraavaKentta() |
---|
87 | { |
---|
88 | ClearAll(); |
---|
89 | luoKentta(); |
---|
90 | lisaaNappaimet(); |
---|
91 | Camera.Position = new Vector(0, 0); |
---|
92 | } |
---|
93 | |
---|
94 | Level luoKentta() |
---|
95 | { |
---|
96 | Level.Width = 4000; |
---|
97 | Level.Height = 1000; |
---|
98 | Level.CreateBorders(); |
---|
99 | Level.Background.CreateGradient(Color.White, Color.Gray); |
---|
100 | Gravity = new Vector(0, -1500); |
---|
101 | luoTasot(); |
---|
102 | lisaaPelaajat(); |
---|
103 | lisaaAsePelaajalle(); |
---|
104 | lisaaKerattavaAse(); |
---|
105 | lisaaHPNaytot(); |
---|
106 | |
---|
107 | Timer timer = new Timer(); |
---|
108 | timer.Interval = 0.1; |
---|
109 | timer.Timeout += delegate { TarkistaReunat(300, 1000); }; |
---|
110 | timer.Start(); |
---|
111 | |
---|
112 | return Level; |
---|
113 | } |
---|
114 | |
---|
115 | void TarkistaReunat(double leveys, double korkeus) |
---|
116 | { |
---|
117 | if (pelaaja1.Position.X < -leveys) |
---|
118 | { |
---|
119 | pelaaja1.Position = new Vector(-leveys, pelaaja1.Position.Y); |
---|
120 | } |
---|
121 | if (pelaaja1.Position.X > leveys) |
---|
122 | { |
---|
123 | pelaaja1.Position = new Vector(leveys, pelaaja1.Position.Y); |
---|
124 | } |
---|
125 | if (pelaaja1.Position.Y < -korkeus) |
---|
126 | { |
---|
127 | pelaaja1.Position = new Vector(pelaaja1.Position.X, -korkeus); |
---|
128 | } |
---|
129 | if (pelaaja1.Position.Y > korkeus) |
---|
130 | { |
---|
131 | pelaaja1.Position = new Vector(pelaaja1.Position.Y, korkeus); |
---|
132 | } |
---|
133 | } |
---|
134 | |
---|
135 | void LuoAlkuValikko() |
---|
136 | { |
---|
137 | ClearAll(); |
---|
138 | NollaaLaskurit(); |
---|
139 | MultiSelectWindow alkuValikko = new MultiSelectWindow("Kynäri", |
---|
140 | "Aloita peli", "Lopeta"); |
---|
141 | Add(alkuValikko); |
---|
142 | alkuValikko.AddItemHandler(0, aloitaUusiPeli); |
---|
143 | alkuValikko.AddItemHandler(1, Exit); |
---|
144 | alkuValikko.DefaultCancel = 1; |
---|
145 | alkuValikko.Color = Color.Gray; |
---|
146 | Level.BackgroundColor = Color.Gray; |
---|
147 | } |
---|
148 | |
---|
149 | void luoTasot() |
---|
150 | { |
---|
151 | PhysicsObject alusta = new PhysicsObject(Level.Width, 300); |
---|
152 | alusta.Color = Color.Gray; |
---|
153 | alusta.X = 0; |
---|
154 | alusta.Y = Level.Bottom - alusta.Height / 2; |
---|
155 | Add(alusta); |
---|
156 | |
---|
157 | lisaaPieniTaso(-200, -350); |
---|
158 | lisaaPieniTaso(0, -400); |
---|
159 | lisaaPieniTaso(100, -300); |
---|
160 | lisaaPieniTaso(400, -350); |
---|
161 | lisaaPieniTaso(450, -200); |
---|
162 | lisaaPieniTaso(-500, -400); |
---|
163 | lisaaPieniTaso(-550, -200); |
---|
164 | lisaaPieniTaso(-400, -300); |
---|
165 | lisaaPieniTaso(-150, -150); |
---|
166 | lisaaPieniTaso(-870, -350); |
---|
167 | lisaaPieniTaso(-700, -400); |
---|
168 | |
---|
169 | lisaaPieniTaso(600, -300); |
---|
170 | lisaaPieniTaso(850, -300); |
---|
171 | lisaaPieniTaso(750, -400); |
---|
172 | lisaaPieniTaso(200, -200); |
---|
173 | lisaaPieniTaso(-200, -150); |
---|
174 | |
---|
175 | lisaaPystyTaso(600, -450); |
---|
176 | lisaaPystyTaso(-600, -500); |
---|
177 | lisaaPystyTaso(0, -450); |
---|
178 | |
---|
179 | lisaaReuna(-1375, 0); |
---|
180 | lisaaReuna(1375, 0); |
---|
181 | } |
---|
182 | |
---|
183 | void lisaaHPNaytot() |
---|
184 | { |
---|
185 | // luodaan elämänäyttö |
---|
186 | hpNaytto = new ProgressBar(250, 30); |
---|
187 | //hpNaytto.Angle = Angle.FromDegrees(90); |
---|
188 | hpNaytto.BarColor = Color.LightGreen; |
---|
189 | hpNaytto.Color = Color.Red; |
---|
190 | hpNaytto.BindTo(HitPoint1); |
---|
191 | hpNaytto.Position = new Vector(Screen.LeftSafe + 300, Screen.TopSafe - 170); |
---|
192 | Add(hpNaytto); |
---|
193 | |
---|
194 | hpNaytto2 = new ProgressBar(250, 30); |
---|
195 | //hpNaytto2.Angle = Angle.FromDegrees(90); |
---|
196 | hpNaytto2.BarColor = Color.LightGreen; |
---|
197 | hpNaytto2.Color = Color.Red; |
---|
198 | hpNaytto2.BindTo(HitPoint2); |
---|
199 | hpNaytto2.Position = new Vector(Screen.RightSafe - 300, Screen.TopSafe - 170); |
---|
200 | Add(hpNaytto2); |
---|
201 | } |
---|
202 | |
---|
203 | void LisaaLaskurit() |
---|
204 | { |
---|
205 | LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 175.0, pelaajan1Pisteet); |
---|
206 | LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 175.0, pelaajan2Pisteet); |
---|
207 | pelaajan1Pisteet.MaxValue = 3; |
---|
208 | pelaajan2Pisteet.MaxValue = 3; |
---|
209 | //pelaajan1Pisteet.UpperLimit += (laskuri1_UpperLimit); |
---|
210 | //pelaajan2Pisteet.UpperLimit += (laskuri2_UpperLimit); |
---|
211 | } |
---|
212 | |
---|
213 | void NollaaLaskurit() |
---|
214 | { |
---|
215 | pelaajan1Pisteet.Reset(); |
---|
216 | pelaajan2Pisteet.Reset(); |
---|
217 | } |
---|
218 | |
---|
219 | IntMeter LuoPisteLaskuri(double x, double y, IntMeter laskuri) |
---|
220 | { |
---|
221 | //IntMeter laskuri = new IntMeter(0); |
---|
222 | Label naytto = new Label(); |
---|
223 | naytto.BindTo(laskuri); |
---|
224 | naytto.X = x; |
---|
225 | naytto.Y = y; |
---|
226 | Add(naytto); |
---|
227 | return laskuri; |
---|
228 | } |
---|
229 | |
---|
230 | void Pelaaja1Voitti() |
---|
231 | { |
---|
232 | /* |
---|
233 | if (peliohi) { |
---|
234 | return; |
---|
235 | } |
---|
236 | peliohi = true; |
---|
237 | */ |
---|
238 | MessageDisplay.Clear(); |
---|
239 | if (pelaaja1.IsDestroying && pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue) |
---|
240 | { |
---|
241 | MessageDisplay.Add("Tasapeli!"); |
---|
242 | } |
---|
243 | else |
---|
244 | { |
---|
245 | MessageDisplay.Add("Pelaaja 1 voittaa!"); |
---|
246 | } |
---|
247 | MessageDisplay.X = 0; |
---|
248 | } |
---|
249 | |
---|
250 | void Pelaaja2Voitti() |
---|
251 | { |
---|
252 | /* |
---|
253 | if (peliohi) |
---|
254 | { |
---|
255 | return; |
---|
256 | } |
---|
257 | peliohi = true; |
---|
258 | */ |
---|
259 | MessageDisplay.Clear(); |
---|
260 | if (pelaaja2.IsDestroying && pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue) |
---|
261 | { |
---|
262 | MessageDisplay.Add("Tasapeli!"); |
---|
263 | } |
---|
264 | else |
---|
265 | { |
---|
266 | MessageDisplay.Add("Pelaaja 2 voittaa!"); |
---|
267 | } |
---|
268 | MessageDisplay.X = 0; |
---|
269 | |
---|
270 | } |
---|
271 | |
---|
272 | void lisaaPieniTaso(double x, double y) |
---|
273 | { |
---|
274 | PhysicsObject taso = PhysicsObject.CreateStaticObject(100, 30, Shape.Rectangle); |
---|
275 | taso.Color = Color.Gray; |
---|
276 | taso.X = x; |
---|
277 | taso.Y = y; |
---|
278 | Add(taso); |
---|
279 | } |
---|
280 | |
---|
281 | void lisaaReuna(double x, double y) |
---|
282 | { |
---|
283 | PhysicsObject taso = PhysicsObject.CreateStaticObject(1000, 1000, Shape.Rectangle); |
---|
284 | taso.Color = Color.Gray; |
---|
285 | taso.X = x; |
---|
286 | taso.Y = y; |
---|
287 | Add(taso); |
---|
288 | } |
---|
289 | |
---|
290 | void lisaaPystyTaso(double x, double y) |
---|
291 | { |
---|
292 | PhysicsObject taso = PhysicsObject.CreateStaticObject(30, 100, Shape.Rectangle); |
---|
293 | taso.Color = Color.Gray; |
---|
294 | taso.X = x; |
---|
295 | taso.Y = y; |
---|
296 | Add(taso); |
---|
297 | } |
---|
298 | |
---|
299 | void lisaaPelaajat() |
---|
300 | { |
---|
301 | pelaaja1 = new Pelaaja(40, 40, Shape.Circle); |
---|
302 | pelaaja1.Image = norsu; |
---|
303 | pelaaja1.X = -700; |
---|
304 | pelaaja1.Y = Level.Bottom + 50; |
---|
305 | pelaaja1.Tag = "pelaaja"; |
---|
306 | |
---|
307 | pelaaja2 = new Pelaaja(40, 40, Shape.Circle); |
---|
308 | pelaaja2.Image = norsu; |
---|
309 | pelaaja2.X = 700; |
---|
310 | pelaaja2.Y = Level.Bottom + 50; |
---|
311 | pelaaja2.Tag = "pelaaja"; |
---|
312 | |
---|
313 | HitPoint1.MaxValue = 100; |
---|
314 | HitPoint1.Value = 100; |
---|
315 | HitPoint1.LowerLimit += pelaaja1Kuoli; |
---|
316 | |
---|
317 | HitPoint2.MaxValue = 100; |
---|
318 | HitPoint2.Value = 100; |
---|
319 | HitPoint2.LowerLimit += pelaaja2Kuoli; |
---|
320 | |
---|
321 | Add(pelaaja1); |
---|
322 | Add(pelaaja2); |
---|
323 | } |
---|
324 | |
---|
325 | void pelaaja1Kuoli() |
---|
326 | { |
---|
327 | if (pelaaja1.IsDestroying) |
---|
328 | { |
---|
329 | return; |
---|
330 | } |
---|
331 | |
---|
332 | pelaaja1.Destroy(); |
---|
333 | VaihdaAse(pelaaja1); |
---|
334 | MessageDisplay.Clear(); |
---|
335 | MessageDisplay.X = 0; |
---|
336 | pelaajan2Pisteet.Value += 1; |
---|
337 | |
---|
338 | if (!(pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue || pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue)) |
---|
339 | { |
---|
340 | if (pelaaja2.IsDestroying && pelaajan1Pisteet.Value != pelaajan1Pisteet.MaxValue) |
---|
341 | { |
---|
342 | MessageDisplay.Clear(); |
---|
343 | MessageDisplay.Add("Erä tasan!"); |
---|
344 | } |
---|
345 | else if (pelaajan1Pisteet.Value != pelaajan1Pisteet.MaxValue) |
---|
346 | { |
---|
347 | MessageDisplay.Add("Pelaaja 2 voitti erän!"); |
---|
348 | } |
---|
349 | |
---|
350 | Timer.SingleShot(3.0, aloitaUusiPeli); |
---|
351 | } |
---|
352 | else if (pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue) |
---|
353 | { |
---|
354 | Pelaaja2Voitti(); |
---|
355 | ClearTimers(); |
---|
356 | Timer.SingleShot(3.0, LuoAlkuValikko); |
---|
357 | } |
---|
358 | |
---|
359 | /* |
---|
360 | if (pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue) |
---|
361 | { |
---|
362 | Timer.SingleShot(3.0, LuoAlkuValikko); |
---|
363 | } |
---|
364 | |
---|
365 | else |
---|
366 | { |
---|
367 | Timer.SingleShot(3.0, aloitaUusiPeli); |
---|
368 | } |
---|
369 | */ |
---|
370 | |
---|
371 | |
---|
372 | } |
---|
373 | void pelaaja2Kuoli() |
---|
374 | { |
---|
375 | if (pelaaja2.IsDestroying) |
---|
376 | { |
---|
377 | return; |
---|
378 | } |
---|
379 | pelaaja2.Destroy(); |
---|
380 | VaihdaAse(pelaaja2); |
---|
381 | //MessageDisplay.Clear(); |
---|
382 | MessageDisplay.X = 0; |
---|
383 | pelaajan1Pisteet.Value += 1; |
---|
384 | |
---|
385 | if (!(pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue || pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue)) |
---|
386 | { |
---|
387 | if (pelaaja1.IsDestroying && pelaajan2Pisteet.Value != pelaajan2Pisteet.MaxValue) |
---|
388 | { |
---|
389 | MessageDisplay.Clear(); |
---|
390 | MessageDisplay.Add("Erä tasan!"); |
---|
391 | } |
---|
392 | else if (pelaajan1Pisteet.Value != pelaajan2Pisteet.MaxValue) |
---|
393 | { |
---|
394 | MessageDisplay.Add("Pelaaja 1 voitti erän!"); |
---|
395 | } |
---|
396 | |
---|
397 | Timer.SingleShot(3.0, aloitaUusiPeli); |
---|
398 | } |
---|
399 | else if (pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue) |
---|
400 | { |
---|
401 | Pelaaja1Voitti(); |
---|
402 | ClearTimers(); |
---|
403 | Timer.SingleShot(3.0, LuoAlkuValikko); |
---|
404 | } |
---|
405 | /*if (pelaaja1.IsDestroying && pelaajan2Pisteet.Value != pelaajan2Pisteet.MaxValue) |
---|
406 | { |
---|
407 | MessageDisplay.Add("Erä tasan!"); |
---|
408 | } |
---|
409 | else if (pelaajan2Pisteet.Value != pelaajan2Pisteet.MaxValue) |
---|
410 | { |
---|
411 | MessageDisplay.Add("Pelaaja 1 voitti erän!"); |
---|
412 | } |
---|
413 | |
---|
414 | if (pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue) |
---|
415 | { |
---|
416 | Timer.SingleShot(3.0, LuoAlkuValikko); |
---|
417 | } |
---|
418 | else |
---|
419 | { |
---|
420 | Timer.SingleShot(3.0, aloitaUusiPeli); |
---|
421 | }*/ |
---|
422 | } |
---|
423 | |
---|
424 | void keraaAse(PhysicsObject ase, Pelaaja pelaaja) |
---|
425 | { |
---|
426 | Weapon ase2 = null; // |
---|
427 | |
---|
428 | if (!pelaaja.voikoPoimiaAseen) return; |
---|
429 | |
---|
430 | ase.Destroy(); |
---|
431 | |
---|
432 | if (pelaaja == pelaaja1) |
---|
433 | { |
---|
434 | //PudotaAse(pelaaja1); |
---|
435 | VaihdaAse(pelaaja1); // tiputtaa vanhan aseen maahan |
---|
436 | ase2 = LuoAse(ase, pelaaja1); // ase2 on uusi ase |
---|
437 | |
---|
438 | } |
---|
439 | |
---|
440 | if (pelaaja == pelaaja2) |
---|
441 | { |
---|
442 | //PudotaAse(pelaaja2); |
---|
443 | |
---|
444 | VaihdaAse(pelaaja2); // tiputtaa vanhan aseen maahan |
---|
445 | ase2 = LuoAse(ase, pelaaja2); |
---|
446 | } |
---|
447 | |
---|
448 | naytaTiedot(); |
---|
449 | //Timer ajastin = new Timer(); |
---|
450 | //ajastin.Interval = 1; |
---|
451 | //ajastin.Tag = collision.Other; |
---|
452 | //ajastin.Trigger += new Timer.TriggerHandler(salliAseenvaihto); |
---|
453 | //ajastin.Start(); |
---|
454 | //AddTimer(ajastin); |
---|
455 | |
---|
456 | // Pelaaja törmäsi aseeseen |
---|
457 | |
---|
458 | |
---|
459 | |
---|
460 | /* PlatformCharacter pelaaja = (PlatformCharacter)collision.Other; |
---|
461 | if (ase.Owner != null) |
---|
462 | { |
---|
463 | return; |
---|
464 | } |
---|
465 | pelaaja.UnequipWeapon(); |
---|
466 | Weapon vanhaAse = pelaaja.Weapon; |
---|
467 | vanhaAse.RemoveFromOwner(); |
---|
468 | vanhaAse.X = pelaaja.X + vanhaAse.Width; |
---|
469 | vanhaAse.Y = pelaaja.Y; |
---|
470 | vanhaAse.Visible = true; |
---|
471 | vanhaAse.Hit(new Vector(100, 20)); |
---|
472 | pelaaja.Weapon = ase; |
---|
473 | pelaaja.EquipWeapon(); |
---|
474 | pelaaja.Weapon.Texture = ase.Texture; |
---|
475 | */ |
---|
476 | |
---|
477 | } |
---|
478 | |
---|
479 | /*private void PudotaAse(PlatformCharacter pelaaja) |
---|
480 | { |
---|
481 | Weapon tiputettu = new Weapon(pelaaja.Weapon.Width, pelaaja.Weapon.Height); |
---|
482 | tiputettu.Position = pelaaja.Position; |
---|
483 | |
---|
484 | Add(tiputettu); |
---|
485 | |
---|
486 | }*/ |
---|
487 | |
---|
488 | private void VaihdaAse(Pelaaja pelaaja) |
---|
489 | { |
---|
490 | if (pelaaja.Weapon == null) return; |
---|
491 | |
---|
492 | pelaaja.voikoPoimiaAseen = false; |
---|
493 | Timer.SingleShot(1.0, delegate { pelaaja.voikoPoimiaAseen = true; }); |
---|
494 | String aseenTagi = pelaaja.Weapon.Tag.ToString(); |
---|
495 | Vector koko = pelaaja.Weapon.Size; |
---|
496 | Vector paikka = pelaaja.Position; |
---|
497 | |
---|
498 | PhysicsObject tiputettuAse = new PhysicsObject(koko.X, koko.Y); |
---|
499 | tiputettuAse.Position = paikka; |
---|
500 | tiputettuAse.Tag = aseenTagi; |
---|
501 | tiputettuAse.CollisionIgnoreGroup = 1; |
---|
502 | pelaaja.CollisionIgnoreGroup = 1; |
---|
503 | Timer.SingleShot(1.0, delegate |
---|
504 | { |
---|
505 | tiputettuAse.CollisionIgnoreGroup = 0; |
---|
506 | pelaaja.CollisionIgnoreGroup = 0; |
---|
507 | }); |
---|
508 | //tiputettuAse.IgnoresCollisionWith(pelaaja2); |
---|
509 | Add(tiputettuAse); |
---|
510 | tiputettuAse.Image = pelaaja.Weapon.Image; |
---|
511 | //tiputettuAse.Hit(new Vector(0, 100)); |
---|
512 | AddCollisionHandler<PhysicsObject, Pelaaja>(tiputettuAse, "pelaaja", keraaAse); |
---|
513 | |
---|
514 | pelaaja.Weapon = null; |
---|
515 | |
---|
516 | //naytaTiedot(); |
---|
517 | //pelaaja.UnequipWeapon(); |
---|
518 | //Weapon vanhaAse = pelaaja.Weapon; |
---|
519 | //vanhaAse.RemoveFromOwner(); |
---|
520 | //vanhaAse.X = pelaaja.X + vanhaAse.Width; |
---|
521 | //vanhaAse.Y = pelaaja.Y; |
---|
522 | |
---|
523 | //vanhaAse.Visible = true; |
---|
524 | //vanhaAse.Hit(new Vector(100, 20)); |
---|
525 | //pelaaja.Weapon = ase; |
---|
526 | |
---|
527 | // pelaaja..EquipWeapon(); |
---|
528 | // pelaaja.Weapon.Texture = ase.Texture; |
---|
529 | |
---|
530 | |
---|
531 | |
---|
532 | } |
---|
533 | |
---|
534 | void KranaattiOsui(PhysicsObject ammus, PhysicsObject kohde) |
---|
535 | { |
---|
536 | if (kohde.Tag.ToString() == "pelaaja") |
---|
537 | { |
---|
538 | ammus.Destroy(); |
---|
539 | } |
---|
540 | } |
---|
541 | void PaineaaltoOsuu(IPhysicsObject kohde, Vector shokki) |
---|
542 | { |
---|
543 | if (kohde == pelaaja1) { HitPoint1.Value -= 75; } |
---|
544 | if (kohde == pelaaja2) { HitPoint2.Value -= 75; } |
---|
545 | } |
---|
546 | |
---|
547 | void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) |
---|
548 | { |
---|
549 | if ((string)kohde.Tag != "ammus") |
---|
550 | { |
---|
551 | ammus.Destroy(); |
---|
552 | } |
---|
553 | |
---|
554 | if (kohde.Tag.ToString() == "pelaaja") |
---|
555 | { |
---|
556 | if (kohde == pelaaja1) { HitPoint1.Value -= 15; } |
---|
557 | if (kohde == pelaaja2) { HitPoint2.Value -= 15; } |
---|
558 | } |
---|
559 | } |
---|
560 | void KivaariOsui(PhysicsObject ammus, PhysicsObject kohde) |
---|
561 | { |
---|
562 | if ((string)kohde.Tag != "ammus") |
---|
563 | { |
---|
564 | ammus.Destroy(); |
---|
565 | } |
---|
566 | if (kohde.Tag.ToString() == "pelaaja") |
---|
567 | { |
---|
568 | if (kohde == pelaaja1) { HitPoint1.Value -= 10; } |
---|
569 | if (kohde == pelaaja2) { HitPoint2.Value -= 10; } |
---|
570 | } |
---|
571 | } |
---|
572 | void MagnumOsui(PhysicsObject ammus, PhysicsObject kohde) |
---|
573 | { |
---|
574 | if ((string)kohde.Tag != "ammus") |
---|
575 | { |
---|
576 | ammus.Destroy(); |
---|
577 | } |
---|
578 | if (kohde.Tag.ToString() == "pelaaja") |
---|
579 | { |
---|
580 | if (kohde == pelaaja1) { HitPoint1.Value -= 35; } |
---|
581 | if (kohde == pelaaja2) { HitPoint2.Value -= 35; } |
---|
582 | } |
---|
583 | } |
---|
584 | void HaulikkoOsui(PhysicsObject ammus, PhysicsObject kohde) |
---|
585 | { |
---|
586 | if ((string)kohde.Tag != "ammus") |
---|
587 | { |
---|
588 | ammus.Destroy(); |
---|
589 | } |
---|
590 | |
---|
591 | if (kohde.Tag.ToString() == "pelaaja") |
---|
592 | { |
---|
593 | if (kohde == pelaaja1) { HitPoint1.Value -= 13; } |
---|
594 | if (kohde == pelaaja2) { HitPoint2.Value -= 13; } |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | private Weapon LuoAse(PhysicsObject ase, Pelaaja pelaaja) |
---|
599 | { |
---|
600 | Weapon ase2 = null; |
---|
601 | |
---|
602 | if (ase.Tag.ToString() == "Kivääri") |
---|
603 | { |
---|
604 | ase2 = new AssaultRifle(39, 13); |
---|
605 | ase2.FireRate = 7; |
---|
606 | ase2.ProjectileCollision = KivaariOsui; |
---|
607 | ase2.MaxAmmoLifetime = TimeSpan.FromSeconds(10); |
---|
608 | //kivaari.MomentOfInertia = double.PositiveInfinity; |
---|
609 | //kivaari.Mass = 0.1; |
---|
610 | ase2.Tag = "Kivääri"; |
---|
611 | ase2.Image = kivaarinkuva; |
---|
612 | //pelaaja.Add(ase2); |
---|
613 | pelaaja.Weapon = ase2; |
---|
614 | } |
---|
615 | if (ase.Tag.ToString() == "Magnum") |
---|
616 | { |
---|
617 | ase2 = new AssaultRifle(17, 12); |
---|
618 | ase2.FireRate = 1.2; |
---|
619 | ase2.ProjectileCollision = MagnumOsui; |
---|
620 | ase2.MaxAmmoLifetime = TimeSpan.FromSeconds(10); |
---|
621 | //magnum.MomentOfInertia = double.PositiveInfinity; |
---|
622 | //magnum.Mass = 0.1; |
---|
623 | ase2.Tag = "Magnum"; |
---|
624 | ase2.Image = magnumkuva; |
---|
625 | ase2.X = 10; |
---|
626 | ase2.Y = 10; |
---|
627 | //magnum.Shape = Shapes.CreateFromTexture(magnumtexture, new Vector(magnumtexture.Width, magnumtexture.Height), 100); |
---|
628 | //magnum.Size = new Vector(magnumtexture.Width, magnumtexture.Height); |
---|
629 | //magnum.UpdateShapeFromSize(); |
---|
630 | //magnum.AmmoType.Damage = new Damage(20); |
---|
631 | // pelaaja.Add(ase2); |
---|
632 | pelaaja.Weapon = ase2; |
---|
633 | } |
---|
634 | |
---|
635 | if (ase.Tag.ToString() == "Haulikko") |
---|
636 | { |
---|
637 | |
---|
638 | ase2 = new AssaultRifle(39, 13); |
---|
639 | ase2.FireRate = 0.75; |
---|
640 | ase2.ProjectileCollision = HaulikkoOsui; |
---|
641 | ase2.MaxAmmoLifetime = TimeSpan.FromSeconds(0.4); |
---|
642 | |
---|
643 | //haulikko.MomentOfInertia = double.PositiveInfinity; |
---|
644 | //haulikko.Mass = 0.1; |
---|
645 | ase2.Tag = "Haulikko"; |
---|
646 | //haulikko.AmmoType.Damage = new Damage(35); |
---|
647 | //haulikko.AmmoType.ClusterArc = 3; |
---|
648 | |
---|
649 | ase2.Image = haulikonkuva; |
---|
650 | //pelaaja.Add(ase2); |
---|
651 | pelaaja.Weapon = ase2; |
---|
652 | } |
---|
653 | |
---|
654 | if (ase.Tag.ToString() == "Kranaatinheitin") |
---|
655 | { |
---|
656 | ase2 = new Cannon(37, 19); |
---|
657 | ase2.FireRate = 0.5; |
---|
658 | ase2.ProjectileCollision = KranaattiOsui; |
---|
659 | ase2.MaxAmmoLifetime = TimeSpan.FromSeconds(2); |
---|
660 | //kranaatinheitin.MomentOfInertia = double.PositiveInfinity; |
---|
661 | //kranaatinheitin.Mass = 0.1; |
---|
662 | //kranaatinheitin.Power = new Meter<double>(5000, 0, 5000); |
---|
663 | ase2.Tag = "Kranaatinheitin"; |
---|
664 | ase2.Image = kranaatinheittimenkuva; |
---|
665 | //kranaatinheitin.Shape = Shapes.CreateFromTexture(grenade, new Vector(grenade.Width, grenade.Height), 100); |
---|
666 | //kranaatinheitin.Size = new Vector(grenade.Width, grenade.Height); |
---|
667 | //kranaatinheitin.UpdateShapeFromSize(); |
---|
668 | //pelaaja.Add(ase2); |
---|
669 | pelaaja.Weapon = ase2; |
---|
670 | } |
---|
671 | |
---|
672 | if (ase.Tag.ToString() == "Pistooli") |
---|
673 | { |
---|
674 | ase2 = new AssaultRifle(16, 11); |
---|
675 | ase2.FireRate = 2; |
---|
676 | ase2.ProjectileCollision = AmmusOsui; |
---|
677 | ase2.MaxAmmoLifetime = TimeSpan.FromSeconds(10); |
---|
678 | //pelaaja1.Weapon.Mass = 0.1; |
---|
679 | //pelaaja1.EquipWeapon(); |
---|
680 | //pelaaja1.Weapon.MomentOfInertia = double.PositiveInfinity; |
---|
681 | ase2.Tag = "Pistooli"; |
---|
682 | //pelaaja1.Weapon.Shape = Shapes.CreateFromTexture(pistol, new Vector(pistol.Width, pistol.Height), 100); |
---|
683 | //pelaaja1.Weapon.Size = new Vector(pistol.Width, pistol.Height); |
---|
684 | //pelaaja1.Weapon.UpdateShapeFromSize(); |
---|
685 | ase2.Image = pistoolinkuva; |
---|
686 | //pelaaja.Add(ase2); |
---|
687 | pelaaja.Weapon = ase2; |
---|
688 | } |
---|
689 | return ase2; |
---|
690 | } |
---|
691 | |
---|
692 | void lisaaKerattavaAse() |
---|
693 | { |
---|
694 | //Täällä lisätään ase kenttään |
---|
695 | /*Bullet luoti = new Bullet(1); |
---|
696 | Bullet luoti2 = new Bullet(1); |
---|
697 | Bullet hauli = new Bullet(1); |
---|
698 | |
---|
699 | Grenade kranaatti = new Grenade(1); |
---|
700 | kranaatti.Explosion = new Explosion(20); |
---|
701 | */ |
---|
702 | // kranaatti.ExplodeCondition = OnkoPelaaja; TODO: räjähtää kun osuu pelaajaan! |
---|
703 | |
---|
704 | PhysicsObject kivaari = new PhysicsObject(39, 13); |
---|
705 | kivaari.X = 200; |
---|
706 | kivaari.Y = -150; |
---|
707 | //kivaari.FireRate = 5; |
---|
708 | //kivaari.MomentOfInertia = double.PositiveInfinity; |
---|
709 | //kivaari.Mass = 0.1; |
---|
710 | kivaari.Tag = "Kivääri"; |
---|
711 | kivaari.Image = kivaarinkuva; |
---|
712 | Add(kivaari); |
---|
713 | |
---|
714 | PhysicsObject magnum = new PhysicsObject(17, 12); |
---|
715 | magnum.X = 0; |
---|
716 | magnum.Y = -350; |
---|
717 | //magnum.FireRate = 1; |
---|
718 | //magnum.MomentOfInertia = double.PositiveInfinity; |
---|
719 | //magnum.Mass = 0.1; |
---|
720 | magnum.Tag = "Magnum"; |
---|
721 | magnum.Image = magnumkuva; |
---|
722 | //magnum.Shape = Shapes.CreateFromTexture(magnumtexture, new Vector(magnumtexture.Width, magnumtexture.Height), 100); |
---|
723 | //magnum.Size = new Vector(magnumtexture.Width, magnumtexture.Height); |
---|
724 | //magnum.UpdateShapeFromSize(); |
---|
725 | //magnum.AmmoType.Damage = new Damage(20); |
---|
726 | Add(magnum); |
---|
727 | |
---|
728 | PhysicsObject haulikko = new PhysicsObject(39, 13); |
---|
729 | haulikko.X = -550; |
---|
730 | haulikko.Y = -150; |
---|
731 | //haulikko.FireRate = 0.75; |
---|
732 | //haulikko.MomentOfInertia = double.PositiveInfinity; |
---|
733 | //haulikko.Mass = 0.1; |
---|
734 | haulikko.Tag = "Haulikko"; |
---|
735 | //haulikko.AmmoType.Damage = new Damage(35); |
---|
736 | //haulikko.AmmoType.ClusterArc = 3; |
---|
737 | haulikko.Image = haulikonkuva; |
---|
738 | Add(haulikko); |
---|
739 | |
---|
740 | PhysicsObject kranaatinheitin = new PhysicsObject(37, 19); |
---|
741 | kranaatinheitin.X = -180; |
---|
742 | kranaatinheitin.Y = -100; |
---|
743 | // kranaatinheitin.FireRate = 0.2; |
---|
744 | //kranaatinheitin.MomentOfInertia = double.PositiveInfinity; |
---|
745 | //kranaatinheitin.Mass = 0.1; |
---|
746 | //kranaatinheitin.Power = new Meter<double>(5000, 0, 5000); |
---|
747 | kranaatinheitin.Tag = "Kranaatinheitin"; |
---|
748 | kranaatinheitin.Image = kranaatinheittimenkuva; |
---|
749 | //kranaatinheitin.Shape = Shapes.CreateFromTexture(grenade, new Vector(grenade.Width, grenade.Height), 100); |
---|
750 | //kranaatinheitin.Size = new Vector(grenade.Width, grenade.Height); |
---|
751 | //kranaatinheitin.UpdateShapeFromSize(); |
---|
752 | Add(kranaatinheitin); |
---|
753 | |
---|
754 | //Lisää myös törmäyksen käsittelijä aseelle, jossa kutsutaan keraaAse -aliohjelmaa |
---|
755 | |
---|
756 | AddCollisionHandler<PhysicsObject, Pelaaja>(kivaari, "pelaaja", keraaAse); |
---|
757 | AddCollisionHandler<PhysicsObject, Pelaaja>(haulikko, "pelaaja", keraaAse); |
---|
758 | AddCollisionHandler<PhysicsObject, Pelaaja>(kranaatinheitin, "pelaaja", keraaAse); |
---|
759 | AddCollisionHandler<PhysicsObject, Pelaaja>(magnum, "pelaaja", keraaAse); |
---|
760 | } |
---|
761 | |
---|
762 | void lisaaAsePelaajalle() |
---|
763 | { |
---|
764 | Bullet luoti = new Bullet(1); |
---|
765 | PhysicsObject pistol1 = new PhysicsObject(16, 11); |
---|
766 | pistol1.Image = pistoolinkuva; |
---|
767 | pistol1.Tag = "Pistooli"; |
---|
768 | |
---|
769 | LuoAse(pistol1, pelaaja1); |
---|
770 | LuoAse(pistol1, pelaaja2); |
---|
771 | |
---|
772 | //pelaaja1.UnequipWeapon(); |
---|
773 | /* pelaaja1.Weapon = new AssaultRifle(10, 10); |
---|
774 | pelaaja1.Weapon.FireRate = 2; |
---|
775 | //pelaaja1.Weapon.Mass = 0.1; |
---|
776 | Add(pelaaja1.Weapon); |
---|
777 | //pelaaja1.EquipWeapon(); |
---|
778 | //pelaaja1.Weapon.MomentOfInertia = double.PositiveInfinity; |
---|
779 | pelaaja1.Weapon.Tag = "Pistooli"; |
---|
780 | //pelaaja1.Weapon.Shape = Shapes.CreateFromTexture(pistol, new Vector(pistol.Width, pistol.Height), 100); |
---|
781 | //pelaaja1.Weapon.Size = new Vector(pistol.Width, pistol.Height); |
---|
782 | //pelaaja1.Weapon.UpdateShapeFromSize(); |
---|
783 | pelaaja1.Weapon.Image = pistoolinkuva; |
---|
784 | AddCollisionHandler(pelaaja1.Weapon, keraaAse); |
---|
785 | |
---|
786 | //pelaaja2.UnequipWeapon(); |
---|
787 | pelaaja2.Weapon = new AssaultRifle(10, 10); |
---|
788 | pelaaja2.Weapon.FireRate = 2; |
---|
789 | //pelaaja2.Weapon.Mass = 0.1; |
---|
790 | Add(pelaaja2.Weapon); |
---|
791 | //pelaaja2.EquipWeapon(); |
---|
792 | // pelaaja2.Weapon.MomentOfInertia = double.PositiveInfinity; |
---|
793 | pelaaja2.Weapon.Tag = "Pistooli"; |
---|
794 | //pelaaja2.Weapon.Shape = Shapes.CreateFromTexture(pistol, new Vector(pistol.Width, pistol.Height), 100); |
---|
795 | //pelaaja2.Weapon.Size = new Vector(pistol.Width, pistol.Height); |
---|
796 | // pelaaja2.Weapon.UpdateShapeFromSize(); |
---|
797 | pelaaja2.Weapon.Image = pistoolinkuva; |
---|
798 | AddCollisionHandler(pelaaja2.Weapon, keraaAse); */ |
---|
799 | } |
---|
800 | |
---|
801 | #endregion |
---|
802 | |
---|
803 | |
---|
804 | #region Nappaimet |
---|
805 | // Lisää peliin kaikki näppäimet |
---|
806 | void lisaaNappaimet() |
---|
807 | { |
---|
808 | ClearControls(); |
---|
809 | //Yleiset näppäimet |
---|
810 | Keyboard.Listen(Key.F1, ButtonState.Pressed, uusiPeli, "Aloittaa uuden pelin"); |
---|
811 | |
---|
812 | // Pelaajan näppäimet |
---|
813 | Keyboard.Listen(Key.A, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, new Vector(-liikeVoima, 0)); |
---|
814 | Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1, new Vector(liikeVoima, 0)); |
---|
815 | Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1, hyppyVoima); |
---|
816 | Keyboard.Listen(Key.Space, ButtonState.Down, Ammu, "Ammu", pelaaja1); |
---|
817 | |
---|
818 | Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja2, new Vector(-liikeVoima, 0)); |
---|
819 | Keyboard.Listen(Key.Right, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja2, new Vector(liikeVoima, 0)); |
---|
820 | Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja2, hyppyVoima); |
---|
821 | Keyboard.Listen(Key.Enter, ButtonState.Down, Ammu, "Ammu", pelaaja2); |
---|
822 | |
---|
823 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, PeliPauselle, "Pysäyttää pelin"); |
---|
824 | |
---|
825 | lisaaGamePadNappaimet(ControllerOne, pelaaja1); |
---|
826 | lisaaGamePadNappaimet(ControllerTwo, pelaaja2); |
---|
827 | } |
---|
828 | |
---|
829 | void lisaaGamePadNappaimet(GamePad pelaajaNro, PlatformCharacter pelaaja) |
---|
830 | { |
---|
831 | //Yleiset näppäimet |
---|
832 | //pelaajaNro.Listen(pelaajaNro, Button.Start, ButtonState.Pressed, uusiPeli, "Aloittaa uuden pelin"); |
---|
833 | |
---|
834 | //pelaajaNro.Listen(pelaajaNro, Button.DPadLeft, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", pelaaja, new Vector(-liikeVoima, 0)); |
---|
835 | //pelaajaNro.Listen(pelaajaNro, Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja, new Vector(liikeVoima, 0)); |
---|
836 | //pelaajaNro.Listen(pelaajaNro, Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja, hyppyVoima); |
---|
837 | //pelaajaNro.Listen(pelaajaNro, Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", pelaaja); |
---|
838 | } |
---|
839 | |
---|
840 | void PeliPauselle() |
---|
841 | { |
---|
842 | Pause(); |
---|
843 | MultiSelectWindow PauseValikko = new MultiSelectWindow("Kynäri", |
---|
844 | "Jatka peliä", "Aloita peli alusta", "Päävalikko", "Lopeta"); |
---|
845 | Add(PauseValikko); |
---|
846 | PauseValikko.AddItemHandler(0, Pause); |
---|
847 | PauseValikko.AddItemHandler(1, delegate { uusiPeli(); Pause(); }); |
---|
848 | PauseValikko.AddItemHandler(2, delegate { LuoAlkuValikko(); Pause(); }); |
---|
849 | PauseValikko.AddItemHandler(3, Exit); |
---|
850 | PauseValikko.DefaultCancel = 0; |
---|
851 | PauseValikko.Color = Color.Gray; |
---|
852 | } |
---|
853 | |
---|
854 | // Näppäimiin liitetyt toiminnot alkavat tästä --> |
---|
855 | void liikuta(PlatformCharacter hahmo, Vector voima) |
---|
856 | { |
---|
857 | //hahmo.Walk(e.Time, voima); |
---|
858 | hahmo.Walk(voima.X); |
---|
859 | } |
---|
860 | |
---|
861 | void naytaTiedot() |
---|
862 | { |
---|
863 | MessageDisplay.Clear(); |
---|
864 | MessageDisplay.X = 0; |
---|
865 | if (pelaaja1.Weapon != null) |
---|
866 | { |
---|
867 | MessageDisplay.Add("Pelaaja 1: " + pelaaja1.Weapon.Tag); |
---|
868 | } |
---|
869 | if (pelaaja2.Weapon != null) |
---|
870 | { |
---|
871 | MessageDisplay.Add("Pelaaja 2: " + pelaaja2.Weapon.Tag); |
---|
872 | } |
---|
873 | } |
---|
874 | |
---|
875 | void Ammu(PlatformCharacter hahmo) |
---|
876 | { |
---|
877 | if (hahmo.IsDestroyed || saaAmpua == false) |
---|
878 | { |
---|
879 | return; |
---|
880 | } |
---|
881 | |
---|
882 | PhysicsObject ammus = hahmo.Weapon.Shoot(); |
---|
883 | |
---|
884 | if (ammus != null) |
---|
885 | { |
---|
886 | ammus.Tag = "ammus"; |
---|
887 | ammus.IgnoresCollisionResponse = true; |
---|
888 | ammus.IgnoresExplosions = true; |
---|
889 | |
---|
890 | if ((string)hahmo.Weapon.Tag == "Kranaatinheitin") |
---|
891 | { |
---|
892 | ammus.Destroying += delegate { KranaattiRajahdys(ammus); }; |
---|
893 | ammus.IgnoresCollisionResponse = false; |
---|
894 | |
---|
895 | Timer.SingleShot(0.1, delegate { ammus.CollisionIgnorer = null; }); |
---|
896 | } |
---|
897 | if ((string)hahmo.Weapon.Tag == "Haulikko") |
---|
898 | { |
---|
899 | for (int i = 0; i < 5; i++) |
---|
900 | { |
---|
901 | PhysicsObject ammus2 = new PhysicsObject(ammus.Image); |
---|
902 | ammus2.IgnoresGravity = true; |
---|
903 | ammus2.Size = ammus.Size; |
---|
904 | ammus2.Position = ammus.Position; |
---|
905 | ammus2.Velocity = ammus.Velocity; |
---|
906 | ammus2.MaximumLifetime = TimeSpan.FromSeconds(0.4); |
---|
907 | ammus2.Hit(new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-300, 300))); |
---|
908 | //ammus2.CollisionIgnoreGroup = 2; |
---|
909 | ammus2.CollisionIgnorer = ammus.CollisionIgnorer; |
---|
910 | ammus2.Tag = "ammus"; |
---|
911 | ammus2.IgnoresCollisionResponse = true; |
---|
912 | ammus2.IgnoresExplosions = true; |
---|
913 | AddCollisionHandler(ammus2, HaulikkoOsui); |
---|
914 | Add(ammus2); |
---|
915 | } |
---|
916 | } |
---|
917 | Add(ammus); |
---|
918 | } |
---|
919 | |
---|
920 | return; |
---|
921 | } |
---|
922 | |
---|
923 | void KranaattiRajahdys(PhysicsObject ammus) |
---|
924 | { |
---|
925 | Explosion rajahdys = new Explosion(100); |
---|
926 | rajahdys.Position = ammus.Position; |
---|
927 | rajahdys.AddShockwaveHandler("pelaaja", PaineaaltoOsuu); |
---|
928 | Add(rajahdys); |
---|
929 | rajahdys.Force = 100; |
---|
930 | rajahdys.Speed = 1000; |
---|
931 | } |
---|
932 | |
---|
933 | void hyppaa(PlatformCharacter hahmo, double voima) |
---|
934 | { |
---|
935 | //PlatformCharacter hahmo = e.Parameter0 as PlatformCharacter; |
---|
936 | //double voima = e.Parameter1.ToDouble(); |
---|
937 | |
---|
938 | /* if (Math.Abs(hahmo.Velocity.Y) > 0.001) |
---|
939 | { |
---|
940 | return; |
---|
941 | } |
---|
942 | */ |
---|
943 | |
---|
944 | if (hahmo.Jump(voima)) |
---|
945 | { |
---|
946 | hyppyAani.Play(); |
---|
947 | } |
---|
948 | } |
---|
949 | |
---|
950 | void uusiPeli() |
---|
951 | { |
---|
952 | NollaaLaskurit(); |
---|
953 | aloitaUusiPeli(); |
---|
954 | } |
---|
955 | #endregion |
---|
956 | |
---|
957 | |
---|
958 | } |
---|