- Timestamp:
- 2014-07-24 11:21:34 (9 years ago)
- Location:
- 2014/30/AtteB
- Files:
-
- 7 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/30/AtteB/Peli/Peli/Peli/Peli.cs
r5599 r5623 7 7 using Jypeli.Widgets; 8 8 9 // TODO Lisää kenttiä (!!!) 10 // TODO Tähtääminen hiirellä 11 // TODO Lisää vihollisia 12 // TODO Healthbar pelaajan ja bossin päälle 13 9 14 class Vihollinen : PlatformCharacter 10 15 { … … 20 25 } 21 26 27 class Boss : PhysicsObject 28 { 29 private IntMeter elamaLaskuri; 30 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 31 32 public Boss(double leveys, double korkeus, int elama) 33 : base(leveys, korkeus) 34 { 35 elamaLaskuri = new IntMeter(elama, 0, elama); 36 elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 37 } 38 } 39 22 40 class Inventory : Widget 23 41 { … … 60 78 61 79 PlatformCharacter pelaaja1; 62 PhysicsObject Vihollinen; 63 Vihollinen Slime; 80 Vector BossSijainti; 64 81 65 82 Image tahtiKuva = LoadImage("tahti"); … … 78 95 Image Heart1 = LoadImage("heart"); 79 96 Image SlimeBall = LoadImage("SlimeBall"); 97 Image Gate = LoadImage("Gate"); 80 98 81 99 SoundEffect maaliAani = LoadSoundEffect("maali"); 82 100 SoundEffect HowItBegins = LoadSoundEffect("HowItBegins"); 83 101 SoundEffect PlayerShoot1 = LoadSoundEffect("PlayerShoot"); 102 SoundEffect Hitman = LoadSoundEffect("Hitman"); 84 103 85 104 public override void Begin() … … 119 138 kentta.SetTileMethod('S', LuoSlime); 120 139 kentta.SetTileMethod('H', LisaaHeart); 140 kentta.SetTileMethod('O', LisaaOvi); 141 kentta.SetTileMethod('-', LisaaOvenSulkija); 142 kentta.SetTileMethod('§', LisaaOvi2); 143 kentta.SetTileMethod('B', delegate(Vector paikka, double l, double k) { BossSijainti = paikka; }); 121 144 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 122 145 Level.CreateBorders(); … … 130 153 taso.Position = paikka; 131 154 taso.Image = StoneTaso; 155 taso.Tag = "seinä"; 132 156 Add(taso); 133 157 } … … 139 163 Stone.Position = paikka; 140 164 Stone.Image = StoneKuva; 165 Stone.Tag = "seinä"; 141 166 Add(Stone); 142 167 … … 149 174 stoneBrick.Position = paikka; 150 175 stoneBrick.Image = StoneBrickTaso; 176 stoneBrick.Tag = "seinä"; 151 177 Add(stoneBrick); 152 178 … … 159 185 Stone.Position = paikka; 160 186 Stone.Image = StoneKuva_katto; 187 Stone.Tag = "seinä"; 161 188 Add(Stone); 162 189 … … 182 209 AddCollisionHandler(pelaaja1, "vihollinen", PelaajaOsuuViholliseen); 183 210 AddCollisionHandler(pelaaja1, "health", PelaajaOsuuHeart); 211 AddCollisionHandler(pelaaja1, "ovensulkija", OvetSulkeutuu); 184 212 Add(pelaaja1); 185 213 … … 216 244 217 245 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 246 247 Mouse.ListenMovement(0.1, Tähtää, "Tähtää aseella"); 218 248 } 219 249 … … 291 321 ajastin.Timeout += delegate 292 322 { 293 PhysicsObject ammus = Slime.Weapon.Shoot(); 323 if (!Slime.IsDestroyed && Slime.SeesObject(pelaaja1, "seinä")) 324 { 325 326 PhysicsObject ammus = Slime.Weapon.Shoot(); 327 if (ammus != null) 328 { 329 ammus.Image = SlimeBall; 330 ammus.Size = new Vector(20, 20); 331 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 332 ammus.Tag = "ammus"; 333 334 } 335 } 336 }; 337 ajastin.Start(); 338 339 Timer ajastin2 = new Timer(); 340 ajastin2.Interval = 0.01; 341 ajastin2.Timeout += delegate 342 { 343 344 Vector suunta = (pelaaja1.Position - Slime.Position).Normalize(); 345 Slime.Weapon.Angle = suunta.Angle; 346 347 }; 348 ajastin2.Start(); 349 } 350 351 void LuoBoss1(Vector paikka, double leveys, double korkeus) 352 { 353 Boss Boss1 = new Boss(leveys, korkeus * 0.5, 20); 354 Boss1.CanRotate = false; 355 Boss1.Position = paikka; 356 Boss1.Tag = "boss"; 357 Boss1.Image = Slime1; 358 Boss1.IgnoresGravity = true; 359 Add(Boss1); 360 361 362 PathFollowerBrain tasoAivot = new PathFollowerBrain(100, paikka + new Vector(-200, 0), paikka + new Vector(200, 0), paikka + new Vector(200, -100), paikka + new Vector(-200, -100)); 363 tasoAivot.Loop = true; 364 Boss1.Brain = tasoAivot; 365 366 AssaultRifle weapon = new AssaultRifle(30, 10); 367 weapon.ProjectileCollision = AmmusOsuiPelaajaan; 368 weapon.IsVisible = false; 369 weapon.AttackSound = null; 370 weapon.Power.MaxValue = 10; 371 Boss1.Add(weapon); 372 373 Timer ajastin = new Timer(); 374 ajastin.Interval = 0.8; 375 ajastin.Timeout += delegate 376 { 377 Vector suunta = (pelaaja1.Position - Boss1.Position).Normalize(); 378 weapon.Angle = suunta.Angle; 379 380 PhysicsObject ammus = weapon.Shoot(); 294 381 if (ammus != null) 295 382 { 296 383 ammus.Image = SlimeBall; 297 384 ammus.Size = new Vector(20, 20); 298 ammus.MaximumLifetime = TimeSpan.FromSeconds( 1.0);385 ammus.MaximumLifetime = TimeSpan.FromSeconds(8.0); 299 386 ammus.Tag = "ammus"; 300 387 } 388 if (Boss1.IsDestroyed) 389 { 390 ajastin.Stop(); 391 MediaPlayer.Pause(); 392 MediaPlayer.Play("howitbegins"); 301 393 } 302 394 }; 303 395 ajastin.Start(); 304 305 Timer ajastin2 = new Timer(); 306 ajastin2.Interval = 0.01; 307 ajastin2.Timeout += delegate 308 { 309 310 Vector suunta = (pelaaja1.Position - Slime.Position).Normalize(); 311 Slime.Weapon.Angle = suunta.Angle; 312 313 }; 314 ajastin2.Start(); 315 } 316 317 void LuoBoss1(Vector paikka, double leveys, double korkeus) 318 { 319 Vihollinen Boss1 = new Vihollinen(leveys, korkeus * 0.5, 20); 320 Boss1.CanRotate = false; 321 Boss1.Position = paikka; 322 Boss1.Tag = "vihollinen"; 323 Boss1.Image = Slime1; 324 Add(Boss1); 325 326 PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 327 tasoAivot.Speed = 150; 328 Boss1.Brain = tasoAivot; 329 330 FollowerBrain SlimeAivot = new FollowerBrain("vihollinen"); 331 SlimeAivot.Speed = 200; 332 SlimeAivot.DistanceFar = 600; 333 SlimeAivot.DistanceClose = 300; 334 SlimeAivot.StopWhenTargetClose = true; 335 SlimeAivot.FarBrain = tasoAivot; 336 337 Boss1.Weapon = new AssaultRifle(30, 10); 338 Boss1.Weapon.ProjectileCollision = AmmusOsuiPelaajaan; 339 Boss1.Weapon.IsVisible = false; 340 Boss1.Weapon.AttackSound = null; 341 342 Timer ajastin = new Timer(); 343 ajastin.Interval = 1.0; 344 ajastin.Timeout += delegate 345 { 346 PhysicsObject ammus = Boss1.Weapon.Shoot(); 347 if (ammus != null) 348 { 349 ammus.Image = SlimeBall; 350 ammus.Size = new Vector(20, 20); 351 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 352 ammus.Tag = "ammus"; 353 } 354 }; 355 ajastin.Start(); 356 if (Boss1.IsDestroyed) 357 { 358 ajastin.Stop(); 359 } 396 360 397 } 361 398 … … 368 405 (kohde as Vihollinen).ElamaLaskuri.Value--; 369 406 } 407 if (kohde.Tag.ToString() == "boss") 408 { 409 (kohde as Boss).ElamaLaskuri.Value--; 410 } 370 411 } 371 412 … … 382 423 void AmmuAseella(AssaultRifle ase) 383 424 { 384 ase.AbsoluteAngle = pelaaja1.FacingDirection.Angle;385 425 PhysicsObject ammus = ase.Shoot(); 386 426 … … 394 434 } 395 435 396 void Tähtää()397 {398 pelaaja1.Weapon.Angle = pelaaja1.FacingDirection.Angle;399 }400 401 436 void LuoElämäLaskuri() 402 437 { … … 406 441 407 442 ProgressBar elämäPalkki = new ProgressBar(150, 20); 408 elämäPalkki.X = Screen.Left + 500;409 elämäPalkki.Y = Screen.Top - 100;443 elämäPalkki.X = Level.Top - 450; 444 elämäPalkki.Y = Level.Left + 350; 410 445 elämäPalkki.BindTo(elämäLaskuri); 411 446 elämäPalkki.Color = Color.Transparent; … … 428 463 } 429 464 430 public void SlimeLähelläPelaajaa()431 {432 Vector suunta = (pelaaja1.Position - Slime.Position).Normalize();433 434 Slime.Angle = suunta.Angle;435 }436 437 465 void AloitaPeliAlusta() 438 466 { … … 441 469 } 442 470 471 void LisaaOvi(Vector paikka, double leveys, double korkeus) 472 { 473 PhysicsObject ovi = PhysicsObject.CreateStaticObject(leveys, korkeus); 474 ovi.Position = paikka; 475 ovi.Image = Gate; 476 ovi.Tag = "ovi"; 477 ovi.IgnoresCollisionResponse = true; 478 ovi.IsVisible = false; 479 Add(ovi); 480 } 481 482 void LisaaOvenSulkija(Vector paikka, double leveys, double korkeus) 483 { 484 PhysicsObject ovensulkija = PhysicsObject.CreateStaticObject(leveys, korkeus * 5); 485 ovensulkija.Position = paikka; 486 ovensulkija.Image = Heart1; 487 ovensulkija.Tag = "ovensulkija"; 488 ovensulkija.IgnoresCollisionResponse = true; 489 ovensulkija.IsVisible = false; 490 Add(ovensulkija); 491 } 492 493 void OvetSulkeutuu(PhysicsObject pelaaja1, PhysicsObject sulkija) 494 { 495 sulkija.Destroy(); 496 foreach (PhysicsObject ovi in GetObjectsWithTag("ovi")) 497 { 498 ovi.IgnoresCollisionResponse = false; 499 ovi.IsVisible = true; 500 } 501 502 LuoBoss1(BossSijainti, RUUDUN_KOKO * 2, RUUDUN_KOKO * 2); 503 504 MediaPlayer.Pause(); 505 MediaPlayer.Play("hitman"); 506 } 507 508 void LisaaOvi2(Vector paikka, double leveys, double korkeus) 509 { 510 PhysicsObject ovi2 = PhysicsObject.CreateStaticObject(leveys, korkeus); 511 ovi2.Position = paikka; 512 ovi2.Image = Gate; 513 ovi2.Tag = "ovi"; 514 ovi2.IgnoresCollisionResponse = true; 515 ovi2.IsVisible = false; 516 Add(ovi2); 517 } 518 519 void Tähtää(AnalogState hiirenLiike) 520 { 521 522 } 443 523 } -
2014/30/AtteB/Peli/Peli/Peli/Peli.csproj.Debug.cachefile
r5599 r5623 21 21 Content\Slimeball.xnb 22 22 Content\PlayerShoot.xnb 23 Content\Hitman.xnb 24 Content\Gate.xnb 23 25 Content\HowItBegins.wma 24 26 Content\PlayerShoot.wma 27 Content\Hitman.wma -
2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/ContentPipeline-{2D86B228-748C-44C7-93B1-DCBD6910317C}.xml
r5599 r5623 36 36 <Options>None</Options> 37 37 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\kentta1.xnb</Output> 38 <Time>2014-07-2 3T13:24:51.8127339+03:00</Time>38 <Time>2014-07-24T11:06:14.5761203+03:00</Time> 39 39 </Item> 40 40 <Item> … … 201 201 <Extra>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.wma</Extra> 202 202 <Time>2014-07-23T13:51:43.8689234+03:00</Time> 203 </Item> 204 <Item> 205 <Source>Hitman.mp3</Source> 206 <Name>Hitman</Name> 207 <Importer>Mp3Importer</Importer> 208 <Processor>SongProcessor</Processor> 209 <Options>None</Options> 210 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Hitman.xnb</Output> 211 <Extra>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Hitman.wma</Extra> 212 <Time>2014-07-24T10:40:31.5509965+03:00</Time> 213 </Item> 214 <Item> 215 <Source>Gate.png</Source> 216 <Name>Gate</Name> 217 <Importer>TextureImporter</Importer> 218 <Processor>TextureProcessor</Processor> 219 <Options>None</Options> 220 <Output>C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Gate.xnb</Output> 221 <Time>2014-07-24T10:56:16.5370039+03:00</Time> 203 222 </Item> 204 223 <BuildSuccessful>true</BuildSuccessful> -
2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/Peli.csproj.FileListAbsolute.txt
r5599 r5623 31 31 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.xnb 32 32 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\PlayerShoot.wma 33 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Hitman.xnb 34 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Hitman.wma 35 C:\MyTemp\AtteB\Peli\Peli\Peli\bin\x86\Debug\Content\Gate.xnb -
2014/30/AtteB/Peli/Peli/Peli/obj/x86/Debug/cachefile-{2D86B228-748C-44C7-93B1-DCBD6910317C}-targetpath.txt
r5599 r5623 23 23 Content\PlayerShoot.xnb 24 24 Content\PlayerShoot.wma 25 Content\Hitman.xnb 26 Content\Hitman.wma 27 Content\Gate.xnb -
2014/30/AtteB/Peli/Peli/PeliContent/PeliContent.contentproj
r5599 r5623 187 187 </Compile> 188 188 </ItemGroup> 189 <ItemGroup> 190 <Compile Include="Hitman.mp3"> 191 <Name>Hitman</Name> 192 <Importer>Mp3Importer</Importer> 193 <Processor>SongProcessor</Processor> 194 </Compile> 195 </ItemGroup> 196 <ItemGroup> 197 <Compile Include="Gate.png"> 198 <Name>Gate</Name> 199 <Importer>TextureImporter</Importer> 200 <Processor>TextureProcessor</Processor> 201 </Compile> 202 </ItemGroup> 189 203 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 190 204 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2014/30/AtteB/Peli/Peli/PeliContent/kentta1.txt
r5599 r5623 8 8 ???????.............?....... . 9 9 ????????............?...S...?. 10 ############## ####################### ####################11 ........... .................................................12 ........... .................................................13 ........... .................................................14 ........... .................................................15 ........... .................................................16 ........... .................................................17 ........... .................................................10 ##############..##################### #################### 11 ...........#.................#.............................. 12 ...........#........B........#.............................. 13 ...........#.................#.............................. 14 ...........#.................#.............................. 15 ...........#.................#.............................. 16 ...........§...............-.O.............................. 17 ...........§.................O.............................. 18 18 ############################################################
Note: See TracChangeset
for help on using the changeset viewer.