Changeset 4282
- Timestamp:
- 2013-06-27 15:08:34 (10 years ago)
- Location:
- 2012/09-22/SanteriH/Kynari
- Files:
-
- 10 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/09-22/SanteriH/Kynari/Kynari/Kynari/Kynari.cs
r4248 r4282 11 11 public bool DamageResistance { get; set; } 12 12 public bool voikoPoimiaAseen { get; set; } 13 public string varaAse; 13 14 public Explosion ViimeisinRajahdys { get; set; } 14 15 public DoubleMeter HPLaskuri { get; set; } … … 19 20 voikoPoimiaAseen = true; 20 21 DamageResistance = false; 22 varaAse = null; 21 23 } 22 24 } … … 36 38 string SailytaAse = "Kyllä"; 37 39 int PISTEMAARA_JOLLA_VOITTAA_PELIN = 3; 38 int HPMAARA = 100;40 int PHPMAARA = 100; 39 41 int HPBOOST = 25; 40 42 int kentta = 1; … … 42 44 int powerupmaara = 0; 43 45 int hpmaara = 0; 46 int CURRENTHP = 100; 47 int MAXHP = 100; 44 48 45 49 46 50 Pelaaja pelaaja1 = new Pelaaja(40, 40, Shape.Circle); 47 51 Pelaaja pelaaja2 = new Pelaaja(40, 40, Shape.Circle); 48 //DoubleMeter hpLaskuri1 = new DoubleMeter(100);49 //DoubleMeter hpLaskuri2 = new DoubleMeter(100);50 52 51 53 Image ammuslv4 = LoadImage("ammuslv4"); 54 Image portaalikuva = LoadImage("portal"); 52 55 Image hpkuva = LoadImage("health"); 53 56 Image kranaatinheittimenkuva = LoadImage("grenadelauncher"); … … 63 66 Image magnumkuva3 = LoadImage("magnum3"); 64 67 Image magnumkuva4 = LoadImage("magnum4"); 68 Image miekankuva = LoadImage("miekka"); 69 Image miekkahit = LoadImage("miekkaattack"); 65 70 Image norsu = LoadImage("norsu"); 71 Image norsu2 = LoadImage("norsu2"); 66 72 Image haulikonkuva = LoadImage("shotgun"); 67 73 Image haulikonkuva2 = LoadImage("shotgun2"); … … 88 94 Image sniperinkuva3 = LoadImage("sniper3"); 89 95 Image sniperinkuva4 = LoadImage("sniper4"); 96 Image target = LoadImage("target"); 90 97 Image powerupinkuva = LoadImage("upgrade"); 98 91 99 bool saaAmpua = false; 92 100 bool tasapeli = false; 93 //bool peliohi = false;94 101 95 102 SoundEffect hyppyAani = LoadSoundEffect("hyppays"); … … 116 123 void AloitaUusiPeli() 117 124 { 118 119 125 MessageDisplay.Clear(); 120 126 // ladataan kenttä 121 //seuraavaKentta();122 127 LuoKentta(); 123 128 lisaaNappaimet(); … … 125 130 LisaaHPNaytot(); 126 131 naytaTiedot(); 127 //peliohi = false;128 132 tasapeli = false; 129 133 saaAmpua = false; … … 138 142 #region KentanLataus 139 143 140 void LuoTaso ()144 void LuoTasoKentta() 141 145 { 142 146 ClearAll(); … … 150 154 ruudut.SetTileMethod('z', LuoLattia); 151 155 ruudut.SetTileMethod('c', LuoSeina); 152 156 ruudut.SetTileMethod('.', LuoKohde); 157 ruudut.SetTileMethod('w', LuoPortaali); 158 ruudut.SetTileMethod('v', LuoNorsuVihu, "Pistooli"); 159 //ruudut.SetTileMethod('m', LuoAse, new Vector(24, 24), "Miekka", miekankuva); 160 ruudut.SetTileMethod('A', LuoAse, new Vector(39, 13), "Kivääri", kivaarinkuva); 161 ruudut.SetTileMethod('G', LuoAse, new Vector(42, 15), "Kranaatinheitin", kranaatinheittimenkuva); 162 ruudut.SetTileMethod('S', LuoAse, new Vector(42, 10), "Haulikko", haulikonkuva); 163 ruudut.SetTileMethod('M', LuoAse, new Vector(17, 12), "Magnum", magnumkuva); 164 ruudut.SetTileMethod('R', LuoAse, new Vector(48, 15), "Raketinheitin", raketinheittimenkuva); 165 ruudut.SetTileMethod('U', LuoAse, new Vector(42, 11), "Sniper", sniperinkuva); 166 ruudut.SetTileMethod('1', delegate(Vector paikka, double leveys, double korkeus) { pelaaja1 = LuoYksinPelaaja(paikka, leveys, korkeus, Direction.Right, pelaaja1); }); 153 167 ruudut.Execute(RUUDUNLEVEYS, RUUDUNKORKEUS); 154 168 Level.Background.CreateGradient(Color.White, Color.Gray); 155 169 Gravity = new Vector(0, -1500); 170 Camera.Follow(pelaaja1); 156 171 } 157 172 … … 183 198 if (Aseet == "Kaikki aseet") { ruudut.SetTileMethod('R', LuoAse, new Vector(48, 15), "Raketinheitin", raketinheittimenkuva); } 184 199 if (Aseet == "Kaikki aseet") { ruudut.SetTileMethod('U', LuoAse, new Vector(42, 11), "Sniper", sniperinkuva); } 185 //if (PowerUpit == "Päällä") { ruudut.SetTileMethod('+', LuoPowerUp, new Vector(16, 20), "Power Up", powerupinkuva); }186 //if (HP == "Päällä") { ruudut.SetTileMethod('h', LuoHP, new Vector(20, 21), "HP", hpkuva); }187 200 ruudut.SetTileMethod('1', delegate(Vector paikka, double leveys, double korkeus) { pelaaja1 = LuoPelaaja(paikka, leveys, korkeus, Direction.Right, pelaaja1); }); 188 201 ruudut.SetTileMethod('2', delegate(Vector paikka, double leveys, double korkeus) { pelaaja2 = LuoPelaaja(paikka, leveys, korkeus, Direction.Left, pelaaja2); }); … … 276 289 } 277 290 291 void LuoPortaali(Vector paikka, double leveys, double korkeus) 292 { 293 PhysicsObject portal = new PhysicsObject(leveys, korkeus * 2); 294 portal.Position = paikka + new Vector(0, -korkeus * 0.5); 295 portal.Image = portaalikuva; 296 portal.Tag = "Portaali"; 297 portal.MakeStatic(); 298 Add(portal); 299 AddCollisionHandler(portal, "pelaaja", SeuraavaTaso); 300 } 301 278 302 void LuoLattia(Vector paikka, double leveys, double korkeus) 279 303 { … … 325 349 Add(taso); 326 350 } 327 351 void LuoKohde(Vector paikka, double leveys, double korkeus) 352 { 353 PhysicsObject kohde = new PhysicsObject(20, 20); 354 kohde.Position = paikka; 355 kohde.Image = target; 356 kohde.Tag = "Target"; 357 kohde.MakeStatic(); 358 Add(kohde); 359 AddCollisionHandler(kohde, "ammus", delegate (PhysicsObject o, PhysicsObject k) { TuhoaKohde(kohde); }); 360 } 361 void TuhoaKohde(PhysicsObject kohde) 362 { 363 kohde.Destroy(); 364 } 365 366 void LuoNorsuVihu(Vector paikka, double leveys, double korkeus, string ase) 367 { 368 Pelaaja norsu = new Pelaaja(35.0, 35.0, Shape.Circle); 369 norsu.Image = norsu2; 370 norsu.Tag = "Norsu"; 371 372 norsu.HPLaskuri = new DoubleMeter(45, 0, 45); 373 norsu.HPLaskuri.MaxValue = 45; 374 norsu.HPLaskuri.Value = 45; 375 norsu.HPLaskuri.LowerLimit += delegate() 376 { 377 NorsuKuoli(norsu); 378 }; 379 380 381 PlatformWandererBrain aivot = new PlatformWandererBrain(); 382 norsu.Brain = aivot; 383 aivot.Speed = 200; 384 aivot.JumpSpeed = 700; 385 386 Add(norsu); 387 LuoAsePelaajalle(ase, norsu); 388 } 328 389 329 390 void TarkistaReunat(double leveys, double korkeus) … … 364 425 ClearAll(); 365 426 MultiSelectWindow asetukset = new MultiSelectWindow("Asetukset", "Voittoon tarvittava pistemäärä: " + PISTEMAARA_JOLLA_VOITTAA_PELIN, 366 "Pelaajien HP määrä: " + HPMAARA, "Kentällä olevat aseet: " + Aseet, "Power Upit: " + PowerUpit, "HP Boostit: " + HP, "HP Boostin Määrä: " + HPBOOST, "Säilytä aseet erien välissä: " + SailytaAse, "Takaisin");427 "Pelaajien HP määrä: " + PHPMAARA, "Kentällä olevat aseet: " + Aseet, "Power Upit: " + PowerUpit, "HP Boostit: " + HP, "HP Boostin Määrä: " + HPBOOST, "Säilytä aseet erien välissä: " + SailytaAse, "Takaisin"); 367 428 asetukset.AddItemHandler(0, AsetaPistemaara); 368 429 asetukset.AddItemHandler(1, AsetaHP); … … 378 439 asetukset.DefaultCancel = 7; 379 440 Add(asetukset); 380 Timer.SingleShot(0.01, delegate 381 { 382 asetukset.SelectedIndex = valinta; 383 }); 384 385 441 asetukset.SelectedIndex = valinta; 386 442 387 443 ControllerTwo.Listen(Button.DPadUp, ButtonState.Pressed, delegate { asetukset.SelectedIndex = (asetukset.Buttons.Length + asetukset.SelectedIndex - 1) % asetukset.Buttons.Length; }, null).InContext(asetukset); … … 492 548 void AsetaHP() 493 549 { 494 if ( HPMAARA == 1)495 { 496 HPMAARA = 50;550 if (PHPMAARA == 1) 551 { 552 PHPMAARA = 50; 497 553 LuoAsetukset(1); 498 554 return; 499 555 } 500 if ( HPMAARA == 50)501 { 502 HPMAARA = 100;556 if (PHPMAARA == 50) 557 { 558 PHPMAARA = 100; 503 559 LuoAsetukset(1); 504 560 return; 505 561 } 506 if ( HPMAARA == 100)507 { 508 HPMAARA = 150;562 if (PHPMAARA == 100) 563 { 564 PHPMAARA = 150; 509 565 LuoAsetukset(1); 510 566 return; 511 567 } 512 if ( HPMAARA == 150)513 { 514 HPMAARA = 200;568 if (PHPMAARA == 150) 569 { 570 PHPMAARA = 200; 515 571 LuoAsetukset(1); 516 572 return; 517 573 } 518 if ( HPMAARA == 200)519 { 520 HPMAARA = 250;574 if (PHPMAARA == 200) 575 { 576 PHPMAARA = 250; 521 577 LuoAsetukset(1); 522 578 return; 523 579 } 524 if ( HPMAARA == 250)525 { 526 HPMAARA = 500;580 if (PHPMAARA == 250) 581 { 582 PHPMAARA = 500; 527 583 LuoAsetukset(1); 528 584 return; 529 585 } 530 if ( HPMAARA == 500)531 { 532 HPMAARA = 1000;586 if (PHPMAARA == 500) 587 { 588 PHPMAARA = 1000; 533 589 LuoAsetukset(1); 534 590 return; 535 591 } 536 if ( HPMAARA == 1000)537 { 538 HPMAARA = 1;592 if (PHPMAARA == 1000) 593 { 594 PHPMAARA = 1; 539 595 LuoAsetukset(1); 540 596 return; … … 542 598 else 543 599 { 544 HPMAARA = 100;600 PHPMAARA = 100; 545 601 LuoAsetukset(1); 546 602 } … … 704 760 } 705 761 762 void SeuraavaTaso( PhysicsObject tormaaja, PhysicsObject kohde ) 763 { 764 Pelaaja pelaaja = tormaaja as Pelaaja; 765 766 if (taso == 0) { LuoTaso1(); } 767 } 768 706 769 void LuoTaso0() 707 770 { 708 771 taso = 0; 772 uusiYksinPeli(); 773 } 774 775 void LuoTaso1() 776 { 777 taso = 1; 709 778 uusiYksinPeli(); 710 779 } … … 762 831 } 763 832 833 void LisaaHPNaytto() 834 { 835 hpNaytto = new ProgressBar(250, 30); 836 hpNaytto.BarColor = Color.LightGreen; 837 hpNaytto.Color = Color.Red; 838 hpNaytto.BindTo(pelaaja1.HPLaskuri); 839 hpNaytto.Position = new Vector(Screen.LeftSafe + 300, Screen.TopSafe - 170); 840 Add(hpNaytto); 841 842 Label hpNumeroLaskuri = new Label(); 843 hpNumeroLaskuri.DoubleFormatString = "{0:0}"; 844 hpNumeroLaskuri.BindTo(pelaaja1.HPLaskuri); 845 hpNumeroLaskuri.Position = new Vector(Screen.LeftSafe + 225, Screen.TopSafe - 170); 846 Add(hpNumeroLaskuri); 847 } 848 764 849 void LisaaHPNaytot() 765 850 { 766 851 // luodaan elämänäyttö 767 852 hpNaytto = new ProgressBar(250, 30); 768 //hpNaytto.Angle = Angle.FromDegrees(90);769 853 hpNaytto.BarColor = Color.LightGreen; 770 854 hpNaytto.Color = Color.Red; … … 835 919 } 836 920 837 //Vanha838 void Pelaaja1Voitti()839 {840 841 MessageDisplay.Clear();842 if (pelaaja1.IsDestroying && pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue)843 {844 MessageDisplay.Add("Tasapeli!");845 }846 else847 {848 MessageDisplay.Add("Pelaaja 1 voittaa!");849 }850 MessageDisplay.X = 0;851 }852 853 //Vanha854 void Pelaaja2Voitti()855 {856 MessageDisplay.Clear();857 if (pelaaja2.IsDestroying && pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue)858 {859 MessageDisplay.Add("Tasapeli!");860 }861 else862 {863 MessageDisplay.Add("Pelaaja 2 voittaa!");864 }865 MessageDisplay.X = 0;866 867 }868 869 921 void lisaaPieniTaso(double x, double y) 870 922 { … … 894 946 } 895 947 896 Pelaaja Luo Pelaaja(Vector paikka, double leveys, double korkeus, Direction suunta, Pelaaja pelaaja)948 Pelaaja LuoYksinPelaaja(Vector paikka, double leveys, double korkeus, Direction suunta, Pelaaja pelaaja) 897 949 { 898 950 string ase = "Pistooli"; … … 912 964 pelaaja.FacingDirection = suunta; 913 965 914 pelaaja.HPLaskuri = new DoubleMeter( HPMAARA, 0, HPMAARA);915 pelaaja.HPLaskuri.MaxValue = HPMAARA;916 pelaaja.HPLaskuri.Value = HPMAARA;966 pelaaja.HPLaskuri = new DoubleMeter(CURRENTHP, 0, MAXHP); 967 pelaaja.HPLaskuri.MaxValue = MAXHP; 968 pelaaja.HPLaskuri.Value = CURRENTHP; 917 969 pelaaja.HPLaskuri.LowerLimit += delegate() 918 970 { … … 923 975 LuoAsePelaajalle(ase, pelaaja); 924 976 return pelaaja; 977 } 978 979 Pelaaja LuoPelaaja(Vector paikka, double leveys, double korkeus, Direction suunta, Pelaaja pelaaja) 980 { 981 string ase = "Pistooli"; 982 if (pelaaja.Weapon != null && SailytaAse == "Kyllä") 983 { 984 ase = pelaaja.Weapon.Tag.ToString(); 985 if (ase.Length > 6 && ase.Substring(ase.Length - 5) == "Lv. 4") 986 { 987 ase = ase.Substring(0, ase.Length - 5) + "Lv. 3"; 988 } 989 990 } 991 pelaaja = new Pelaaja(40, 40, Shape.Circle); 992 pelaaja.Image = norsu; 993 pelaaja.Position = paikka; 994 pelaaja.Tag = "pelaaja"; 995 pelaaja.FacingDirection = suunta; 996 997 pelaaja.HPLaskuri = new DoubleMeter(PHPMAARA, 0, PHPMAARA); 998 pelaaja.HPLaskuri.MaxValue = PHPMAARA; 999 pelaaja.HPLaskuri.Value = PHPMAARA; 1000 pelaaja.HPLaskuri.LowerLimit += delegate() 1001 { 1002 PelaajaKuoli(pelaaja); 1003 }; 1004 Add(pelaaja); 1005 1006 LuoAsePelaajalle(ase, pelaaja); 1007 return pelaaja; 1008 } 1009 1010 void NorsuKuoli(Pelaaja norsu) 1011 { 1012 norsu.Destroy(); 1013 PudotaAseenHahmo(norsu); 925 1014 } 926 1015 … … 957 1046 else if (pelaajan2Pisteet.Value == pelaajan2Pisteet.MaxValue) 958 1047 { 959 Pelaaja 2Voitti();1048 PelaajaVoittaa(pelaaja2, "Pelaaja 2", pelaaja1, pelaajan1Pisteet); 960 1049 ClearTimers(); 961 1050 Timer.SingleShot(3.0, delegate { LuoVoittoRuutu("Pelaaja 2 voitti pelin!"); }); … … 983 1072 else if (pelaajan1Pisteet.Value == pelaajan1Pisteet.MaxValue) 984 1073 { 985 Pelaaja 1Voitti();1074 PelaajaVoittaa(pelaaja1, "Pelaaja 1", pelaaja2, pelaajan2Pisteet); 986 1075 ClearTimers(); 987 1076 Timer.SingleShot(3.0, delegate { LuoVoittoRuutu("Pelaaja 1 voitti pelin!"); }); … … 1011 1100 } 1012 1101 pelaaja.HPLaskuri.Value += HPBOOST; 1102 } 1103 1104 void vaihdaAse(Pelaaja pelaaja) 1105 { 1106 if (pelaaja.Weapon == null || pelaaja.Weapon.IsDestroyed) 1107 { 1108 return; 1109 } 1110 1111 string asetag = pelaaja.Weapon.Tag.ToString(); 1112 Image aseenKuva = pelaaja.Weapon.Image; 1113 Vector aseenkoko = pelaaja.Weapon.Size; 1114 if (asetag.Length > 6 && asetag.Substring(asetag.Length - 5) == "Lv. 4") 1115 { 1116 asetag = asetag.Substring(0, asetag.Length - 5) + "Lv. 3"; 1117 } 1118 pelaaja.Weapon.Destroy(); 1119 pelaaja.Clear(); 1120 pelaaja.Weapon.Tag = null; 1121 1122 LuoAsePelaajalle(pelaaja.varaAse, pelaaja); 1123 naytaTiedot(); 1124 1125 1126 //string aseenTagi = pelaaja.Weapon.Tag.ToString(); 1127 //if (aseenTagi != null && aseenTagi.Length > 6 && aseenTagi.Substring(aseenTagi.Length - 5) == "Lv. 4") 1128 //{ 1129 // aseenTagi = aseenTagi.Substring(0, aseenTagi.Length - 5) + "Lv. 3"; 1130 //} 1131 1132 GameObject ase = new GameObject(0, 0); 1133 ase.Image = aseenKuva; 1134 ase.X = -20; 1135 ase.Y = 0; 1136 ase.Tag = asetag; 1137 ase.Image = aseenKuva; 1138 ase.Size = aseenkoko; 1139 ase.Angle = Angle.FromDegrees(90); 1140 pelaaja.varaAse = asetag; 1141 1142 pelaaja.Add(ase); 1013 1143 } 1014 1144 … … 1261 1391 void PistooliOsui(PhysicsObject ammus, PhysicsObject kohde) 1262 1392 { 1263 //if (ammus.IsDestroying) return;1264 //if (kohde.Tag.ToString() != "ammus" && kohde.Tag.ToString() != "") ammus.Destroy();1265 //if (!(kohde is Pelaaja)) return;1266 1393 if (AmmusVoiOsua(ammus, kohde)) 1267 1394 { … … 1279 1406 void PistooliOsui2(PhysicsObject ammus, PhysicsObject kohde) 1280 1407 { 1281 //if (ammus.IsDestroying) return;1282 //if (kohde.Tag.ToString() != "ammus" && kohde.Tag.ToString() != "") ammus.Destroy();1283 //if (!(kohde is Pelaaja)) return;1284 1408 if (AmmusVoiOsua(ammus, kohde)) 1285 1409 { … … 1297 1421 void PistooliOsui3(PhysicsObject ammus, PhysicsObject kohde) 1298 1422 { 1299 //if (ammus.IsDestroying) return;1300 //if (kohde.Tag.ToString() != "ammus" && kohde.Tag.ToString() != "") ammus.Destroy();1301 //if (!(kohde is Pelaaja)) return;1302 1423 if (AmmusVoiOsua(ammus, kohde)) 1303 1424 { … … 1316 1437 void KivaariOsui(PhysicsObject ammus, PhysicsObject kohde) 1317 1438 { 1318 //if (ammus.IsDestroying) return;1319 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1320 //if (!(kohde is Pelaaja)) return;1321 1439 if (AmmusVoiOsua(ammus, kohde)) 1322 1440 { … … 1334 1452 void KivaariOsui2(PhysicsObject ammus, PhysicsObject kohde) 1335 1453 { 1336 //if (ammus.IsDestroying) return;1337 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1338 //if (!(kohde is Pelaaja)) return;1339 1454 if (AmmusVoiOsua(ammus, kohde)) 1340 1455 { … … 1352 1467 void KivaariOsui3(PhysicsObject ammus, PhysicsObject kohde) 1353 1468 { 1354 //if (ammus.IsDestroying) return;1355 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1356 //if (!(kohde is Pelaaja)) return;1357 1469 if (AmmusVoiOsua(ammus, kohde)) 1358 1470 { … … 1371 1483 void SniperOsui(PhysicsObject ammus, PhysicsObject kohde) 1372 1484 { 1373 //if (ammus.IsDestroying) return;1374 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1375 //if (!(kohde is Pelaaja)) return;1376 1485 if (AmmusVoiOsua(ammus, kohde)) 1377 1486 { … … 1389 1498 void SniperOsui2(PhysicsObject ammus, PhysicsObject kohde) 1390 1499 { 1391 //if (ammus.IsDestroying) return;1392 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1393 //if (!(kohde is Pelaaja)) return;1394 1500 if (AmmusVoiOsua(ammus, kohde)) 1395 1501 { … … 1407 1513 void SniperOsui3(PhysicsObject ammus, PhysicsObject kohde) 1408 1514 { 1409 //if (ammus.IsDestroying) return;1410 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1411 //if (!(kohde is Pelaaja)) return;1412 1515 if (AmmusVoiOsua(ammus, kohde)) 1413 1516 { … … 1425 1528 void SniperOsui4(PhysicsObject ammus, PhysicsObject kohde) 1426 1529 { 1427 //if (ammus.IsDestroying) return;1428 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1429 //if (!(kohde is Pelaaja)) return;1430 1530 if (AmmusVoiOsua(ammus, kohde)) 1431 1531 { … … 1444 1544 void MagnumOsui(PhysicsObject ammus, PhysicsObject kohde) 1445 1545 { 1446 //if (ammus.IsDestroying) return;1447 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1448 //if (!(kohde is Pelaaja)) return;1449 1546 if (AmmusVoiOsua(ammus, kohde)) 1450 1547 { … … 1462 1559 void MagnumOsui2(PhysicsObject ammus, PhysicsObject kohde) 1463 1560 { 1464 //if (ammus.IsDestroying) return;1465 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1466 //if (!(kohde is Pelaaja)) return;1467 1561 if (AmmusVoiOsua(ammus, kohde)) 1468 1562 { … … 1480 1574 void MagnumOsui3(PhysicsObject ammus, PhysicsObject kohde) 1481 1575 { 1482 //if (ammus.IsDestroying) return;1483 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1484 //if (!(kohde is Pelaaja)) return;1485 1576 if (AmmusVoiOsua(ammus, kohde)) 1486 1577 { … … 1498 1589 void MagnumOsui4(PhysicsObject ammus, PhysicsObject kohde) 1499 1590 { 1500 //if (ammus.IsDestroying) return;1501 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1502 //if (!(kohde is Pelaaja)) return;1503 1591 if (AmmusVoiOsua(ammus, kohde)) 1504 1592 { … … 1517 1605 void HaulikkoOsui(PhysicsObject ammus, PhysicsObject kohde) 1518 1606 { 1519 //if (ammus.IsDestroying) return;1520 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1521 //if (!(kohde is Pelaaja)) return;1522 1607 if (AmmusVoiOsua(ammus, kohde)) 1523 1608 { … … 1535 1620 void HaulikkoOsui2(PhysicsObject ammus, PhysicsObject kohde) 1536 1621 { 1537 //if (ammus.IsDestroying) return;1538 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1539 //if (!(kohde is Pelaaja)) return;1540 1622 if (AmmusVoiOsua(ammus, kohde)) 1541 1623 { … … 1553 1635 void HaulikkoOsui3(PhysicsObject ammus, PhysicsObject kohde) 1554 1636 { 1555 //if (ammus.IsDestroying) return;1556 //if ((string)kohde.Tag != "ammus") ammus.Destroy();1557 //if (!(kohde is Pelaaja)) return;1558 1637 if (AmmusVoiOsua(ammus, kohde)) 1559 1638 { … … 1566 1645 { 1567 1646 p.HPLaskuri.Value -= 15; 1647 } 1648 } 1649 } 1650 1651 void MiekkaOsui(PhysicsObject ammus, PhysicsObject kohde) 1652 { 1653 if (AmmusVoiOsua(ammus, kohde)) 1654 { 1655 Pelaaja p = (Pelaaja)kohde; 1656 if (p.DamageResistance == true) 1657 { 1658 p.HPLaskuri.Value -= 5; 1659 } 1660 else 1661 { 1662 p.HPLaskuri.Value -= 10; 1568 1663 } 1569 1664 } … … 1935 2030 } 1936 2031 1937 pelaaja.Weapon = ase; 2032 //Yksinpeli aseet 2033 if (aseenTag == "Miekka") 2034 { 2035 ase = new AssaultRifle(24, 24); 2036 ase.FireRate = 1; 2037 ase.ProjectileCollision = MiekkaOsui; 2038 ase.MaxAmmoLifetime = TimeSpan.FromSeconds(0.05); 2039 ase.Tag = "Miekka"; 2040 ase.X = 10; 2041 ase.Y = 10; 2042 2043 } 2044 if(ase != null) 2045 pelaaja.Weapon = ase; 1938 2046 } 1939 2047 … … 1941 2049 { 1942 2050 if (aseenTag == null) return; 1943 1944 //string[] a = "Pistooli-2".Split('-');1945 2051 1946 2052 if (aseenTag == "Kivääri") … … 2223 2329 #region Nappaimet 2224 2330 // Lisää peliin kaikki näppäimet 2225 void lisaaNappaimet() 2331 2332 void lisaaYksinNappaimet() 2226 2333 { 2227 2334 ClearControls(); 2228 //Yleiset näppäimet2229 //Keyboard.Listen(Key.F1, ButtonState.Pressed, uusiPeli, "Aloittaa uuden pelin");2230 2231 // Pelaajan näppäimet2232 2233 2335 Keyboard.Listen(Key.A, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, new Vector(-LIIKEVOIMA, 0)); 2234 2336 Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1, new Vector(LIIKEVOIMA, 0)); 2235 2337 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1, HYPPYVOIMA); 2236 2338 Keyboard.Listen(Key.Space, ButtonState.Down, Ammu, "Ammu", pelaaja1); 2237 Keyboard.Listen(Key.LeftShift, ButtonState.Down, LukitseSuunta, "Lukitse suunta", pelaaja1); 2238 Keyboard.Listen(Key.LeftShift, ButtonState.Pressed, ValitseSuunta, "Valitse lukittava suunta", pelaaja1); 2339 Keyboard.Listen(Key.LeftShift, ButtonState.Pressed, LukitseSuunta, "Lukitse suunta", pelaaja1); 2340 Keyboard.Listen(Key.LeftShift, ButtonState.Released, PoistaLukitus, "Poista lukitus", pelaaja1); 2341 Keyboard.Listen(Key.E, ButtonState.Pressed, vaihdaAse, "Vaihda ase", pelaaja1); 2342 2343 Keyboard.Listen(Key.Escape, ButtonState.Pressed, YksinPeliPauselle, "Pysäyttää pelin", pelaaja1); 2344 2345 lisaaYksinGamePadNappaimet(ControllerOne, pelaaja1); 2346 2347 //Admin 2348 Keyboard.Listen(Key.F1, ButtonState.Pressed, LuoTaso1, null); 2349 } 2350 2351 void lisaaNappaimet() 2352 { 2353 ClearControls(); 2354 // Pelaajan näppäimet 2355 2356 Keyboard.Listen(Key.A, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja1, new Vector(-LIIKEVOIMA, 0)); 2357 Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", pelaaja1, new Vector(LIIKEVOIMA, 0)); 2358 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja1, HYPPYVOIMA); 2359 Keyboard.Listen(Key.Space, ButtonState.Down, Ammu, "Ammu", pelaaja1); 2360 Keyboard.Listen(Key.LeftShift, ButtonState.Pressed, LukitseSuunta, "Lukitse suunta", pelaaja1); 2361 Keyboard.Listen(Key.LeftShift, ButtonState.Released, PoistaLukitus, "Poista lukitus", pelaaja1); 2239 2362 2240 2363 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Liikkuu vasemmalle", pelaaja2, new Vector(-LIIKEVOIMA, 0)); … … 2242 2365 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", pelaaja2, HYPPYVOIMA); 2243 2366 Keyboard.Listen(Key.RightControl, ButtonState.Down, Ammu, "Ammu", pelaaja2); 2244 Keyboard.Listen(Key.RightShift, ButtonState. Down, LukitseSuunta, "Lukitse suunta", pelaaja2);2245 Keyboard.Listen(Key.RightShift, ButtonState. Pressed, ValitseSuunta, "Valitse lukittava suunta", pelaaja2);2367 Keyboard.Listen(Key.RightShift, ButtonState.Pressed, LukitseSuunta, "Lukitse suunta", pelaaja2); 2368 Keyboard.Listen(Key.RightShift, ButtonState.Released, PoistaLukitus, "Poista lukitus", pelaaja2); 2246 2369 2247 2370 Keyboard.Listen(Key.Escape, ButtonState.Pressed, PeliPauselle, "Pysäyttää pelin", pelaaja1); … … 2250 2373 lisaaGamePadNappaimet(ControllerTwo, pelaaja2); 2251 2374 } 2252 2375 2253 2376 void LukitseSuunta(Pelaaja pelaaja) 2254 2377 { 2255 if (pelaaja.lukittuSuunta == Direction.Left) 2256 { 2257 pelaaja.Turn(Direction.Left); 2258 } 2259 if (pelaaja.lukittuSuunta == Direction.Right) 2260 { 2261 pelaaja.Turn(Direction.Right); 2262 } 2263 } 2264 2265 void ValitseSuunta(Pelaaja pelaaja) 2266 { 2267 pelaaja.lukittuSuunta = pelaaja.FacingDirection; 2268 } 2269 2270 void lisaaGamePadNappaimet(GamePad pelaajaNro, Pelaaja pelaaja) 2378 pelaaja.TurnsWhenWalking = false; 2379 } 2380 2381 void PoistaLukitus(Pelaaja pelaaja) 2382 { 2383 pelaaja.TurnsWhenWalking = true; 2384 } 2385 2386 void lisaaYksinGamePadNappaimet(GamePad pelaajaNro, Pelaaja pelaaja) 2271 2387 { 2272 2388 //Yleiset näppäimet … … 2277 2393 pelaajaNro.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja, HYPPYVOIMA); 2278 2394 pelaajaNro.Listen(Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", pelaaja); 2279 pelaajaNro.Listen(Button.LeftTrigger, ButtonState.Down, LukitseSuunta, "Lukitse suunta", pelaaja); 2280 pelaajaNro.Listen(Button.LeftTrigger, ButtonState.Pressed, ValitseSuunta, "Valitse lukittava suunta", pelaaja); 2395 pelaajaNro.Listen(Button.LeftTrigger, ButtonState.Pressed, LukitseSuunta, "Lukitse suunta", pelaaja); 2396 pelaajaNro.Listen(Button.LeftTrigger, ButtonState.Released, PoistaLukitus, "Poista lukitus", pelaaja); 2397 2398 pelaajaNro.Listen(Button.Start, ButtonState.Pressed, YksinPeliPauselle, "Pysäyttää pelin", pelaaja); 2399 } 2400 2401 void lisaaGamePadNappaimet(GamePad pelaajaNro, Pelaaja pelaaja) 2402 { 2403 //Yleiset näppäimet 2404 2405 LiikutaPelaajaa(pelaajaNro, pelaaja); 2406 pelaajaNro.Listen(Button.DPadLeft, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", pelaaja, new Vector(-LIIKEVOIMA, 0)); 2407 pelaajaNro.Listen(Button.DPadRight, ButtonState.Down, liikuta, "Pelaaja liikkuu oikealle", pelaaja, new Vector(LIIKEVOIMA, 0)); 2408 pelaajaNro.Listen(Button.A, ButtonState.Pressed, hyppaa, "Pelaaja hyppää", pelaaja, HYPPYVOIMA); 2409 pelaajaNro.Listen(Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", pelaaja); 2410 pelaajaNro.Listen(Button.LeftTrigger, ButtonState.Pressed, LukitseSuunta, "Lukitse suunta", pelaaja); 2411 pelaajaNro.Listen(Button.LeftTrigger, ButtonState.Released, PoistaLukitus, "Poista lukitus", pelaaja); 2281 2412 2282 2413 pelaajaNro.Listen(Button.Start, ButtonState.Pressed, PeliPauselle, "Pysäyttää pelin", pelaaja); … … 2288 2419 } 2289 2420 2421 void YksinPeliPauselle(PlatformCharacter pelaaja) 2422 { 2423 Pause(); 2424 MultiSelectWindow PauseValikko = new MultiSelectWindow("Kynäri", 2425 "Jatka peliä", "Aloita taso alusta", "Päävalikko", "Lopeta"); 2426 Add(PauseValikko); 2427 PauseValikko.AddItemHandler(0, Pause); 2428 PauseValikko.AddItemHandler(1, delegate { uusiYksinPeli(); Pause(); }); 2429 PauseValikko.AddItemHandler(2, delegate { LuoAlkuValikko(); Pause(); }); 2430 PauseValikko.AddItemHandler(3, Exit); 2431 PauseValikko.DefaultCancel = 0; 2432 PauseValikko.Color = Color.Gray; 2433 2434 ControllerOne.Listen(Button.Start, ButtonState.Pressed, delegate { PauseValikko.Close(); Pause(); }, null).InContext(PauseValikko); 2435 ControllerOne.Listen(Button.B, ButtonState.Pressed, delegate { PauseValikko.Close(); Pause(); }, null).InContext(PauseValikko); 2436 } 2290 2437 2291 2438 void PeliPauselle(PlatformCharacter pelaaja) … … 2350 2497 void Ammu(PlatformCharacter hahmo) 2351 2498 { 2352 if (hahmo.IsDestroyed || !saaAmpua) return;2499 if (hahmo.IsDestroyed || !saaAmpua || hahmo.Weapon.IsDestroyed == true) return; 2353 2500 PhysicsObject ammus = hahmo.Weapon.Shoot(); 2354 2501 if (ammus == null) return; … … 2357 2504 ammus.IgnoresCollisionResponse = true; 2358 2505 ammus.IgnoresExplosions = true; 2506 2359 2507 string aseenTag = hahmo.Weapon.Tag.ToString(); 2360 2361 2508 if (aseenTag.Length > 6 && aseenTag.Substring(aseenTag.Length - 5) == "Lv. 4") 2362 2509 { … … 2592 2739 ammus2.Velocity = ammus.Velocity; 2593 2740 ammus2.MaximumLifetime = ammus.MaximumLifetime; 2594 //ammus2.Hit(new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-200, 200)));2595 2741 ammus2.CollisionIgnorer = ammus.CollisionIgnorer; 2596 2742 ammus2.Tag = "ammus"; … … 2610 2756 ammus2.Velocity = ammus.Velocity; 2611 2757 ammus2.MaximumLifetime = ammus.MaximumLifetime; 2612 //ammus2.Hit(new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-200, 200)));2613 2758 ammus2.CollisionIgnorer = ammus.CollisionIgnorer; 2614 2759 ammus2.Tag = "ammus"; … … 2629 2774 void uusiYksinPeli() 2630 2775 { 2631 LuoTaso ();2776 LuoTasoKentta(); 2632 2777 NollaaLaskurit(); 2778 lisaaYksinNappaimet(); 2779 PHPMAARA = 100; 2780 HPBOOST = 25; 2781 LisaaHPNaytto(); 2782 2783 2784 saaAmpua = false; 2785 Timer.SingleShot(0.1, delegate 2786 { 2787 saaAmpua = true; 2788 }); 2633 2789 } 2634 2790 -
2012/09-22/SanteriH/Kynari/Kynari/Kynari/Kynari.csproj.Debug.cachefile
r4248 r4282 50 50 Content\taso1.xnb 51 51 Content\taso0.xnb 52 Content\miekka.xnb 53 Content\miekkaattack.xnb 54 Content\target.xnb 55 Content\portal.xnb 56 Content\norsu2.xnb 52 57 Content\tausta.wma 53 58 Content\kentta1.txt -
2012/09-22/SanteriH/Kynari/Kynari/Kynari/bin/x86/Debug/Jypeli.xml
r4248 r4282 6974 6974 </summary> 6975 6975 </member> 6976 <member name="P:Jypeli.Widgets.MultiSelectWindow.RememberSelection"> 6977 <summary> 6978 Muistetaanko missÀ kohtaa kursori oli viime kerralla kun ikkuna nÀytettiin. 6979 </summary> 6980 </member> 6976 6981 <member name="E:Jypeli.Widgets.MultiSelectWindow.ItemSelected"> 6977 6982 <summary> … … 10434 10439 </summary> 10435 10440 </member> 10441 <member name="P:PlatformCharacter.TurnsWhenWalking"> 10442 <summary> 10443 KÀÀntyykö hahmo automaattisesti kun se kÀvelee. 10444 </summary> 10445 </member> 10436 10446 <member name="P:PlatformCharacter.Weapon"> 10437 10447 <summary> -
2012/09-22/SanteriH/Kynari/Kynari/Kynari/obj/x86/Debug/Kynari.csproj.FileListAbsolute.txt
r4248 r4282 60 60 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\taso1.xnb 61 61 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\taso0.xnb 62 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\miekka.xnb 63 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\miekkaattack.xnb 64 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\target.xnb 65 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\portal.xnb 66 C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\norsu2.xnb -
2012/09-22/SanteriH/Kynari/Kynari/Kynari/obj/x86/Debug/cachefile-{CE1DC0B1-C320-4A5D-86A8-6245AF0207D1}-targetpath.txt
r4248 r4282 51 51 Content\taso1.xnb 52 52 Content\taso0.xnb 53 Content\miekka.xnb 54 Content\miekkaattack.xnb 55 Content\target.xnb 56 Content\portal.xnb 57 Content\norsu2.xnb 53 58 Content\kentta1.txt -
2012/09-22/SanteriH/Kynari/Kynari/KynariContent/KynariContent.contentproj
r4248 r4282 386 386 </Compile> 387 387 </ItemGroup> 388 <ItemGroup> 389 <Compile Include="miekka.png"> 390 <Name>miekka</Name> 391 <Importer>TextureImporter</Importer> 392 <Processor>TextureProcessor</Processor> 393 </Compile> 394 </ItemGroup> 395 <ItemGroup> 396 <Compile Include="miekkaattack.png"> 397 <Name>miekkaattack</Name> 398 <Importer>TextureImporter</Importer> 399 <Processor>TextureProcessor</Processor> 400 </Compile> 401 </ItemGroup> 402 <ItemGroup> 403 <Compile Include="target.png"> 404 <Name>target</Name> 405 <Importer>TextureImporter</Importer> 406 <Processor>TextureProcessor</Processor> 407 </Compile> 408 </ItemGroup> 409 <ItemGroup> 410 <Compile Include="portal.png"> 411 <Name>portal</Name> 412 <Importer>TextureImporter</Importer> 413 <Processor>TextureProcessor</Processor> 414 </Compile> 415 </ItemGroup> 416 <ItemGroup> 417 <Compile Include="norsu2.png"> 418 <Name>norsu2</Name> 419 <Importer>TextureImporter</Importer> 420 <Processor>TextureProcessor</Processor> 421 </Compile> 422 </ItemGroup> 388 423 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 389 424 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/09-22/SanteriH/Kynari/Kynari/KynariContent/obj/x86/Debug/ContentPipeline.xml
r4248 r4282 451 451 <Options>None</Options> 452 452 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\taso1.xnb</Output> 453 <Time>2013-06-2 5T13:14:13.8889563+03:00</Time>453 <Time>2013-06-27T13:40:38.7015777+03:00</Time> 454 454 </Item> 455 455 <Item> … … 460 460 <Options>None</Options> 461 461 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\taso0.xnb</Output> 462 <Time>2013-06-25T13:14:13.8889563+03:00</Time> 462 <Time>2013-06-27T12:40:31.3418778+03:00</Time> 463 </Item> 464 <Item> 465 <Source>miekka.png</Source> 466 <Name>miekka</Name> 467 <Importer>TextureImporter</Importer> 468 <Processor>TextureProcessor</Processor> 469 <Options>None</Options> 470 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\miekka.xnb</Output> 471 <Time>2013-06-27T10:26:50.621886+03:00</Time> 472 </Item> 473 <Item> 474 <Source>miekkaattack.png</Source> 475 <Name>miekkaattack</Name> 476 <Importer>TextureImporter</Importer> 477 <Processor>TextureProcessor</Processor> 478 <Options>None</Options> 479 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\miekkaattack.xnb</Output> 480 <Time>2013-06-27T10:56:19.748781+03:00</Time> 481 </Item> 482 <Item> 483 <Source>target.png</Source> 484 <Name>target</Name> 485 <Importer>TextureImporter</Importer> 486 <Processor>TextureProcessor</Processor> 487 <Options>None</Options> 488 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\target.xnb</Output> 489 <Time>2013-06-27T11:20:29.0506967+03:00</Time> 490 </Item> 491 <Item> 492 <Source>portal.png</Source> 493 <Name>portal</Name> 494 <Importer>TextureImporter</Importer> 495 <Processor>TextureProcessor</Processor> 496 <Options>None</Options> 497 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\portal.xnb</Output> 498 <Time>2013-06-27T12:00:14.2841962+03:00</Time> 499 </Item> 500 <Item> 501 <Source>norsu2.png</Source> 502 <Name>norsu2</Name> 503 <Importer>TextureImporter</Importer> 504 <Processor>TextureProcessor</Processor> 505 <Options>None</Options> 506 <Output>C:\MyTemp\SanteriH\Kynari\Kynari\Kynari\bin\x86\Debug\Content\norsu2.xnb</Output> 507 <Time>2013-06-27T12:48:29.401679+03:00</Time> 463 508 </Item> 464 509 <BuildSuccessful>true</BuildSuccessful> -
2012/09-22/SanteriH/Kynari/Kynari/KynariContent/taso0.txt
r4248 r4282 1 z######################################################### 2 c c 3 # # 4 # # 5 # # 6 # # 7 # # 8 # # 9 # # 10 # # 11 # # 12 # # 13 # # 14 # # 15 # # 16 # # 17 # # 18 # # 19 # # 20 # # 21 # # 22 # # 23 # # 24 # # 25 # # 26 # # 27 # # 28 # # 29 # # 30 # # 31 # # 32 # # 33 # # 34 z######################################################### 1 tttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttttt 2 t t t t 3 t t t t 4 t t t t 5 t tttttttttttttttttttttt t ttttttttttttttttttttttttt t t 6 t tt t .t t t 7 t t t t .t t t 8 t t t ttttttttttttttttttttttt tt t t 9 ttttttttttttttttttttt t t . tt t t 10 t t t . tt ttttttttttt 11 t t t tttttttttttttttttttttttttttttt wt 12 t 1 t t t t #t 13 z#########################################################tttttttttttttttttttttttttttttt -
2012/09-22/SanteriH/Kynari/Kynari/KynariContent/taso1.txt
r4248 r4282 1 z######################################################### 2 c c 3 # # 4 # # 5 # # 6 # # 7 # # 8 # # 9 # # 10 # # 11 # # 12 # # 13 # # 14 # # 15 # # 16 # # 17 # # 18 # # 19 # # 20 # # 21 # # 22 # # 23 # # 24 # # 25 # # 26 # # 27 # # 28 # # 29 # # 30 # # 31 # # 32 # # 33 # # 34 z######################################################### 1 t 2 t 3 t 4 t 5 t 6 t 7 t 8 t 9 t 10 t 11 t 12 t t 13 t 1 A tt v 14 z#########################################################tttttttttttttttttttttttttttttt
Note: See TracChangeset
for help on using the changeset viewer.