- Timestamp:
- 2012-06-15 10:43:42 (11 years ago)
- Location:
- 2012/24/AtteJ/Räiskintä-mättöpeli
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/24/AtteJ/Räiskintä-mättöpeli/Räiskintä-mättöpeli/Räiskintä-mättöpeli/Räiskintä_mättöpeli.cs
r3028 r3070 20 20 IntMeter KierrosLaskuri; 21 21 DoubleMeter Elamat; 22 DoubleMeter Elamat2; 22 23 ScoreList TopLista = new ScoreList(10, false, 0); 23 24 bool peliLoppui = false; 24 25 25 26 int Vihollisia = 10; 27 26 28 int vihollisiaV2 = 0; 29 27 30 int vihollisiaV3 = 0; 28 31 32 29 33 PhysicsObject vihollinenV1(double x, double y) 30 31 { 32 TagFollowerBrain SeuraajanAivot = new TagFollowerBrain("pelaaja", 20000); 33 PhysicsObject enemy = new PhysicsObject (30, 30); 34 { 35 TagFollowerBrain SeuraajanAivot = new TagFollowerBrain("pelaaja", 10000); 36 PhysicsObject enemy = new PhysicsObject(30, 30); 34 37 enemy.Brain = SeuraajanAivot; 35 38 enemy.X = x; … … 38 41 enemy.Color = Color.Green; 39 42 enemy.Tag = "vihollinen1"; 40 Add 43 Add(enemy); 41 44 viholliset.Add(enemy); 42 45 return enemy; 43 46 } 47 44 48 PhysicsObject vihollinenV2(double x, double y) 45 49 { 46 TagFollowerBrain SeuraajanAivot = new TagFollowerBrain("pelaaja", 400); 47 SeuraajanAivot.Speed = 300; 50 TagFollowerBrain SeuraajanAivot = new TagFollowerBrain("pelaaja", 12000); 48 51 PhysicsObject enemy = new PhysicsObject(30, 30); 49 52 enemy.Brain = SeuraajanAivot; … … 57 60 return enemy; 58 61 } 62 59 63 PhysicsObject vihollinenV3(double x, double y) 60 64 { 61 TagFollowerBrain SeuraajanAivot = new TagFollowerBrain("pelaaja", 400); 62 SeuraajanAivot.Speed = 200; 65 TagFollowerBrain SeuraajanAivot = new TagFollowerBrain("pelaaja", 12000); 63 66 PhysicsObject enemy = new PhysicsObject(30, 30); 64 67 enemy.Brain = SeuraajanAivot; … … 76 79 public override void Begin() 77 80 { 81 //IsFullScreen = true; 82 78 83 MultiSelectWindow AlkuValikko = new MultiSelectWindow("Tervetuloa peliin", 79 84 "Aloita", "Ohje", "Poistu"); … … 100 105 } 101 106 } 107 102 108 void YksinVaiKaksinPeli() 103 109 { 104 MultiSelectWindow PelaajienMaara = new MultiSelectWindow("Yksin- vai kaksinpeli?", 110 MultiSelectWindow PelaajienMaara = new MultiSelectWindow("Yksin- vai kaksinpeli?", 105 111 "Yksinpeli", "Kaksinpeli", "Takaisin"); 106 112 PelaajienMaara.ItemSelected += PainettiinValikon2Nappia; 107 Add (PelaajienMaara); 108 } 113 Add(PelaajienMaara); 114 } 115 109 116 void PainettiinValikon2Nappia(int valinta2) 110 117 { … … 122 129 } 123 130 } 131 124 132 void AlustaPeli() 125 133 { 126 LuoKenttä 127 Pelaaja 134 LuoKenttä(); 135 Pelaaja(); 128 136 Aseet(); 129 137 LisääOhjaimet(); … … 137 145 while (i < Vihollisia) 138 146 { 139 vihollinenV1 147 vihollinenV1(Level.Right - 30, RandomGen.NextDouble(Level.Bottom + 30, Level.Top - 30)); 140 148 i++; 141 149 } 142 150 143 144 } 151 152 } 153 145 154 void AlustaPeli2() 146 155 { … … 167 176 168 177 } 178 169 179 void Ohje() 170 180 { … … 176 186 177 187 } 188 178 189 void LuoKenttä() 179 190 { … … 186 197 187 198 Label Pistenaytto = new Label(); 188 Pistenaytto.X = Level.Right + 7;189 Pistenaytto.Y = Level.Top - 30;199 Pistenaytto.X = Level.Right - 70; 200 Pistenaytto.Y = Level.Top - 65; 190 201 Pistenaytto.TextColor = Color.White; 191 202 Pistenaytto.Color = Color.Red; … … 195 206 196 207 Label Pisteteksti = new Label("Tuhottu:"); 197 Pisteteksti.X = Level.Right + 7;198 Pisteteksti.Y = Level.Top - 5;208 Pisteteksti.X = Level.Right - 70; 209 Pisteteksti.Y = Level.Top - 40; 199 210 Pisteteksti.TextColor = Color.White; 200 211 Pisteteksti.Color = Color.Red; … … 203 214 204 215 } 216 205 217 void Pelaaja() 206 218 { … … 211 223 pelaaja.Y = -30; 212 224 pelaaja.Tag = "pelaaja"; 213 Add 225 Add(pelaaja); 214 226 pelaaja.LinearDamping = 0.9; 215 227 pelaaja.Restitution = 1.0; … … 218 230 Elamat = new DoubleMeter(100); 219 231 Elamat.MaxValue = 100; 220 Elamat.LowerLimit += GameOver;232 Elamat.LowerLimit += P1kuoli; 221 233 222 234 ProgressBar ElämäPalkki = new ProgressBar(150, 10); 223 235 ElämäPalkki.BindTo(Elamat); 224 ElämäPalkki.X = Level.Left - 50;225 ElämäPalkki.Y = Level.Top - 5;236 ElämäPalkki.X = Level.Left + 100; 237 ElämäPalkki.Y = Level.Top - 40; 226 238 ElämäPalkki.BarColor = Color.Red; 227 239 ElämäPalkki.BorderColor = Color.Green; … … 233 245 AddCollisionHandler(pelaaja, "PowerUp", PowerUpit); 234 246 } 247 235 248 void Pelaaja2() 236 249 { … … 246 259 pelaaja2.CanRotate = false; 247 260 248 Elamat = new DoubleMeter(100);249 Elamat .MaxValue = 100;250 Elamat .LowerLimit += GameOver;261 Elamat2 = new DoubleMeter(100); 262 Elamat2.MaxValue = 100; 263 Elamat2.LowerLimit += P2kuoli; 251 264 252 265 ProgressBar ElämäPalkki = new ProgressBar(150, 10); 253 ElämäPalkki.BindTo(Elamat );254 ElämäPalkki.X = Level.Left + 2 00;255 ElämäPalkki.Y = Level.Top - 5;266 ElämäPalkki.BindTo(Elamat2); 267 ElämäPalkki.X = Level.Left + 270; 268 ElämäPalkki.Y = Level.Top - 40; 256 269 ElämäPalkki.BarColor = Color.Red; 257 270 ElämäPalkki.BorderColor = Color.Green; 258 271 Add(ElämäPalkki); 259 272 260 AddCollisionHandler(pelaaja2, "vihollinen1", VihollinenOsuuPelaajaan );261 AddCollisionHandler(pelaaja2, "vihollinen2", VihollinenOsuuPelaajaan );262 AddCollisionHandler(pelaaja2, "vihollinen3", VihollinenOsuuPelaajaan );273 AddCollisionHandler(pelaaja2, "vihollinen1", VihollinenOsuuPelaajaan2); 274 AddCollisionHandler(pelaaja2, "vihollinen2", VihollinenOsuuPelaajaan2); 275 AddCollisionHandler(pelaaja2, "vihollinen3", VihollinenOsuuPelaajaan2); 263 276 AddCollisionHandler(pelaaja2, "PowerUp", PowerUpit); 264 277 } 278 265 279 void LisääOhjaimet() 266 280 { … … 268 282 ControllerOne.Listen(Button.X, ButtonState.Down, Ampuminen, "ammu", pelaaja, Ase); 269 283 ControllerOne.Listen(Button.Start, ButtonState.Pressed, ConfirmExit, null); 270 271 272 273 274 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector( -5000, 0 ), pelaaja); 275 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector( 5000, 0 ), pelaaja); 276 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector( 0, 5000 ), pelaaja); 277 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector( 0, -5000 ), pelaaja); 278 Keyboard.Listen(Key.L, ButtonState.Down, Ampuminen, "ammu", pelaaja, Ase); 279 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 280 281 282 } 284 285 286 287 288 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, null, new Vector(-5000, 0), pelaaja); 289 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(5000, 0), pelaaja); 290 Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 5000), pelaaja); 291 Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -5000), pelaaja); 292 Keyboard.Listen(Key.L, ButtonState.Down, Ampuminen, "ammu", pelaaja, Ase); 293 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 294 295 296 } 297 283 298 void LisääOhjaimet2() 284 299 { … … 298 313 299 314 } 315 300 316 void LiikutaPelaajaa(Vector vektori, PhysicsObject pelaaja) 301 317 { 302 318 pelaaja.Push(vektori); 303 319 } 304 void LiikutaPelaajaa2 (AnalogState TatinTila, PhysicsObject pelaaja) 320 321 void LiikutaPelaajaa2(AnalogState TatinTila, PhysicsObject pelaaja) 305 322 { 306 323 Vector tatinAsento = TatinTila.StateVector; 307 pelaaja.Push(tatinAsento*5000); 308 } 324 pelaaja.Push(tatinAsento * 5000); 325 } 326 309 327 void Aseet() 310 328 { … … 316 334 pyssy.Power.DefaultValue = 500; 317 335 Ase = pyssy; 318 319 } 336 337 } 338 320 339 void Aseet2() 321 340 { … … 329 348 330 349 } 350 331 351 void LuotiOsuuViholliseen(PhysicsObject ammus, PhysicsObject kohde) 332 352 { … … 355 375 } 356 376 Add(rajahdys); 357 358 } 377 378 } 379 359 380 void KaikkiVihollisetTuhottu(int vihollisia) 360 381 { … … 364 385 365 386 } 387 366 388 void Ampuminen(PhysicsObject pelaaja, Weapon Ase) 367 389 { … … 377 399 } 378 400 } 401 379 402 void VihollinenOsuuPelaajaan(PhysicsObject pelaaja, PhysicsObject enemy) 380 403 { … … 393 416 394 417 ControllerOne.Vibrate(1.0, 1.0, 1.0, 1.0, 0.2); 418 419 } 420 421 void VihollinenOsuuPelaajaan2(PhysicsObject pelaaja2, PhysicsObject enemy) 422 { 423 if (enemy.Tag == "vihollinen3") 424 { 425 Elamat2.Value -= 30; 426 } 427 else if (enemy.Tag == "vihollinen2") 428 { 429 Elamat2.Value -= 20; 430 } 431 else if (enemy.Tag == "vihollinen1") 432 { 433 Elamat2.Value -= 10; 434 } 435 436 ControllerTwo.Vibrate(1.0, 1.0, 1.0, 1.0, 0.2); 437 } 438 439 void P1kuoli(double ElamatLopussa) 440 { 441 Explosion rajahdys2 = new Explosion(100); 442 rajahdys2.Position = pelaaja.Position; 443 rajahdys2.Speed = 500.0; 444 rajahdys2.Force = 10000; 445 446 if (pelaaja2 != null) 447 { 448 rajahdys2.AddShockwaveHandler(pelaaja2, KumoaPaineaalto); 449 } 450 451 Add(rajahdys2); 452 pelaaja.Destroy(); 453 PeliLoppui(); 395 454 396 455 } 397 void GameOver(double Elämät) 398 { 399 if (peliLoppui) return; 400 { 401 MultiSelectWindow PeliLoppui = new MultiSelectWindow ("Kuolit", 402 "Uudestaan", "Poistu"); 403 PeliLoppui.ItemSelected += PainettiinValikon3Nappia; 404 Add (PeliLoppui); 405 } 406 } 456 457 void KumoaPaineaalto(IPhysicsObject pelaaja, Vector voima) 458 { 459 pelaaja.Hit(-voima); 460 } 461 462 void P2kuoli(double Elamat2Lopussa) 463 { 464 Explosion rajahdys2 = new Explosion(100); 465 rajahdys2.Position = pelaaja2.Position; 466 rajahdys2.Speed = 500.0; 467 rajahdys2.Force = 10000; 468 rajahdys2.AddShockwaveHandler(pelaaja, KumoaPaineaalto); 469 Add(rajahdys2); 470 pelaaja2.Destroy(); 471 PeliLoppui(); 472 } 473 474 void PeliLoppui() 475 { 476 if (pelaaja.IsDestroyed && (pelaaja2 == null || pelaaja2.IsDestroyed)) 477 { 478 HighScoreWindow(); 479 } 480 } 481 407 482 void PainettiinValikon3Nappia(int valinta3) 408 483 { … … 417 492 } 418 493 } 494 419 495 void HighScoreWindow() 420 { 421 HighScoreWindow topIkkuna = new HighScoreWindow( 422 "Parhaat pisteet", 423 "Onneksi olkoon, pääsit listalle tapoilla %p! Syötä nimesi:", 424 TopLista, VihollisiaTuhottu.Value); 496 { 497 498 499 HighScoreWindow topIkkuna = new HighScoreWindow( 500 "Parhaat pisteet", 501 "Onneksi olkoon, pääsit listalle tapoilla %p! Syötä nimesi:", 502 TopLista, VihollisiaTuhottu.Value); 425 503 topIkkuna.Closed += TallennaPisteet; 426 504 Add(topIkkuna); 427 505 peliLoppui = true; 428 } 506 507 if (peliLoppui) return; 508 { 509 MultiSelectWindow PeliLoppui = new MultiSelectWindow("", 510 "Uudestaan", "Poistu"); 511 PeliLoppui.ItemSelected += PainettiinValikon3Nappia; 512 PeliLoppui.X = 0; 513 PeliLoppui.Y = -100; 514 Add(PeliLoppui); 515 } 516 517 //viholliset 518 } 519 429 520 void TallennaPisteet(Window sender) 430 521 { … … 434 525 435 526 } 527 436 528 void LisaaVihollisia() 437 529 { … … 442 534 vihollisiaV3 = vihollisiaV3 + 5; 443 535 } 444 536 445 537 if (KierrosLaskuri.Value >= 4) 446 538 { … … 466 558 } 467 559 } 560 468 561 void LuoKierrosLaskuri() 469 562 { 470 563 KierrosLaskuri = new IntMeter(1); 471 564 Label KierrosNaytto = new Label(); 472 KierrosNaytto.X = Level.Center.X - 100;473 KierrosNaytto.Y = Level.Top - 5;565 KierrosNaytto.X = Level.Center.X; 566 KierrosNaytto.Y = Level.Top - 40; 474 567 KierrosNaytto.TextColor = Color.White; 475 568 KierrosNaytto.Color = Color.Red; 476 569 KierrosNaytto.Title = "Kierros"; 477 570 KierrosNaytto.BindTo(KierrosLaskuri); 478 Add (KierrosNaytto); 479 } 571 Add(KierrosNaytto); 572 } 573 480 574 void PowerUpit(PhysicsObject tormaaja, PhysicsObject kohde) 481 575 { 482 576 kohde.Destroy(); 483 577 484 578 int v = 0; 485 while (v<viholliset.Count)579 while (v < viholliset.Count) 486 580 { 487 581 viholliset[v].Destroy(); … … 492 586 viholliset.Clear(); 493 587 } 588 494 589 void Tormaykset() 495 590 { … … 497 592 498 593 } 594 499 595 void LuoPowerUpit() 500 596 { … … 503 599 PowerUp.Shape = Shape.Star; 504 600 PowerUp.Color = Color.Yellow; 505 PowerUp.Mass = 0;601 PowerUp.Mass = 0; 506 602 PowerUp.X = RandomGen.NextDouble(Level.Left + 30, Level.Right - 30); 507 603 PowerUp.Y = RandomGen.NextDouble(Level.Bottom + 30, Level.Top - 30); 508 604 Add(PowerUp); 509 Timer.SingleShot(RandomGen.NextDouble(0, 20), LuoPowerUpit); 605 Timer.SingleShot(RandomGen.NextDouble(0, 20), LuoPowerUpit); 510 606 } 511 607 -
2012/24/AtteJ/Räiskintä-mättöpeli/Räiskintä-mättöpeli/Räiskintä-mättöpeli/bin/x86/Debug/Data/pisteet.xml
r3028 r3070 6 6 <Item Index="0" Type="Jypeli.ScoreItem, Jypeli, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null"> 7 7 <Field Name="Name" Type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 8 <Value> -</Value>8 <Value>atte</Value> 9 9 </Field> 10 10 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 11 <Value> 0</Value>11 <Value>160</Value> 12 12 </Field> 13 13 </Item> 14 14 <Item Index="1" Type="Jypeli.ScoreItem, Jypeli, Version=5.0.0.0, Culture=neutral, PublicKeyToken=null"> 15 15 <Field Name="Name" Type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 16 <Value> -</Value>16 <Value>atte</Value> 17 17 </Field> 18 18 <Field Name="Score" Type="System.Double, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 19 <Value> 0</Value>19 <Value>1</Value> 20 20 </Field> 21 21 </Item> … … 87 87 </Field> 88 88 <Field Name="LastEnteredName" Type="System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"> 89 <Value />89 <Value>atte</Value> 90 90 </Field> 91 91 </Object>
Note: See TracChangeset
for help on using the changeset viewer.