- Timestamp:
- 2013-07-02 14:59:07 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/27/NikoKi/EpicTankBattle/EpicTankBattle/EpicTankBattle/EpicTankBattle.cs
r4347 r4363 13 13 public bool saakohypata = true; 14 14 public IntMeter hp = new IntMeter(10, 0, 10); 15 public IntMeter a jastin = new IntMeter(0, 0, 100);16 public IntMeter hyppy ajastin= new IntMeter(100, 0, 100);15 public IntMeter ampumisajastin = new IntMeter(0, 0, 100); 16 public IntMeter hyppymittari = new IntMeter(100, 0, 100); 17 17 public Tankki(double leveys, double korkeus) 18 18 : base(leveys, korkeus) 19 19 { 20 ajastin.UpperLimit += lataa; 21 } 22 public void lataa() 20 ampumisajastin.UpperLimit += SalliAmpuminen; 21 hyppymittari.UpperLimit += SalliHyppy; 22 } 23 public void SalliAmpuminen() 23 24 { 24 25 saakoampua = true; 25 26 } 26 public void lataahyppya() 27 { 28 saakohypata = false; 29 } 30 31 27 28 public void SalliHyppy() 29 { 30 saakohypata = true; 31 } 32 32 } 33 33 … … 98 98 "Uusi peli", "Lopeta"); 99 99 Add(alkuValikko); 100 alkuValikko.ItemSelected += PainettiinValikonNappia; 100 alkuValikko.ItemSelected += PainettiinValikonNappia; 101 101 } 102 102 … … 116 116 void MaaperaValikko() 117 117 { 118 MultiSelectWindow MaaperaValikko = new MultiSelectWindow("Valitse kenttä", "Vuori", "Järvi", "Vesiputous", "Tulivuori");118 MultiSelectWindow MaaperaValikko = new MultiSelectWindow("Valitse kenttä", "Vuori", "Järvi", "Vesiputous", "Tulivuori"); 119 119 Add(MaaperaValikko); 120 120 MaaperaValikko.ItemSelected += PainettiinMaaperaValikonNappia; … … 124 124 ColorTileMap Ruudut; 125 125 126 string kartta = new string[] { "Maapera","Maapera2","Maapera3","Maapera4"}[MaaperanValinta];126 string kartta = new string[] { "Maapera", "Maapera2", "Maapera3", "Maapera4" }[MaaperanValinta]; 127 127 128 128 Ruudut = ColorTileMap.FromLevelAsset(kartta); … … 278 278 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 279 279 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Begin, "Lopeta peli"); 280 280 281 281 MediaPlayer.Play("8-Bit it is"); 282 282 MediaPlayer.IsRepeating = true; … … 316 316 oikeaReuna.Color = Color.Charcoal; 317 317 318 P1kehys = new Widget(400, 2 50);318 P1kehys = new Widget(400, 235); 319 319 P1kehys.X = Screen.Left + 200; 320 320 P1kehys.Y = Screen.Top - 55; … … 322 322 Add(P1kehys); 323 323 324 P2kehys = new Widget(400, 2 50);324 P2kehys = new Widget(400, 235); 325 325 P2kehys.X = Screen.Right - 200; 326 326 P2kehys.Y = Screen.Top - 55; … … 330 330 P1ammusruutu = new Widget(50, 50); 331 331 P1ammusruutu.X = Screen.Left + 325; 332 P1ammusruutu.Y = Screen.Top - 100;332 P1ammusruutu.Y = Screen.Top - 85; 333 333 VaihdaP1Asekuva(); 334 334 Add(P1ammusruutu); … … 336 336 P2ammusruutu = new Widget(50, 50); 337 337 P2ammusruutu.X = Screen.Right - 325; 338 P2ammusruutu.Y = Screen.Top - 100;338 P2ammusruutu.Y = Screen.Top - 85; 339 339 VaihdaP2Asekuva(); 340 Add(P2ammusruutu); 340 Add(P2ammusruutu); 341 341 342 342 ProgressBar p1hpPalkki = new ProgressBar(200, 20); … … 344 344 p1hpPalkki.BarColor = Color.LimeGreen; 345 345 p1hpPalkki.BorderColor = Color.Black; 346 p1hpPalkki.Color = Color. LightGray;346 p1hpPalkki.Color = Color.Silver; 347 347 p1hpPalkki.X = Screen.Left + 150; 348 p1hpPalkki.Y = Screen.Top - 50;348 p1hpPalkki.Y = Screen.Top - 35; 349 349 Add(p1hpPalkki); 350 350 351 351 ProgressBar P1ammusPalkki = new ProgressBar(200, 20); 352 P1ammusPalkki.BindTo(P1.a jastin);352 P1ammusPalkki.BindTo(P1.ampumisajastin); 353 353 P1ammusPalkki.X = Screen.Left + 150; 354 P1ammusPalkki.Y = Screen.Top - 100;354 P1ammusPalkki.Y = Screen.Top - 85; 355 355 P1ammusPalkki.BarColor = Color.Red; 356 356 P1ammusPalkki.BorderColor = Color.Black; 357 P1ammusPalkki.Color = Color. LightGray;357 P1ammusPalkki.Color = Color.Silver; 358 358 Add(P1ammusPalkki); 359 359 360 360 ProgressBar P1hyppyPalkki = new ProgressBar(200, 20); 361 P1hyppyPalkki.BindTo(P1.hyppy ajastin);361 P1hyppyPalkki.BindTo(P1.hyppymittari); 362 362 P1hyppyPalkki.X = Screen.Left + 150; 363 P1hyppyPalkki.Y = Screen.Top - 1 50;364 P1hyppyPalkki.BarColor = Color. Yellow;363 P1hyppyPalkki.Y = Screen.Top - 135; 364 P1hyppyPalkki.BarColor = Color.HanPurple; 365 365 P1hyppyPalkki.BorderColor = Color.Black; 366 P1hyppyPalkki.Color = Color. LightGray;366 P1hyppyPalkki.Color = Color.Silver; 367 367 Add(P1hyppyPalkki); 368 368 369 369 ProgressBar P2hyppyPalkki = new ProgressBar(200, 20); 370 P2hyppyPalkki.BindTo(P 1.hyppyajastin);370 P2hyppyPalkki.BindTo(P2.hyppymittari); 371 371 P2hyppyPalkki.X = Screen.Right - 150; 372 P2hyppyPalkki.Y = Screen.Top - 1 50;373 P2hyppyPalkki.BarColor = Color. Yellow;372 P2hyppyPalkki.Y = Screen.Top - 135; 373 P2hyppyPalkki.BarColor = Color.HanPurple; 374 374 P2hyppyPalkki.BorderColor = Color.Black; 375 P2hyppyPalkki.Color = Color. LightGray;375 P2hyppyPalkki.Color = Color.Silver; 376 376 Add(P2hyppyPalkki); 377 377 … … 381 381 p2hpPalkki.BarColor = Color.LimeGreen; 382 382 p2hpPalkki.BorderColor = Color.Black; 383 p2hpPalkki.Color = Color. LightGray;383 p2hpPalkki.Color = Color.Silver; 384 384 p2hpPalkki.X = Screen.Right - 150; 385 p2hpPalkki.Y = Screen.Top - 50;385 p2hpPalkki.Y = Screen.Top - 35; 386 386 Add(p2hpPalkki); 387 387 388 388 ProgressBar P2ammusPalkki = new ProgressBar(200, 20); 389 P2ammusPalkki.BindTo(P2.a jastin);389 P2ammusPalkki.BindTo(P2.ampumisajastin); 390 390 P2ammusPalkki.X = Screen.Right - 150; 391 P2ammusPalkki.Y = Screen.Top - 100;391 P2ammusPalkki.Y = Screen.Top - 85; 392 392 P2ammusPalkki.Angle += Angle.FromDegrees(180); 393 393 P2ammusPalkki.BarColor = Color.Red; 394 394 P2ammusPalkki.BorderColor = Color.Black; 395 P2ammusPalkki.Color = Color. LightGray;395 P2ammusPalkki.Color = Color.Silver; 396 396 Add(P2ammusPalkki); 397 397 … … 420 420 }); 421 421 }; 422 422 423 423 P2.hp.LowerLimit += delegate 424 424 { … … 466 466 hyppyajastin.Timeout += delegate 467 467 { 468 if (P1 != null) P1.hyppy ajastin.Value++;469 if (P2 != null) P2.hyppy ajastin.Value++;468 if (P1 != null) P1.hyppymittari.Value++; 469 if (P2 != null) P2.hyppymittari.Value++; 470 470 }; 471 hyppyajastin.Start(); 471 472 472 473 Timer ajastin = new Timer(); … … 474 475 ajastin.Timeout += delegate 475 476 { 476 if (P1 != null) P1.a jastin.Value++;477 if (P2 != null) P2.a jastin.Value++;477 if (P1 != null) P1.ampumisajastin.Value++; 478 if (P2 != null) P2.ampumisajastin.Value++; 478 479 }; 479 480 ajastin.Start(); … … 493 494 }; 494 495 vesiajastin.Start(); 495 496 496 497 } 497 498 … … 500 501 if (Tankki == P1) 501 502 { 502 P1.hp.Value -= 2;503 P1.hp.Value -= 1; 503 504 } 504 505 if (Tankki == P2) 505 506 { 506 P2.hp.Value -= 2;507 P2.hp.Value -= 1; 507 508 } 508 509 } … … 510 511 void Tankkiosuuveteen(PhysicsObject Tankki, PhysicsObject neliovesi) 511 512 { 512 Tankki.Velocity *= Tankki.Tag.ToString() == "ammus" ? 0.95 : 0.8;513 Tankki.Velocity *= Tankki.Tag.ToString() == "ammus" ? 0.95 : 0.8; 513 514 Tankki.Hit(new Vector(0, 42)); 514 515 } … … 549 550 PhysicsObject neliovesi = PhysicsObject.CreateStaticObject(leveys, korkeus); 550 551 neliovesi.Position = paikka; 551 neliovesi.Color = Color.Blue; //new Color(0, 0, 255, 128);552 neliovesi.Color = Color.Blue; 552 553 neliovesi.CollisionIgnoreGroup = 0; 553 554 neliovesi.IgnoresCollisionResponse = true; … … 561 562 PhysicsObject neliovesiB = PhysicsObject.CreateStaticObject(leveys, korkeus); 562 563 neliovesiB.Position = paikka; 563 neliovesiB.Color = Color.Blue; //new Color(0, 0, 255, 128);564 neliovesiB.Color = Color.Blue; 564 565 neliovesiB.CollisionIgnoreGroup = 0; 565 566 neliovesiB.IgnoresCollisionResponse = true; … … 616 617 Keyboard.Listen(Key.RightShift, ButtonState.Pressed, VaihdaP2, null); 617 618 618 Keyboard.Listen(Key.Tab, ButtonState.Pressed, HyppaaP1, null, P1, hyppy); 619 Keyboard.Listen(Key.Enter, ButtonState.Pressed, HyppaaP2, null, P2, hyppy); 620 } 621 622 void HyppaaP1( Tankki tankki, Vector hyppy) 623 { 624 tankki.Push(hyppy); 619 Keyboard.Listen(Key.Tab, ButtonState.Pressed, Hyppaa, null, P1, hyppy); 620 Keyboard.Listen(Key.Enter, ButtonState.Pressed, Hyppaa, null, P2, hyppy); 621 } 622 623 void Hyppaa(Tankki tankki, Vector hyppy) 624 { 625 625 if (tankki == P1 && P1.saakohypata) 626 626 { 627 P1.hyppyajastin.Value = 0; 627 tankki.Push(hyppy); 628 P1.hyppymittari.Value = 0; 628 629 P1.saakohypata = false; 629 630 } 630 } 631 632 void HyppaaP2(Tankki tankki, Vector hyppy) 633 { 634 tankki.Push(hyppy); 635 if (tankki == P2 && P2.saakohypata) 636 { 637 P2.hyppyajastin.Value = 0; 631 632 if (tankki == P2 && P2.saakohypata == true) 633 { 634 P2.hyppymittari.Value = 0; 638 635 P2.saakohypata = false; 639 } 640 } 636 tankki.Push(hyppy); 637 } 638 } 639 641 640 642 641 void LiikutaP1(Tankki tankki, Vector liike) … … 735 734 { 736 735 ammus = LuoAmmus[P1ammus](); 737 P1.a jastin.MaxValue = ammus.aika;738 P1.a jastin.Value = 0;736 P1.ampumisajastin.MaxValue = ammus.aika; 737 P1.ampumisajastin.Value = 0; 739 738 P1.saakoampua = false; 740 739 } … … 743 742 { 744 743 ammus = LuoAmmus[P2ammus](); 745 P2.a jastin.MaxValue = ammus.aika;746 P2.a jastin.Value = 0;744 P2.ampumisajastin.MaxValue = ammus.aika; 745 P2.ampumisajastin.Value = 0; 747 746 P2.saakoampua = false; 748 747 } … … 761 760 AddCollisionHandler(ammus, "neliokallio", Osuukallioon); 762 761 AddCollisionHandler(ammus, "ammus", Osuuammukseen); 763 AddCollisionHandler(ammus, "", CollisionHandler.DestroyObject); // seiniä varten 762 AddCollisionHandler(ammus, "", CollisionHandler.DestroyObject); // seiniä varten 764 763 AddCollisionHandler<PhysicsObject, Tankki>(ammus, "tankki", OsuuPelaajaan); 765 764 } … … 784 783 LuoRajahdys(Maa.Position, RajahdysKuva1, TankkiHuti); 785 784 } 786 787 //void Osuuveteen(PhysicsObject Ammus, PhysicsObject Ammus2);788 // Ammus.Destroy();789 785 790 786 void Osuuammukseen(PhysicsObject Ammus, PhysicsObject Ammus2)
Note: See TracChangeset
for help on using the changeset viewer.