- Timestamp:
- 2015-06-15 22:24:59 (8 years ago)
- Location:
- 2015/24/ohjaajat/Dungeon/Dungeon
- Files:
-
- 9 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.cs
r6110 r6111 24 24 * 25 25 * Ideoita: 26 * - Pahempia vihollisia, joihin ei tehoa piikkiansat27 * vaan pitää ostaa kalliimpia ansoja niitä varten.28 26 * - Kultuurihuoneita, jotka tuottavat eriäviä määriä 29 27 * kultuuria tai kestävät yhden barbaarin iskun. … … 60 58 } 61 59 62 class TrapUpgrade : Upgrade60 abstract class TrapUpgrade : Upgrade 63 61 { 64 public int Damage { get; set; }65 66 62 public bool Active 67 63 { … … 82 78 } 83 79 80 // Kutsutaan kun barbaari aktivoi ansan. 81 public abstract void TrapActivate(Dungeon peli, Barbaari barbaari, Room huone); 82 84 83 public override void Invasion(Dungeon peli, Barbaari barbaari, Room huone) 85 84 { 86 85 if (!Active) return; 87 86 88 barbaari.Tenacity.Value -= ((TrapUpgrade)(huone.Upgrade)).Damage; 89 90 peli.Splatter(huone.Position); 91 92 // Barbaarin tappo pudottaa latausmittarin nollaan. 87 TrapActivate(peli, barbaari, huone); 88 93 89 LatausMittari.Value = LatausMittari.MinValue; 94 90 … … 103 99 { 104 100 LatausMittari.Value++; 101 } 102 } 103 } 104 105 class DamageTrapUpgrade : TrapUpgrade 106 { 107 public int Damage { get; set; } 108 109 public override void TrapActivate(Dungeon peli, Barbaari barbaari, Room huone) 110 { 111 barbaari.Tenacity.Value -= Damage; 112 peli.Splatter(huone.Position); 113 } 114 } 115 116 class TeleTrapUpgrade : TrapUpgrade 117 { 118 public override void TrapActivate(Dungeon peli, Barbaari barbaari, Room huone) 119 { 120 var paikat = peli.RuutujenPaikat().Select(peli.GetRoom).Where(r => r.Upgrade == null && r.Dug).Select(r => r.Location).ToList(); 121 if (paikat.Count > 0) 122 { 123 Point paikka = RandomGen.SelectOne<Point>(paikat); 124 barbaari.Location = paikka; 125 barbaari.Position = peli.GetRoom(paikka).Position; 126 barbaari.Reitti.Clear(); 105 127 } 106 128 } … … 235 257 Image taideVeri = LoadImage("taideveri"); 236 258 private Image[] loppuKuvat = LoadImages2(1, 35, "break/b{0:0000}"); 259 private Image[] teleAnsaKuvat = LoadImages2(1, 8, "teletrap/tele{0:0000}"); 237 260 #endregion 238 261 … … 475 498 for (int i = 0; i < kultuuriKuvat.Length; i++) 476 499 { 477 PushButton kuva = new PushButton(kultuuriKuvat[i][0]); 478 kuva.Size = new Vector(1, 1) * RUUDUN_KOKO; 479 kuva.X = Window.ClientBounds.Width / 2 - 200; 480 kuva.Y = Window.ClientBounds.Height / 2 - (100 + RUUDUN_KOKO * i); 481 //kuva.Position = new Vector((Level.Right + Level.Width * 0.05), (Level.Top - Level.Height * 0.25 - (i * RUUDUN_KOKO))); 482 //kuva.Position = new Vector(Window.ClientBounds.Right, 0); 483 Add(kuva); 484 485 int indeksi = i; // Alla oleva delegaatti vaatii uuden indeksi muuttujan toimiakseen. 486 kuva.Clicked += delegate 500 int indeksi = i; 501 LuoKauppaPainike(kultuuriKuvat[i][0], hinnat[i], i, delegate 487 502 { 488 ostamassa = LuoKultuuriPaivitys(kultuuriKuvat[indeksi], hinnat[indeksi], kultuuriTuotot[indeksi], hajotusAanet[indeksi]); // TODO: tuotto[indeksi] 489 }; 490 491 Add(new Label 492 { 493 Position = kuva.Position + new Vector((RUUDUN_KOKO * 1.2), 0), 494 TextColor = Color.White, 495 Text = hinnat[i].ToString() 503 ostamassa = LuoKultuuriPaivitys(kultuuriKuvat[indeksi], hinnat[indeksi], kultuuriTuotot[indeksi], hajotusAanet[indeksi]); 496 504 }); 497 505 } … … 499 507 for (int i = 0; i < ansaKuvat.Length; i++) 500 508 { 501 PushButton kuva = new PushButton(ansaKuvat[i]);502 kuva.Size = new Vector(1, 1) * RUUDUN_KOKO;503 kuva.Color = Color.Gray;504 kuva.X = Window.ClientBounds.Width / 2 - 200;505 kuva.Y = Window.ClientBounds.Height / 2 - (100 + RUUDUN_KOKO * (kultuuriKuvat.Count() + i));506 //kuva.Position = new Vector((Level.Right + Level.Width * 0.05), (Level.Top - Level.Height * 0.25 - ((kultuuriKuvat.Count() + i) * RUUDUN_KOKO)));507 Add(kuva);508 509 509 int indeksi = i; 510 kuva.Clicked +=delegate510 LuoKauppaPainike(ansaKuvat[i], ansaHinnat[i], kultuuriKuvat.Count() + i, delegate 511 511 { 512 512 ostamassa = LuoAnsaPaivitys(ansaKuvat[indeksi], ansaHinnat[indeksi], ansaAnimaatiot[indeksi], vahingot[indeksi]); 513 };514 515 Add(new Label516 {517 Position = kuva.Position + new Vector((RUUDUN_KOKO * 1.2), 0),518 TextColor = Color.White,519 Text = ansaHinnat[i].ToString()520 513 }); 521 514 } 522 } 523 524 private void LuoAnsaHuoneenPainike(Image image, int hinta, Animation animation, int paikka, int vahinko) 525 { 526 PushButton kuva = new PushButton(image); 515 516 LuoKauppaPainike(teleAnsaKuvat[0], 1000, kultuuriKuvat.Length + ansaKuvat.Length, delegate 517 { 518 ostamassa = LuoTeleAnsaPaivitys(); 519 }); 520 } 521 522 private void LuoKauppaPainike(Image kuvake, int hinta, int paikka, Action toiminto) 523 { 524 var kuva = new PushButton(kuvake); 527 525 kuva.Size = new Vector(1, 1) * RUUDUN_KOKO; 528 526 kuva.Color = Color.Gray; 529 527 kuva.X = Window.ClientBounds.Width / 2 - 200; 530 kuva.Y = Window.ClientBounds.Height / 2 - (100 + RUUDUN_KOKO * (kultuuriKuvat.Count() + paikka)); 531 //kuva.Position = new Vector((Level.Right + Level.Width * 0.05), (Level.Top - Level.Height * 0.25 - ((kultuuriKuvat.Count() + i) * RUUDUN_KOKO))); 528 kuva.Y = Window.ClientBounds.Height / 2 - (100 + RUUDUN_KOKO * paikka); 532 529 Add(kuva); 533 530 534 kuva.Clicked += delegate 535 { 536 ostamassa = LuoAnsaPaivitys(image, hinta, animation, vahinko); 537 }; 531 kuva.Clicked += toiminto; 538 532 539 533 Add(new Label … … 545 539 } 546 540 547 548 549 541 Upgrade LuoAnsaPaivitys(Image kuva, int hinta, Animation animaatio, int vahinko) 550 542 { 551 return new TrapUpgrade543 return new DamageTrapUpgrade 552 544 { 553 545 Image = kuva, … … 556 548 Damage = vahinko, 557 549 Animation = new Animation(animaatio) 550 }; 551 } 552 553 Upgrade LuoTeleAnsaPaivitys() 554 { 555 return new TeleTrapUpgrade 556 { 557 Image = teleAnsaKuvat[0], 558 Size = new Vector(0.7, 0.7)*RUUDUN_KOKO, 559 Animation = new Animation(teleAnsaKuvat) 558 560 }; 559 561 } … … 577 579 barbaari.Tenacity.LowerLimit += delegate 578 580 { 579 barbaarit.Remove(barbaari);581 //barbaarit.Remove(barbaari); 580 582 barbaari.Destroy(); 581 583 }; … … 597 599 barbaari.Kohde = kohteet[RandomGen.NextInt(kohteet.Count)]; 598 600 barbaari.Reitti = FindPath(barbaari.Kohde, (barbaari.Location.Equals(spawn.Location)) ? spawn.Location : barbaari.Location); 601 602 // Reittiä ei löyty, kuollaan nälkään. 603 if (barbaari.Reitti.Count == 0) 604 { 605 barbaari.Destroy(); 606 607 // Jätetään joku nääntynyt ruumis lojumaan maahan hetkeksi. 608 var ruumis = new GameObject(barbaari.Width, barbaari.Height); 609 ruumis.Image = barbaari.Image; 610 ruumis.Position = barbaari.Position; 611 ruumis.Angle = Angle.FromDegrees(90); 612 ruumis.LifetimeLeft = TimeSpan.FromSeconds(3.0); 613 Add(ruumis); 614 } 599 615 } 600 616 … … 623 639 barbaari.MoveTo(huoneet[seuraavaPaikka.X, seuraavaPaikka.Y].Position, 100, () => SyklinPaatteeksi(b, seuraavaPaikka)); 624 640 } 641 642 // Poistetaan listalta tuhoutuneet barbaarit. 643 barbaarit.RemoveAll(b => b.IsDestroyed); 625 644 626 645 // Tarkistetaan onko barbaariaalto jo ohi. … … 884 903 } 885 904 886 IEnumerable<Point> RuutujenPaikat()905 public IEnumerable<Point> RuutujenPaikat() 887 906 { 888 907 return from y in Enumerable.Range(0, huoneet.GetLength(1)) … … 914 933 } 915 934 916 Room GetRoom(Point paikka)935 public Room GetRoom(Point paikka) 917 936 { 918 937 if (paikka.X >= 0 && paikka.X < huoneet.GetLength(0) && paikka.Y >= 0 && paikka.Y < huoneet.GetLength(1)) -
2015/24/ohjaajat/Dungeon/Dungeon/DungeonContent/DungeonContent.contentproj
r6108 r6111 588 588 </Compile> 589 589 </ItemGroup> 590 <ItemGroup> 591 <Compile Include="teletrap\tele0001.png"> 592 <Name>tele0001</Name> 593 <Importer>TextureImporter</Importer> 594 <Processor>TextureProcessor</Processor> 595 </Compile> 596 <Compile Include="teletrap\tele0002.png"> 597 <Name>tele0002</Name> 598 <Importer>TextureImporter</Importer> 599 <Processor>TextureProcessor</Processor> 600 </Compile> 601 <Compile Include="teletrap\tele0003.png"> 602 <Name>tele0003</Name> 603 <Importer>TextureImporter</Importer> 604 <Processor>TextureProcessor</Processor> 605 </Compile> 606 <Compile Include="teletrap\tele0004.png"> 607 <Name>tele0004</Name> 608 <Importer>TextureImporter</Importer> 609 <Processor>TextureProcessor</Processor> 610 </Compile> 611 <Compile Include="teletrap\tele0005.png"> 612 <Name>tele0005</Name> 613 <Importer>TextureImporter</Importer> 614 <Processor>TextureProcessor</Processor> 615 </Compile> 616 <Compile Include="teletrap\tele0006.png"> 617 <Name>tele0006</Name> 618 <Importer>TextureImporter</Importer> 619 <Processor>TextureProcessor</Processor> 620 </Compile> 621 <Compile Include="teletrap\tele0007.png"> 622 <Name>tele0007</Name> 623 <Importer>TextureImporter</Importer> 624 <Processor>TextureProcessor</Processor> 625 </Compile> 626 <Compile Include="teletrap\tele0008.png"> 627 <Name>tele0008</Name> 628 <Importer>TextureImporter</Importer> 629 <Processor>TextureProcessor</Processor> 630 </Compile> 631 </ItemGroup> 590 632 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 591 633 <!-- 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.