- Timestamp:
- 2012-06-29 10:58:12 (11 years ago)
- Location:
- 2012/26/MikaL
- Files:
-
- 2 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/26/MikaL/Zombie Survival/Zombie Survival/Zombie Survival/Zombie_Survival.cs
r3322 r3379 10 10 class Zombi : PhysicsObject 11 11 { 12 public IntMeter zhp = new IntMeter(3,0,3);12 public DoubleMeter zhp = new DoubleMeter(15,0,15); 13 13 14 14 public Zombi(double leveys, double korkeus) 15 15 : base(leveys, korkeus) 16 16 { 17 zhp.LowerLimit += delegate { this.Destroy();}; 17 zhp.LowerLimit += delegate { Tuhoa(); }; 18 } 19 20 public void Tuhoa() 21 { 22 Zombie_Survival peli = (Zombie_Survival)PhysicsGame.Instance; 23 peli.killLaskuri.Value++; 24 peli.rahaLaskuri.Value += 50; 25 this.Destroy(); 26 peli.SpawnaaZombi(); 18 27 } 19 28 } … … 27 36 IntMeter p1_ammo; 28 37 IntMeter p1_lipas; 38 IntMeter p2_ammo; 39 IntMeter p2_lipas; 29 40 30 41 Label lataa; 31 32 IntMeter killLaskuri; 33 IntMeter rahaLaskuri; 42 Label lataa2; 43 44 public IntMeter killLaskuri; 45 public IntMeter rahaLaskuri; 34 46 IntMeter multiplayer; 35 47 … … 37 49 AssaultRifle ak1; 38 50 AssaultRifle ak2; 51 52 DoubleMeter p1_hp; 39 53 40 54 … … 57 71 Image zombie_skin = LoadImage("zombie_skin"); 58 72 73 List<Vector> zombipaikat; 74 59 75 public override void Begin() 60 76 { 61 SetWindowSize(1280, 1024, false); 62 if (DataStorage.Exists("pisteet.xml")) topLista = DataStorage.Load<ScoreList>(topLista, "scores.xml"); 77 zombipaikat = new List<Vector>(); 78 79 SetWindowSize(1024, 768, true); 80 if (DataStorage.Exists("scores.xml")) topLista = DataStorage.Load<ScoreList>(topLista, "scores.xml"); 63 81 64 82 multiplayer = new IntMeter(0); … … 73 91 void StartGame() 74 92 { 93 zombipaikat.Clear(); 75 94 ui(); 76 95 LuoMap(); … … 116 135 void LuoMap() 117 136 { 118 SetWindowSize(1 280, 1024, false);137 SetWindowSize(1024, 768, false); 119 138 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("map"); 120 139 ruudut.SetTileMethod(Color.Black, TeeSeina); … … 122 141 ruudut.SetTileMethod(Color.Blue, TeeP1); 123 142 if(multiplayer == 1) ruudut.SetTileMethod(Color.Yellow, TeeP2); 124 ruudut.SetTileMethod(Color.Green, ZombieSpawn);143 ruudut.SetTileMethod(Color.Green, TeeZombiPaikka); 125 144 ruudut.Execute(20, 20); 126 145 Level.CreateBorders(false); … … 179 198 ak2.Image = null; 180 199 ak2.Color = Color.Transparent; 200 ak1.ProjectileCollision = AmmusOsui; 201 ak1.Ammo.Value = p1_lipas.Value; 181 202 p2.Add(ak2); 182 203 } 183 void ZombieSpawn(Vector paikka, double leveys, double korkeus) 204 public void SpawnaaZombi() 205 { 206 //Tee ajastin 207 } 208 void TeeZombiPaikka(Vector paikka, double leveys, double korkeus) 209 { 210 zombipaikat.Add(paikka); 211 } 212 213 void LuoZombi() 184 214 { 185 215 Zombi z1 = new Zombi(45, 38); 186 z1.Position = paikka;216 z1.Position = RandomGen.SelectOne<Vector>(zombipaikat); 187 217 FollowerBrain zombinAivot = new FollowerBrain("living"); 188 218 z1.Shape = Shape.Circle; … … 240 270 Keyboard.Listen(Key.D, ButtonState.Released, AsetaNopeus, null, p1, Vector.Zero); 241 271 242 Keyboard.Listen(Key.Space, ButtonState.Pressed, AvaaOvi, null, p1);272 Keyboard.Listen(Key.Space, ButtonState.Pressed, Use, null, p1); 243 273 Mouse.Listen(MouseButton.Left, ButtonState.Down, Shoot, null, p1); 244 274 … … 260 290 ControllerOne.Listen(Button.DPadRight, ButtonState.Released, AsetaNopeus, null, p2, Vector.Zero); 261 291 262 ControllerOne.Listen(Button.Y, ButtonState.Pressed, AvaaOvi, null, p2);292 ControllerOne.Listen(Button.Y, ButtonState.Pressed, Use, null, p2); 263 293 264 294 } … … 267 297 268 298 //p1_hp 269 DoubleMeter p1_hp = new DoubleMeter(100);299 p1_hp = new DoubleMeter(5); 270 300 Label player1 = new Label("Player 1"); 271 301 player1.X = Screen.Left + 40; 272 302 player1.Y = Screen.Top - 15; 273 p1_hp.MaxValue = 100;303 p1_hp.MaxValue = 5; 274 304 ProgressBar p1_hpPalkki = new ProgressBar(170, 20); 275 305 p1_hpPalkki.BindTo(p1_hp); … … 288 318 p1_ammo_lipas.BindTo(p1_lipas); 289 319 p1_ammo_label.BindTo(p1_ammo); 290 p1_ammo_lipas.Y = Screen.Top - 60;291 p1_ammo_lipas.X = - 35;292 vali.Y = Screen.Top - 60;293 vali.X = - 20;294 p1_ammo_label.Y = Screen.Top - 60;295 p1_ammo_label.X = 5;320 p1_ammo_lipas.Y = Screen.Top - 50; 321 p1_ammo_lipas.X = - 100; 322 vali.Y = Screen.Top - 50; 323 vali.X = -85; 324 p1_ammo_label.Y = Screen.Top - 50; 325 p1_ammo_label.X = -60; 296 326 Add(p1_ammo_lipas); 297 327 Add(vali); 298 328 Add(p1_ammo_label); 299 329 330 300 331 //Ase 301 GameObject aseenkuva = new GameObject(90,27); 302 aseenkuva.Image = miniak; 303 aseenkuva.Y = Screen.Top - 15; 304 aseenkuva.X = -17; 305 Add(aseenkuva); 332 LuoAse(-100, Level.Top + 70); 333 LuoAse(Level.Left + 20, Level.Bottom + 100); 334 if(multiplayer == 1) LuoAse(+100, Level.Top + 70); 335 336 //GameObject aseenkuva = new GameObject(90,27); 337 //aseenkuva.Image = miniak; 338 //aseenkuva.Y = Level.Top +50; 339 //aseenkuva.X = -17; 340 //Add(aseenkuva); 341 342 306 343 if (multiplayer == 0) return; 307 344 … … 317 354 p2_hpPalkki.Y = Screen.Top - 40; 318 355 p2_hpPalkki.BarImage = LoadImage("fullbar"); 356 p2_hpPalkki.Image = LoadImage("emptybar"); 319 357 Add(p2_hpPalkki); 320 358 Add(player2); 359 360 //p2_ammo 361 p2_ammo = new IntMeter(280); 362 p2_lipas = new IntMeter(30); 363 Label p2_ammo_label = new Label(); 364 vali = new Label("/"); 365 Label p2_ammo_lipas = new Label(); 366 p2_ammo_lipas.BindTo(p2_lipas); 367 p2_ammo_label.BindTo(p2_ammo); 368 p2_ammo_lipas.Y = Screen.Top - 50; 369 p2_ammo_lipas.X = +100; 370 vali.Y = Screen.Top - 50; 371 vali.X = +85; 372 p2_ammo_label.Y = Screen.Top - 50; 373 p2_ammo_label.X = +60; 374 Add(p2_ammo_lipas); 375 Add(vali); 376 Add(p2_ammo_label); 377 378 } 379 void LuoAse(double X, double Y) 380 { 381 GameObject aseenkuva = new GameObject(90, 27); 382 aseenkuva.Image = miniak; 383 aseenkuva.Y = Y; 384 aseenkuva.X = X; 385 aseenkuva.Tag = "ase"; 386 Add(aseenkuva, -3); 321 387 } 322 388 … … 359 425 player.Angle = nopeus.Angle; 360 426 OvenLahella(player); 427 AseenLahella(player); 361 428 } 362 429 void Shoot(PhysicsObject pelaaja) … … 367 434 if(ammus != null) p1_lipas.Value--; 368 435 } 436 if (pelaaja == p2) 437 { 438 PhysicsObject ammus = ak2.Shoot(); 439 if (ammus != null) p1_lipas.Value--; 440 } 441 if (p1_lipas == 0) 442 { 443 lataa = new Label("Reload"); 444 lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 445 Add(lataa); 446 } 447 if (multiplayer == 1 && p2_lipas == 0) 448 { 449 lataa2 = new Label("Reload"); 450 lataa2.X = -50; 451 lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 452 Add(lataa); 453 } 369 454 } 370 455 void ZombieHit(PhysicsObject zombi, PhysicsObject kohde) 371 456 { 372 457 if (kohde.Tag == "living") p1_hp.Value--; 458 if (p1_hp == 0) GameOver(); 373 459 } 374 460 void LuoAikaLaskuri() … … 411 497 else 412 498 { 413 hinta = new Label("Press Space or Yto open one block of the door.");499 hinta = new Label("Press Space or (Y) to open one block of the door."); 414 500 hinta2 = new Label("$150 per block"); 415 501 hinta.X = -20; … … 420 506 hinta.MaximumLifetime = TimeSpan.FromSeconds(1); 421 507 hinta2.MaximumLifetime = TimeSpan.FromSeconds(1); 422 423 508 } 424 509 void HighScores() … … 441 526 ak1.Ammo.Value = p1_lipas.Value; 442 527 } 443 if (p1_lipas == 0)444 {445 lataa = new Label("Reload");446 lataa.MaximumLifetime = TimeSpan.FromSeconds(1);447 Add(lataa);448 449 }528 //if (p1_lipas == 0) 529 //{ 530 // lataa = new Label("Reload"); 531 // lataa.MaximumLifetime = TimeSpan.FromSeconds(1); 532 // Add(lataa); 533 // 534 //} 450 535 } 451 536 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) … … 458 543 { 459 544 Zombi z1 = kohde as Zombi; 460 z1.zhp.Value--; 461 } 462 463 } 545 z1.zhp.Value -= 7.5; 546 } 547 } 548 void OstaAmmo(PhysicsObject pelaaja) 549 { 550 GameObject ase = GetObjectAt(pelaaja.Position, "ase", 35); 551 if (ase == null) return; 552 else if (rahaLaskuri > 499) 553 { 554 p1_lipas.SetValue(30); 555 p1_ammo.SetValue(280); 556 rahaLaskuri.SetValue(rahaLaskuri.Value - 500); 557 } 558 else return; 559 } 560 void GameOver() 561 { 562 ClearAll(); 563 Mouse.IsCursorVisible = true; 564 HighScoreWindow topIkkuna = new HighScoreWindow("Parhaat pisteet","Onneksi olkoon, pääsit listalle lahtaamalla %p zombia! Syötä nimesi:", 565 topLista, killLaskuri); 566 topIkkuna.Closed += TallennaPisteet; 567 Add(topIkkuna); 568 } 569 void TallennaPisteet(Window sender) 570 { 571 DataStorage.Save<ScoreList>(topLista, "pisteet.xml"); 572 Valikko(); 573 } 574 void Use(PhysicsObject pelaaja) 575 { 576 OstaAmmo(pelaaja); 577 AvaaOvi(pelaaja); 578 } 579 void AseenLahella(PhysicsObject pelaaja) 580 { 581 GameObject ase = GetObjectAt(pelaaja.Position, "ase", 35); 582 Label hinta; 583 Label hinta2; 584 if (ase == null) return; 585 if (multiplayer == 0) 586 { 587 hinta = new Label("Press Space to buy AK-47 ammo."); 588 hinta2 = new Label("$500"); 589 hinta.X = -20; 590 hinta2.Y = -20; 591 Add(hinta); 592 Add(hinta2); 593 } 594 else 595 { 596 hinta = new Label("Press Space or (Y) to buy AK-47 ammo."); 597 hinta2 = new Label("$500"); 598 hinta.X = -20; 599 hinta2.Y = -20; 600 Add(hinta); 601 Add(hinta2); 602 } 603 hinta.MaximumLifetime = TimeSpan.FromSeconds(1); 604 hinta2.MaximumLifetime = TimeSpan.FromSeconds(1); 605 } 606 464 607 } -
2012/26/MikaL/Zombie Survival/Zombie Survival/Zombie SurvivalContent/Zombie SurvivalContent.contentproj
r3322 r3379 91 91 </Compile> 92 92 </ItemGroup> 93 <ItemGroup> 94 <Compile Include="emptybar.png"> 95 <Name>emptybar</Name> 96 <Importer>TextureImporter</Importer> 97 <Processor>TextureProcessor</Processor> 98 </Compile> 99 </ItemGroup> 93 100 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 94 101 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/26/MikaL/asd/asd/asd/asd.cs
r3322 r3379 17 17 { 18 18 MessageDisplay.Add("LOL"); 19 ControllerOne.Vibrate(1, 1, 1, 1, 1000000);19 ControllerOne.Vibrate(1, 1, 2, 2, 1000000); 20 20 lol.AddValue(1); 21 21 }
Note: See TracChangeset
for help on using the changeset viewer.