1 | using System; |
---|
2 | using Jypeli; |
---|
3 | using Jypeli.Widgets; |
---|
4 | using Jypeli.Assets; |
---|
5 | using Jypeli.Effects; |
---|
6 | using Physics2DDotNet.Ignorers; |
---|
7 | using System.Collections.Generic; |
---|
8 | |
---|
9 | |
---|
10 | public class Peli : TopDownPhysicsGame |
---|
11 | { |
---|
12 | PhysicsObject vasenReuna; |
---|
13 | PhysicsObject oikeaReuna; |
---|
14 | DoubleMeter voimaMittari1; |
---|
15 | DoubleMeter voimaMittari2; |
---|
16 | Automobile auto1; |
---|
17 | Automobile auto2; |
---|
18 | IntMeter pelaajan1Pisteet; |
---|
19 | IntMeter pelaajan2Pisteet; |
---|
20 | Label aikaNaytto; |
---|
21 | |
---|
22 | AssaultRifle pyssy1; |
---|
23 | AssaultRifle pyssy2; |
---|
24 | |
---|
25 | Image auto1Kuva = LoadImage("PunAuto"); |
---|
26 | Image auto2Kuva = LoadImage("SinAuto"); |
---|
27 | Image[] auto1Ampuu = LoadImages("PunAuto", "PunAutoAmpuu", "PunAuto", "PunAutoAmpuu", "PunAuto"); |
---|
28 | Image[] auto2Ampuu = LoadImages("SinAuto", "SinAutoAmpuu", "SinAuto", "SinAutoAmpuu", "SinAuto"); |
---|
29 | |
---|
30 | List<Label> valikonKohdat; |
---|
31 | |
---|
32 | protected override void Begin() |
---|
33 | { |
---|
34 | KineticFriction = 0.5; // Asetetaan kitka |
---|
35 | |
---|
36 | Valikko(); |
---|
37 | |
---|
38 | auto1 = new Automobile(100, 55); |
---|
39 | auto1.CollisionIgnorer = new ObjectIgnorer(); |
---|
40 | auto1.Mass = 100.0; |
---|
41 | auto1.Color = new Color(1, 1, 1); |
---|
42 | auto1.X = -300; |
---|
43 | auto1.Y = 0; |
---|
44 | auto1.LinearDamping = 0.975; |
---|
45 | auto1.AngularDamping = 0.1; |
---|
46 | auto1.CanRotate = false; |
---|
47 | auto1.Acceleration = 1250; |
---|
48 | auto1.Image = auto1Kuva; |
---|
49 | auto1.Animation = new Animation(auto1Ampuu); |
---|
50 | |
---|
51 | |
---|
52 | auto2 = new Automobile(100, 55); |
---|
53 | auto2.CollisionIgnorer = new ObjectIgnorer(); |
---|
54 | auto2.Mass = 100.0; |
---|
55 | auto2.Color = new Color(255, 255, 255); |
---|
56 | auto2.X = 300; |
---|
57 | auto2.Y = 0; |
---|
58 | auto2.LinearDamping = 0.975; |
---|
59 | auto2.AngularDamping = 0.1; |
---|
60 | auto2.Angle = Angle.Degrees(180.0); |
---|
61 | auto2.CanRotate = false; |
---|
62 | auto2.Acceleration = 1250; |
---|
63 | auto2.Image = auto2Kuva; |
---|
64 | auto2.Animation = new Animation(auto2Ampuu); |
---|
65 | |
---|
66 | |
---|
67 | |
---|
68 | pyssy1 = new AssaultRifle(20, 5); |
---|
69 | pyssy1.Tag = "ase"; |
---|
70 | pyssy1.TimeBetweenUse = TimeSpan.FromMilliseconds(100); |
---|
71 | pyssy1.Ammo.Value = 50000; |
---|
72 | pyssy1.IsVisible = false; |
---|
73 | auto1.Add(pyssy1); |
---|
74 | |
---|
75 | pyssy2 = new AssaultRifle(20, 5); |
---|
76 | pyssy2.Tag = "ase"; |
---|
77 | pyssy2.TimeBetweenUse = TimeSpan.FromMilliseconds(100); |
---|
78 | pyssy2.Ammo.Value = 50000; |
---|
79 | pyssy2.IsVisible = false; |
---|
80 | auto2.Add(pyssy2); |
---|
81 | |
---|
82 | |
---|
83 | } |
---|
84 | void Valikko() |
---|
85 | { |
---|
86 | ClearAll(); |
---|
87 | valikonKohdat = new List<Label>(); |
---|
88 | |
---|
89 | Label kohta1 = new Label("Aloita uusi peli"); |
---|
90 | kohta1.Position = new Vector(0, 40); |
---|
91 | valikonKohdat.Add(kohta1); |
---|
92 | |
---|
93 | Label kohta2 = new Label("Lopeta"); |
---|
94 | kohta2.Position = new Vector(0, -40); |
---|
95 | valikonKohdat.Add(kohta2); |
---|
96 | |
---|
97 | foreach (Label valikonKohta in valikonKohdat) |
---|
98 | { |
---|
99 | Add(valikonKohta); |
---|
100 | } |
---|
101 | |
---|
102 | Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); |
---|
103 | Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Lopeta, null); |
---|
104 | |
---|
105 | Mouse.IsCursorVisible = true; |
---|
106 | Mouse.ListenMovement(1.0, ValikossaLiikkuminen, null); |
---|
107 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Lopeta, ""); |
---|
108 | } |
---|
109 | void ValikossaLiikkuminen(AnalogState hiirenTila) |
---|
110 | { |
---|
111 | foreach (Label kohta in valikonKohdat) |
---|
112 | { |
---|
113 | if (Mouse.IsCursorOn(kohta)) |
---|
114 | { |
---|
115 | kohta.TextColor = Color.Red; |
---|
116 | } |
---|
117 | else |
---|
118 | { |
---|
119 | kohta.TextColor = Color.Black; |
---|
120 | } |
---|
121 | |
---|
122 | } |
---|
123 | } |
---|
124 | void AloitaPeli() |
---|
125 | { |
---|
126 | ClearAll(); |
---|
127 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); |
---|
128 | |
---|
129 | AddCollisionHandler(auto1, KasitteleAuto1Tormays); |
---|
130 | AddCollisionHandler(auto2, KasitteleAuto2Tormays); |
---|
131 | |
---|
132 | AsetaOhjaimet(); |
---|
133 | |
---|
134 | Add(auto1, 1); |
---|
135 | Add(auto2, 1); |
---|
136 | |
---|
137 | Kentta(); |
---|
138 | |
---|
139 | Pelaaja1HP(); |
---|
140 | Pelaaja2HP(); |
---|
141 | |
---|
142 | LisaaLaskurit(); |
---|
143 | |
---|
144 | } |
---|
145 | |
---|
146 | void Lopeta() |
---|
147 | { |
---|
148 | Exit(); |
---|
149 | } |
---|
150 | |
---|
151 | |
---|
152 | void AsetaOhjaimet() |
---|
153 | { |
---|
154 | Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); |
---|
155 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); |
---|
156 | Keyboard.Listen(Key.W, ButtonState.Down, kiihdyta, "Kiihdytä", auto1); |
---|
157 | Keyboard.Listen(Key.S, ButtonState.Down, jarruta, "Jarruta", auto1); |
---|
158 | Keyboard.Listen(Key.A, ButtonState.Down, kaanny, "Käänny vasemmalle", auto1, 2.0); |
---|
159 | Keyboard.Listen(Key.D, ButtonState.Down, kaanny, "Käänny oikealle", auto1, -2.0); |
---|
160 | Keyboard.Listen(Key.LeftControl, ButtonState.Pressed, AloitaAmpuminen, null, auto1, pyssy1); |
---|
161 | Keyboard.Listen(Key.LeftControl, ButtonState.Down, AmmuAseella, "Ammu", auto1, pyssy1); |
---|
162 | Keyboard.Listen(Key.LeftControl, ButtonState.Released, LopetaAmpuminen, null, auto1, pyssy1); |
---|
163 | |
---|
164 | Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); |
---|
165 | Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); |
---|
166 | Keyboard.Listen(Key.Up, ButtonState.Down, kiihdyta, "Kiihdytä", auto2); |
---|
167 | Keyboard.Listen(Key.Down, ButtonState.Down, jarruta, "Jarruta", auto2); |
---|
168 | Keyboard.Listen(Key.Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto2, 2.0); |
---|
169 | Keyboard.Listen(Key.Right, ButtonState.Down, kaanny, "Käänny oikealle", auto2, -2.0); |
---|
170 | Keyboard.Listen(Key.RightControl, ButtonState.Pressed, AloitaAmpuminen, null, auto2, pyssy2); |
---|
171 | Keyboard.Listen(Key.RightControl, ButtonState.Down, AmmuAseella, "Ammu", auto2, pyssy2); |
---|
172 | Keyboard.Listen(Key.RightControl, ButtonState.Released, LopetaAmpuminen, null, auto2, pyssy2); |
---|
173 | } |
---|
174 | |
---|
175 | void kiihdyta(Automobile auto) |
---|
176 | { |
---|
177 | auto.Accelerate(Time.SinceLastUpdate.TotalSeconds); |
---|
178 | } |
---|
179 | |
---|
180 | void jarruta(Automobile auto) |
---|
181 | { |
---|
182 | auto.Brake(Time.SinceLastUpdate.TotalSeconds); |
---|
183 | } |
---|
184 | |
---|
185 | void kaanny(Automobile auto, double kaannos) |
---|
186 | { |
---|
187 | auto.Angle = Angle.Degrees(auto.Angle.Degree + kaannos * 1.75); |
---|
188 | } |
---|
189 | |
---|
190 | void Kentta() |
---|
191 | { |
---|
192 | GameObject maata = new GameObject(800.0, 700.0); |
---|
193 | maata.Shape = Shapes.Circle; |
---|
194 | maata.Color = Color.Gray; |
---|
195 | Add(maata); |
---|
196 | |
---|
197 | PhysicsObject pylvas1 = PhysicsObject.CreateStaticObject(50.0, 50.0); |
---|
198 | pylvas1.Shape = Shapes.Rectangle; |
---|
199 | pylvas1.X = 200; |
---|
200 | pylvas1.Y = 200; |
---|
201 | pylvas1.Restitution = 0.2; |
---|
202 | pylvas1.Tag = "pylvas"; |
---|
203 | pylvas1.Color = Color.DarkGray; |
---|
204 | Add(pylvas1); |
---|
205 | |
---|
206 | PhysicsObject pylvas2 = PhysicsObject.CreateStaticObject(50.0, 50.0); |
---|
207 | pylvas2.Shape = Shapes.Rectangle; |
---|
208 | pylvas2.X = -200; |
---|
209 | pylvas2.Y = 200; |
---|
210 | pylvas2.Restitution = 0.2; |
---|
211 | pylvas2.Tag = "pylvas"; |
---|
212 | pylvas2.Color = Color.DarkGray; |
---|
213 | Add(pylvas2); |
---|
214 | |
---|
215 | PhysicsObject pylvas3 = PhysicsObject.CreateStaticObject(50.0, 50.0); |
---|
216 | pylvas3.Shape = Shapes.Rectangle; |
---|
217 | pylvas3.X = -200; |
---|
218 | pylvas3.Y = -200; |
---|
219 | pylvas3.Restitution = 0.2; |
---|
220 | pylvas3.Tag = "pylvas"; |
---|
221 | pylvas3.Color = Color.DarkGray; |
---|
222 | Add(pylvas3); |
---|
223 | |
---|
224 | PhysicsObject pylvas4 = PhysicsObject.CreateStaticObject(50.0, 50.0); |
---|
225 | pylvas4.Shape = Shapes.Rectangle; |
---|
226 | pylvas4.X = 200; |
---|
227 | pylvas4.Y = -200; |
---|
228 | pylvas4.Restitution = 0.2; |
---|
229 | pylvas4.Tag = "pylvas"; |
---|
230 | pylvas4.Color = Color.DarkGray; |
---|
231 | Add(pylvas4); |
---|
232 | |
---|
233 | PhysicsObject pylvas5 = PhysicsObject.CreateStaticObject(50.0, 50.0); |
---|
234 | pylvas5.Shape = Shapes.Rectangle; |
---|
235 | pylvas5.X = -75; |
---|
236 | pylvas5.Y = 0; |
---|
237 | pylvas5.Restitution = 0.2; |
---|
238 | pylvas5.Tag = "pylvas"; |
---|
239 | pylvas5.Color = Color.DarkGray; |
---|
240 | Add(pylvas5); |
---|
241 | |
---|
242 | PhysicsObject pylvas6 = PhysicsObject.CreateStaticObject(50.0, 50.0); |
---|
243 | pylvas6.Shape = Shapes.Rectangle; |
---|
244 | pylvas6.X = 75; |
---|
245 | pylvas6.Y = 0; |
---|
246 | pylvas6.Restitution = 0.2; |
---|
247 | pylvas6.Tag = "pylvas"; |
---|
248 | pylvas6.Color = Color.DarkGray; |
---|
249 | Add(pylvas6); |
---|
250 | |
---|
251 | GameObject Reuna = new GameObject(70.0, 70.0); |
---|
252 | Reuna.Shape = Shapes.Circle; |
---|
253 | Reuna.Color = Color.Black; |
---|
254 | Add(Reuna); |
---|
255 | |
---|
256 | GameObject Boostipaikka = new GameObject(60.0, 60.0); |
---|
257 | Boostipaikka.Shape = Shapes.Circle; |
---|
258 | Boostipaikka.Color = Color.Turquoise; |
---|
259 | Add(Boostipaikka); |
---|
260 | |
---|
261 | |
---|
262 | vasenReuna = Level.CreateLeftBorder(); |
---|
263 | vasenReuna.Restitution = 0.3; |
---|
264 | vasenReuna.IsVisible = true; |
---|
265 | oikeaReuna = Level.CreateRightBorder(); |
---|
266 | oikeaReuna.Restitution = 0.3; |
---|
267 | oikeaReuna.IsVisible = true; |
---|
268 | PhysicsObject ylaReuna = Level.CreateTopBorder(); |
---|
269 | ylaReuna.Restitution = 0.3; |
---|
270 | ylaReuna.IsVisible = true; |
---|
271 | PhysicsObject alaReuna = Level.CreateBottomBorder(); |
---|
272 | alaReuna.Restitution = 0.3; |
---|
273 | alaReuna.IsVisible = true; |
---|
274 | |
---|
275 | Level.BackgroundColor = Color.ForestGreen; |
---|
276 | |
---|
277 | Camera.X = 0.0; |
---|
278 | Camera.Y = 0.0; |
---|
279 | Camera.ZoomFactor = 0.9; |
---|
280 | } |
---|
281 | void Pelaaja1Tuhoutuu() |
---|
282 | { |
---|
283 | int pMaxMaara = 200; |
---|
284 | ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("liekkiEsimerkki"), pMaxMaara); |
---|
285 | ExplosionSystem rajahdys2 = new ExplosionSystem(LoadImage("rajahdysEsimerkki"), pMaxMaara); |
---|
286 | Add(rajahdys); |
---|
287 | Add(rajahdys2); |
---|
288 | |
---|
289 | double x = auto1.X; |
---|
290 | double y = auto1.Y; |
---|
291 | int pMaara = 100; |
---|
292 | int pMaara2 = 100; |
---|
293 | rajahdys.AddEffect(x, y, pMaara); |
---|
294 | rajahdys2.AddEffect(x, y, pMaara2); |
---|
295 | |
---|
296 | pelaajan2Pisteet.Value += 1; |
---|
297 | |
---|
298 | UusiEra(); |
---|
299 | } |
---|
300 | void Pelaaja2Tuhoutuu() |
---|
301 | { |
---|
302 | int pMaxMaara = 200; |
---|
303 | ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("liekkiEsimerkki"), pMaxMaara); |
---|
304 | ExplosionSystem rajahdys2 = new ExplosionSystem(LoadImage("rajahdysEsimerkki"), pMaxMaara); |
---|
305 | Add(rajahdys); |
---|
306 | Add(rajahdys2); |
---|
307 | |
---|
308 | double x = auto2.X; |
---|
309 | double y = auto2.Y; |
---|
310 | int pMaara = 100; |
---|
311 | int pMaara2 = 100; |
---|
312 | rajahdys.AddEffect(x, y, pMaara); |
---|
313 | rajahdys2.AddEffect(x, y, pMaara2); |
---|
314 | |
---|
315 | pelaajan1Pisteet.Value += 1; |
---|
316 | |
---|
317 | UusiEra(); |
---|
318 | } |
---|
319 | void Voitto() |
---|
320 | { |
---|
321 | if (pelaajan1Pisteet.Value >= 5) |
---|
322 | { |
---|
323 | MessageDisplay.Add("Pelaaja 1 Voitti!"); |
---|
324 | MessageDisplay.X = -75.0; |
---|
325 | MessageDisplay.Y = 100.0; |
---|
326 | Loppui(); |
---|
327 | } |
---|
328 | if (pelaajan2Pisteet.Value >= 5) |
---|
329 | { |
---|
330 | MessageDisplay.Add("Pelaaja 2 Voitti!"); |
---|
331 | MessageDisplay.X = -75.0; |
---|
332 | MessageDisplay.Y = 100.0; |
---|
333 | Loppui(); |
---|
334 | } |
---|
335 | } |
---|
336 | void Pelaaja1HP() |
---|
337 | { |
---|
338 | voimaMittari1 = new DoubleMeter(25); |
---|
339 | voimaMittari1.MaxValue = 25; |
---|
340 | BarGauge voimaPalkki = new BarGauge(10, 150); |
---|
341 | voimaPalkki.BindTo(voimaMittari1); |
---|
342 | voimaPalkki.X = (0.95 * Screen.LeftSafe); |
---|
343 | voimaPalkki.Y = (0.05 * Screen.Height); |
---|
344 | Add(voimaPalkki); |
---|
345 | } |
---|
346 | void Pelaaja2HP() |
---|
347 | { |
---|
348 | voimaMittari2 = new DoubleMeter(25); |
---|
349 | voimaMittari2.MaxValue = 25; |
---|
350 | BarGauge voimaPalkki2 = new BarGauge(10, 150); |
---|
351 | voimaPalkki2.BindTo(voimaMittari2); |
---|
352 | voimaPalkki2.X = (0.95 * Screen.RightSafe); |
---|
353 | voimaPalkki2.Y = (0.05 * Screen.Height); |
---|
354 | Add(voimaPalkki2); |
---|
355 | } |
---|
356 | void KasitteleAuto1Tormays(PhysicsObject auto1, PhysicsObject kohde) |
---|
357 | { |
---|
358 | |
---|
359 | if (auto1.Velocity.Magnitude > 300) |
---|
360 | { |
---|
361 | voimaMittari1.Value--; |
---|
362 | } |
---|
363 | if (voimaMittari1.Value == 0) |
---|
364 | { |
---|
365 | Pelaaja1Tuhoutuu(); |
---|
366 | } |
---|
367 | if (auto2.Velocity.Magnitude > auto1.Velocity.Magnitude) |
---|
368 | { |
---|
369 | voimaMittari1.Value--; |
---|
370 | } |
---|
371 | } |
---|
372 | void KasitteleAuto2Tormays(PhysicsObject auto2, PhysicsObject kohde) |
---|
373 | { |
---|
374 | |
---|
375 | if (auto2.Velocity.Magnitude > 300) |
---|
376 | { |
---|
377 | voimaMittari2.Value--; |
---|
378 | } |
---|
379 | if (voimaMittari2.Value == 0) |
---|
380 | { |
---|
381 | Pelaaja2Tuhoutuu(); |
---|
382 | } |
---|
383 | if (auto1.Velocity.Magnitude > auto2.Velocity.Magnitude) |
---|
384 | { |
---|
385 | voimaMittari2.Value--; |
---|
386 | } |
---|
387 | } |
---|
388 | void LisaaLaskurit() |
---|
389 | { |
---|
390 | pelaajan1Pisteet = LuoPisteLaskuri(-250.0, 250.0); |
---|
391 | pelaajan2Pisteet = LuoPisteLaskuri(230.0, 250.0); |
---|
392 | } |
---|
393 | IntMeter LuoPisteLaskuri(double x, double y) |
---|
394 | { |
---|
395 | IntMeter laskuri = new IntMeter(0); |
---|
396 | laskuri.MaxValue = 5; |
---|
397 | Label naytto = new Label(); |
---|
398 | naytto.BindTo(laskuri); |
---|
399 | naytto.X = x; |
---|
400 | naytto.Y = y; |
---|
401 | naytto.TextColor = Color.White; |
---|
402 | Add(naytto); |
---|
403 | return laskuri; |
---|
404 | } |
---|
405 | void UusiEra() |
---|
406 | { |
---|
407 | ClearControls(); |
---|
408 | |
---|
409 | voimaMittari1.Value = 25; |
---|
410 | voimaMittari2.Value = 25; |
---|
411 | |
---|
412 | auto1.X = -300; |
---|
413 | auto1.Y = 0; |
---|
414 | auto2.X = 300; |
---|
415 | auto2.Y = 0; |
---|
416 | |
---|
417 | auto1.Angle = new Angle(); |
---|
418 | auto2.Angle = Angle.Degrees(180.0); |
---|
419 | |
---|
420 | auto1.Stop(); |
---|
421 | auto2.Stop(); |
---|
422 | |
---|
423 | EranAlku(); |
---|
424 | |
---|
425 | } |
---|
426 | |
---|
427 | void AloitaAmpuminen(Automobile auto, Weapon ase) |
---|
428 | { |
---|
429 | if (auto == auto1) |
---|
430 | { |
---|
431 | auto1.Animation.Start(); |
---|
432 | } |
---|
433 | else |
---|
434 | { |
---|
435 | |
---|
436 | auto2.Animation.Start(); |
---|
437 | } |
---|
438 | } |
---|
439 | |
---|
440 | void LopetaAmpuminen(Automobile auto, Weapon ase) |
---|
441 | { |
---|
442 | if (auto == auto1) |
---|
443 | { |
---|
444 | auto1.Animation.Stop(); |
---|
445 | } |
---|
446 | else |
---|
447 | { |
---|
448 | |
---|
449 | auto2.Animation.Stop(); |
---|
450 | } |
---|
451 | |
---|
452 | } |
---|
453 | |
---|
454 | void AmmuAseella(Automobile auto, Weapon ase) |
---|
455 | { |
---|
456 | PhysicsObject ammus = ase.Shoot(); |
---|
457 | |
---|
458 | if (ammus != null) |
---|
459 | { |
---|
460 | ammus.CollisionIgnorer = auto.CollisionIgnorer; |
---|
461 | ammus.Size *= 3; |
---|
462 | AddCollisionHandler(ammus, AmmusOsui); |
---|
463 | } |
---|
464 | } |
---|
465 | |
---|
466 | void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) |
---|
467 | { |
---|
468 | ammus.Destroy(); |
---|
469 | |
---|
470 | if (kohde == auto1) |
---|
471 | { |
---|
472 | voimaMittari1.Value--; |
---|
473 | return; |
---|
474 | } |
---|
475 | if (kohde == auto2) |
---|
476 | { |
---|
477 | voimaMittari2.Value--; |
---|
478 | } |
---|
479 | } |
---|
480 | |
---|
481 | void EranAlku() |
---|
482 | { |
---|
483 | auto1.Animation.Stop(); |
---|
484 | auto2.Animation.Stop(); |
---|
485 | |
---|
486 | Timer aikaLaskuri = new Timer(); |
---|
487 | aikaLaskuri.Interval = 3; |
---|
488 | aikaLaskuri.Trigger += AikaLoppui; |
---|
489 | aikaLaskuri.Start(); |
---|
490 | |
---|
491 | aikaNaytto = new Label(); |
---|
492 | aikaNaytto.TextColor = Color.White; |
---|
493 | aikaNaytto.X = -90.0; |
---|
494 | aikaNaytto.Y = 0.0; |
---|
495 | aikaNaytto.DecimalPlaces = 1; |
---|
496 | aikaNaytto.BindTo(aikaLaskuri.SecondCounter); |
---|
497 | Add(aikaNaytto); |
---|
498 | |
---|
499 | |
---|
500 | Voitto(); |
---|
501 | } |
---|
502 | |
---|
503 | void AikaLoppui(Timer ajastin) |
---|
504 | { |
---|
505 | MessageDisplay.Add("Start!"); |
---|
506 | MessageDisplay.X = -30.0; |
---|
507 | MessageDisplay.Y = 100.0; |
---|
508 | ajastin.Stop(); |
---|
509 | ajastin.Reset(); |
---|
510 | ajastin.Destroy(); |
---|
511 | aikaNaytto.Destroy(); |
---|
512 | AsetaOhjaimet(); |
---|
513 | |
---|
514 | pyssy1.Ammo.Value = 50000; |
---|
515 | pyssy2.Ammo.Value = 50000; |
---|
516 | } |
---|
517 | void Loppui() |
---|
518 | { |
---|
519 | Remove(auto1); |
---|
520 | Remove(auto2); |
---|
521 | Timer lopunLaskuri = new Timer(); |
---|
522 | lopunLaskuri.Interval = 3; |
---|
523 | lopunLaskuri.Trigger += PeliLoppui; |
---|
524 | lopunLaskuri.Start(); |
---|
525 | } |
---|
526 | void PeliLoppui(Timer ajastin) |
---|
527 | { |
---|
528 | Valikko(); |
---|
529 | Level.BackgroundColor = Color.LightBlue; |
---|
530 | } |
---|
531 | } |
---|