Changeset 7096
- Timestamp:
- 2015-12-12 14:54:21 (7 years ago)
- Location:
- 2015/koodauskerho/AakeR/IMBT
- Files:
-
- 15 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/koodauskerho/AakeR/IMBT/IMBT/IMBT/IMBT.cs
r7078 r7096 14 14 public AssaultRifle Ase; 15 15 public bool telaJaljetLimit; 16 public bool voiLiikkua = true; 16 17 17 18 public Pelaaja(double leveys, double korkeus, Image pelaajanKuva, Image tykkiTorninKuva, Image rajahdysKuva, Image liekkiKuva) … … 68 69 ((IMBT)Game.Instance).AddCollisionHandler(this, "laser", delegate (PhysicsObject a, PhysicsObject b) 69 70 { 70 this.healthit.Value -= 80;71 this.healthit.Value -= 6; 71 72 SavuLiekki(); 72 73 }); … … 200 201 SoundEffect palloAani = LoadSoundEffect("PalloAani"); 201 202 SoundEffect boostiAani = LoadSoundEffect("BoostiAani"); 203 SoundEffect laserAani = LoadSoundEffect("LaserAani"); 204 SoundEffect laserAmmusAani = LoadSoundEffect("LaserAmmusAani"); 202 205 Pelaaja pelaaja1; 203 206 MultiSelectWindow alkuValikko; … … 256 259 } 257 260 ruudut.SetTileMethod(Color.Black, LuoPalikka); 258 Level.Background.Color = Color. Silver;261 Level.Background.Color = Color.LightGray; 259 262 260 263 ruudut.Execute(80, 80); … … 275 278 kontrollerit[pelaajanr - 1].ListenAnalog(AnalogControl.LeftStick, 0.0, KaannaPelaajaa, "", pelaaja); 276 279 kontrollerit[pelaajanr - 1].ListenAnalog(AnalogControl.RightStick, 0.0, KaannaTykkia, "", pelaaja); 277 kontrollerit[pelaajanr - 1].Listen(Button.RightTrigger, ButtonState. Down, Ammu, "", pelaaja, "perus", valinta);280 kontrollerit[pelaajanr - 1].Listen(Button.RightTrigger, ButtonState.Pressed, Ammu, "", pelaaja, "perus", valinta); 278 281 kontrollerit[pelaajanr - 1].Listen(Button.LeftTrigger, ButtonState.Pressed, Ammu, "", pelaaja, "raketti", valinta); 279 282 kontrollerit[pelaajanr - 1].Listen(Button.RightShoulder, ButtonState.Pressed, Ammu, "", pelaaja, "pallo", valinta); … … 349 352 void KaannaPelaajaa(AnalogState tatinTila, Pelaaja pelaaja) 350 353 { 351 Angle vanhaKulma = pelaaja.Angle; 352 pelaaja.Angle = tatinTila.StateVector.Angle; 353 354 Angle kulmanMuutos = pelaaja.Angle - vanhaKulma; 355 356 if (pelaaja.telaJaljetLimit && pelaaja.IsVisible) 357 { 358 pelaaja.telaJaljetLimit = false; 359 360 GameObject telaJaljet = new GameObject(telaJaljetKuva); 361 telaJaljet.Angle = pelaaja.Angle; 362 telaJaljet.Position = pelaaja.Position; 363 Add(telaJaljet, -1); 364 365 Timer.SingleShot(0.05, delegate { pelaaja.telaJaljetLimit = true; }); 366 367 Timer.SingleShot(RandomGen.NextDouble(2.0, 20.0), delegate { telaJaljet.Destroy(); }); 368 } 369 370 pelaaja.Push(tatinTila.StateVector * maxNopeus); 354 if (pelaaja.voiLiikkua) 355 { 356 Angle vanhaKulma = pelaaja.Angle; 357 pelaaja.Angle = tatinTila.StateVector.Angle; 358 359 Angle kulmanMuutos = pelaaja.Angle - vanhaKulma; 360 361 if (pelaaja.telaJaljetLimit && pelaaja.IsVisible) 362 { 363 pelaaja.telaJaljetLimit = false; 364 365 GameObject telaJaljet = new GameObject(telaJaljetKuva); 366 telaJaljet.Angle = pelaaja.Angle; 367 telaJaljet.Position = pelaaja.Position; 368 Add(telaJaljet, -1); 369 370 Timer.SingleShot(0.05, delegate { pelaaja.telaJaljetLimit = true; }); 371 372 Timer.SingleShot(RandomGen.NextDouble(2.0, 20.0), delegate { telaJaljet.Destroy(); }); 373 } 374 375 pelaaja.Push(tatinTila.StateVector * maxNopeus); 376 } 371 377 372 378 } … … 374 380 void KaannaTykkia(AnalogState tatinTila, Pelaaja pelaaja) 375 381 { 376 pelaaja.Ase.AbsoluteAngle = tatinTila.StateVector.Angle; 382 //if (pelaaja.voiLiikkua) 383 { 384 pelaaja.Ase.AbsoluteAngle = tatinTila.StateVector.Angle; 385 } 377 386 } 378 387 379 388 void Ammu(Pelaaja pelaaja, String ammusTyyppi, int konenr) 380 389 { 381 382 PhysicsObject ammus = pelaaja.Ase.Shoot();383 if (ammus != null)384 {385 switch (ammusTyyppi)390 if (pelaaja.voiLiikkua) 391 { 392 pelaaja.Ase.AttackSound = null; 393 PhysicsObject ammus = pelaaja.Ase.Shoot(); 394 if (ammus != null) 386 395 { 387 case "perus": 388 ammusAani.Play(); 389 ammus.Image = perusAmmus[konenr]; 390 if (konenr == 2) 391 { 392 ammus.Height = 25; 393 } 394 ammus.Tag = "perusAmmus"; 395 AddCollisionHandler(ammus, delegate (PhysicsObject a, PhysicsObject b) 396 { 397 a.Destroy(); 398 }); 399 pelaaja.Ase.FireRate = 10; 400 break; 401 case "raketti": 402 raketinAani.Play(); 403 ammus.Image = rakettiKuva; 404 ammus.Tag = "raketti"; 405 ammus.Size *= 2.5; 406 AddCollisionHandler(ammus, delegate (PhysicsObject a, PhysicsObject b) 407 { 408 a.Destroy(); 409 Explosion rajahdys = new Explosion(140); 410 rajahdys.Position = a.Position; 411 rajahdys.ShockwaveReachesObject += RajahdysOsuu; 412 Add(rajahdys); 413 raketinAani.Stop(); 414 }); 415 pelaaja.Ase.FireRate = 0.45; 416 417 if (konenr == 1) 418 { 419 Pelaaja[] kohdePelaajat = new Pelaaja[pelaajat.Count - 1]; 420 for (int i = 0, j = 0; i < pelaajat.Count; i++) 421 { 422 if (pelaajat[i] != pelaaja) 396 switch (ammusTyyppi) 397 { 398 case "perus": 399 ammusAani.Play(); 400 ammus.Image = perusAmmus[konenr]; 401 if (konenr == 2) 402 { 403 ammus.Height = 25; 404 } 405 ammus.Tag = "perusAmmus"; 406 AddCollisionHandler(ammus, delegate (PhysicsObject a, PhysicsObject b) 407 { 408 a.Destroy(); 409 }); 410 Timer perusAjastin = new Timer(); 411 perusAjastin.Interval = 0.1; 412 perusAjastin.Timeout += delegate 413 { 414 ammus = pelaaja.Ase.Shoot(); 415 if (ammus != null) 423 416 { 424 kohdePelaajat[j] = pelaajat[i]; 425 j++; 426 } 427 } 428 429 ammus.Image = hakeutuvaRakettikuva; 430 431 432 FollowerBrain seuraajanAivot = new FollowerBrain(kohdePelaajat); 433 seuraajanAivot.TurnSpeed = UnlimitedAngle.FromDegrees(45); 434 //seuraajanAivot.TurnWhileMoving = true; 435 seuraajanAivot.Speed = 600; 436 ammus.Brain = seuraajanAivot; 437 438 Timer ajastin = new Timer(); 439 ajastin.Interval = 0.1; 440 ajastin.Timeout += delegate 441 { 442 ammus.AbsoluteAngle = ammus.Velocity.Angle; 443 if (ammus.IsDestroyed) 444 { 445 ajastin.Stop(); 417 ammusAani.Play(); 418 ammus.Image = perusAmmus[konenr]; 419 if (konenr == 2) 420 { 421 ammus.Height = 25; 422 } 423 ammus.Tag = "perusAmmus"; 424 AddCollisionHandler(ammus, delegate (PhysicsObject a, PhysicsObject b) 425 { 426 a.Destroy(); 427 }); 428 ammus.Position += pelaaja.Ase.Angle.GetVector() * 70; 446 429 } 447 430 }; 448 ajastin.Start(); 449 } 450 break; 451 case "pallo": 452 if (konenr == 0) 453 { 454 palloAani.Play(); 455 ammus.Image = palloKuva; 456 ammus.Tag = "pallo"; 457 ammus.Size *= 5; 458 ammus.MaximumLifetime = new TimeSpan(0, 0, 4); 459 pelaaja.Ase.FireRate = 0.5; 460 } 461 // Tähän tulee laser, ei pallo 462 else if (konenr == 2) 463 { 464 ammus.Image = laser1Kuva; 465 ammus.Tag = "laser"; 466 ammus.Size = new Vector(3000, 10); 467 ammus.Position += ammus.Angle.Cos * new Vector(1490, 0) + ammus.Angle.Sin * new Vector(0, 1490); 468 ammus.Velocity = new Vector(0, 0); 469 Timer.SingleShot(1.5, delegate 470 { 471 Animation ammusAnim = new Animation(new Image[]{ laser2Kuva, laser3Kuva, laser4Kuva }); 472 ammus.Animation = ammusAnim; 473 ammus.Size = new Vector(3000, 40); 474 ammus.Animation.Start(); 431 perusAjastin.Start(2); 432 pelaaja.Ase.FireRate = 10; 433 break; 434 case "raketti": 435 raketinAani.Play(); 436 ammus.Image = rakettiKuva; 437 ammus.Tag = "raketti"; 438 ammus.Size *= 2.5; 439 AddCollisionHandler(ammus, delegate (PhysicsObject a, PhysicsObject b) 440 { 441 a.Destroy(); 442 Explosion rajahdys = new Explosion(140); 443 rajahdys.Position = a.Position; 444 rajahdys.ShockwaveReachesObject += RajahdysOsuu; 445 Add(rajahdys); 446 raketinAani.Stop(); 475 447 }); 476 Timer.SingleShot(4.0, delegate 448 pelaaja.Ase.FireRate = 0.45; 449 450 if (konenr == 1) 451 { 452 Pelaaja[] kohdePelaajat = new Pelaaja[pelaajat.Count - 1]; 453 for (int i = 0, j = 0; i < pelaajat.Count; i++) 454 { 455 if (pelaajat[i] != pelaaja) 456 { 457 kohdePelaajat[j] = pelaajat[i]; 458 j++; 459 } 460 } 461 462 ammus.Image = hakeutuvaRakettikuva; 463 464 465 FollowerBrain seuraajanAivot = new FollowerBrain(kohdePelaajat); 466 seuraajanAivot.TurnSpeed = UnlimitedAngle.FromDegrees(45); 467 //seuraajanAivot.TurnWhileMoving = true; 468 seuraajanAivot.Speed = 450; 469 ammus.Brain = seuraajanAivot; 470 471 Timer ajastin = new Timer(); 472 ajastin.Interval = 0.1; 473 ajastin.Timeout += delegate 474 { 475 ammus.AbsoluteAngle = ammus.Velocity.Angle; 476 if (ammus.IsDestroyed) 477 { 478 ajastin.Stop(); 479 } 480 }; 481 ajastin.Start(); 482 } 483 break; 484 case "pallo": 485 if (konenr == 0) 486 { 487 palloAani.Play(); 488 ammus.Image = palloKuva; 489 ammus.Tag = "pallo"; 490 ammus.Size *= 5; 491 ammus.MaximumLifetime = new TimeSpan(0, 0, 4); 492 pelaaja.Ase.FireRate = 0.5; 493 } 494 // Tähän tulee laser, ei pallo 495 else if (konenr == 2) 496 { 497 Animation ammusAnim = new Animation(new Image[] { laser2Kuva, laser3Kuva, laser4Kuva }); 498 laserAmmusAani.Play(); 499 pelaaja.voiLiikkua = false; 500 pelaaja.Stop(); 501 pelaaja.Ase.FireRate = 100; 502 ammus.IgnoresCollisionResponse = true; 503 ammus.IgnoresExplosions = true; 504 ammus.Image = laser1Kuva; 505 ammus.Tag = "none"; 506 ammus.Size = new Vector(3000, 10); 507 ammus.Position = pelaaja.Position + ammus.Angle.Cos * new Vector(1480, 0) + ammus.Angle.Sin * new Vector(0, 1480); 508 ammus.Velocity = new Vector(0, 0); 509 510 Timer tahtaysAjastin = new Timer(); 511 tahtaysAjastin.Interval = 0.1; 512 tahtaysAjastin.Timeout += delegate 513 { 514 ammus.Angle = pelaaja.Ase.Angle; 515 ammus.Position = pelaaja.Position + ammus.Angle.Cos * new Vector(1550, 0) + ammus.Angle.Sin * new Vector(0, 1550); 516 ammus.Velocity = new Vector(0, 0); 517 }; 518 tahtaysAjastin.Start(1); 519 520 Timer.SingleShot(1.5, delegate 521 { 522 ammus.Destroy(); 523 ammus = pelaaja.Ase.Shoot(); 524 if (ammus != null) 525 { 526 pelaaja.voiLiikkua = false; 527 pelaaja.Stop(); 528 pelaaja.Ase.FireRate = 100; 529 ammus.IgnoresCollisionResponse = true; 530 ammus.IgnoresExplosions = true; 531 ammus.Tag = "laser"; 532 ammus.Animation = ammusAnim; 533 ammus.Size = new Vector(3000, 40); 534 ammus.Position = pelaaja.Position + ammus.Angle.Cos * new Vector(1550, 0) + ammus.Angle.Sin * new Vector(0, 1550); 535 ammus.Velocity = new Vector(0, 0); 536 ammus.Animation.Start(); 537 Timer ajastin = new Timer(); 538 ajastin.Interval = 0.05; 539 ajastin.Timeout += delegate 540 { 541 if (ammus != null) 542 { 543 ammus.Destroy(); 544 } 545 ammus = pelaaja.Ase.Shoot(); 546 if (ammus != null) 547 { 548 laserAani.Play(); 549 ammus.IgnoresCollisionResponse = true; 550 ammus.IgnoresExplosions = true; 551 ammus.Tag = "laser"; 552 ammus.Animation = ammusAnim; 553 ammus.Size = new Vector(3000, 40); 554 ammus.Position = pelaaja.Position + ammus.Angle.Cos * new Vector(1550, 0) + ammus.Angle.Sin * new Vector(0, 1550); 555 ammus.Velocity = new Vector(0, 0); 556 ammus.Animation.Start(); 557 } 558 }; 559 ajastin.Start(40); 560 } 561 }); 562 Timer.SingleShot(3.55, delegate 563 { 564 if (ammus != null) 565 { 566 ammus.Destroy(); 567 } 568 pelaaja.voiLiikkua = true; 569 pelaaja.Ase.FireRate = 0.45; 570 }); 571 } 572 else 477 573 { 478 574 ammus.Destroy(); 479 }); 480 ammus.IgnoresCollisionResponse = true; 481 } 482 else 483 { 484 ammus.Destroy(); 485 Explosion poks = new Explosion(200); 486 poks.Position = pelaaja.Position; 487 poks.Animation = null; 488 poks.Speed = 1000; 489 poks.Image = paineAaltoKuva; 490 poks.AddShockwaveHandler("raketti", delegate (IPhysicsObject a, Vector v) 491 { 492 a.Brain.Active = false; 493 }); 494 pelaaja.IgnoresExplosions = true; 495 Add(poks); 496 Timer ajastin = new Timer(); 497 Timer.SingleShot(0.5, delegate { pelaaja.IgnoresExplosions = false; }); 498 pelaaja.Ase.FireRate = 0.5; 499 ajastin.Start(); 500 501 } 502 break; 503 default: 504 break; 575 Explosion poks = new Explosion(200); 576 poks.Position = pelaaja.Position; 577 poks.Animation = null; 578 poks.Speed = 1000; 579 poks.Image = paineAaltoKuva; 580 poks.AddShockwaveHandler("raketti", delegate (IPhysicsObject a, Vector v) 581 { 582 a.Brain.Active = false; 583 }); 584 pelaaja.IgnoresExplosions = true; 585 Add(poks); 586 Timer ajastin = new Timer(); 587 Timer.SingleShot(0.5, delegate { pelaaja.IgnoresExplosions = false; }); 588 pelaaja.Ase.FireRate = 0.5; 589 ajastin.Start(); 590 591 } 592 break; 593 default: 594 break; 595 } 596 597 ammus.Position += pelaaja.Ase.Angle.GetVector() * 70; 598 599 505 600 } 506 507 ammus.Position += pelaaja.Ase.Angle.GetVector() * 70;508 509 510 601 } 511 602 … … 534 625 pelaaja.Ase.IsVisible = false; 535 626 536 Timer.SingleShot( 0.75, delegate627 Timer.SingleShot(1.75, delegate 537 628 { 538 629 pelaaja.IsVisible = true; -
2015/koodauskerho/AakeR/IMBT/IMBT/IMBT/IMBT.csproj.Debug.cachefile
r7078 r7096 51 51 Content\Suojakilpi.xnb 52 52 Content\TykkiSuojaKilpi.xnb 53 Content\LaserAani.xnb 54 Content\LaserAmmusAani.xnb -
2015/koodauskerho/AakeR/IMBT/IMBT/IMBT/obj/x86/Debug/ContentPipeline-{B6A1F4C9-F2E2-4290-A5B5-3717058CC989}.xml
r7078 r7096 54 54 <Options>None</Options> 55 55 <Output>C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\Palikka.xnb</Output> 56 <Time>2015-1 0-17T09:58:33.2098209+03:00</Time>56 <Time>2015-12-12T13:25:09.1463058+02:00</Time> 57 57 </Item> 58 58 <Item> … … 469 469 <Output>C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\TykkiSuojaKilpi.xnb</Output> 470 470 <Time>2015-11-14T13:03:11.0700757+02:00</Time> 471 </Item> 472 <Item> 473 <Source>LaserAani.wav</Source> 474 <Name>LaserAani</Name> 475 <Importer>WavImporter</Importer> 476 <Processor>SoundEffectProcessor</Processor> 477 <Options>None</Options> 478 <Output>C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\LaserAani.xnb</Output> 479 <Time>2015-12-12T12:59:16.7101058+02:00</Time> 480 </Item> 481 <Item> 482 <Source>LaserAmmusAani.wav</Source> 483 <Name>LaserAmmusAani</Name> 484 <Importer>WavImporter</Importer> 485 <Processor>SoundEffectProcessor</Processor> 486 <Options>None</Options> 487 <Output>C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\LaserAmmusAani.xnb</Output> 488 <Time>2015-12-12T12:53:05.7033058+02:00</Time> 471 489 </Item> 472 490 <BuildSuccessful>true</BuildSuccessful> -
2015/koodauskerho/AakeR/IMBT/IMBT/IMBT/obj/x86/Debug/IMBT.csproj.FileListAbsolute.txt
r7078 r7096 59 59 C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\Suojakilpi.xnb 60 60 C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\TykkiSuojaKilpi.xnb 61 C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\LaserAani.xnb 62 C:\MyTemp\AakeR\IMBT\IMBT\IMBT\bin\x86\Debug\Content\LaserAmmusAani.xnb -
2015/koodauskerho/AakeR/IMBT/IMBT/IMBT/obj/x86/Debug/cachefile-{B6A1F4C9-F2E2-4290-A5B5-3717058CC989}-targetpath.txt
r7078 r7096 51 51 Content\Suojakilpi.xnb 52 52 Content\TykkiSuojaKilpi.xnb 53 Content\LaserAani.xnb 54 Content\LaserAmmusAani.xnb -
2015/koodauskerho/AakeR/IMBT/IMBT/IMBTContent/IMBTContent.contentproj
r7078 r7096 353 353 </Compile> 354 354 </ItemGroup> 355 <ItemGroup> 356 <Compile Include="LaserAani.wav"> 357 <Name>LaserAani</Name> 358 <Importer>WavImporter</Importer> 359 <Processor>SoundEffectProcessor</Processor> 360 </Compile> 361 </ItemGroup> 362 <ItemGroup> 363 <Compile Include="LaserAmmusAani.wav"> 364 <Name>LaserAmmusAani</Name> 365 <Importer>WavImporter</Importer> 366 <Processor>SoundEffectProcessor</Processor> 367 </Compile> 368 </ItemGroup> 355 369 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 356 370 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.