- Timestamp:
- 2015-06-21 19:07:24 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.cs
r6114 r6115 283 283 public List<Barbaari> barbaarit; 284 284 private Room[,] huoneet; 285 private Room spawn;285 private List<Room> spawnit = new List<Room>(); 286 286 private Timer barbaariAjastin; 287 287 private Timer sykliAjastin; … … 618 618 //Barbaari barbaari = new Barbaari(RUUDUN_KOKO * 0.4, RUUDUN_KOKO * 0.4, 0); 619 619 barbaari.Color = Color.Red; 620 var spawn = RandomGen.SelectOne<Room>(spawnit); 620 621 barbaari.Position = spawn.Position; 621 622 barbaari.Location = spawn.Location; … … 632 633 var kohteet = KultuuriHuoneidenPaikat(); 633 634 barbaari.Kohde = kohteet[RandomGen.NextInt(kohteet.Count)]; 634 barbaari.Reitti = FindPath(barbaari.Kohde, (barbaari.Location.Equals(spawn.Location)) ? spawn.Location :barbaari.Location);635 barbaari.Reitti = FindPath(barbaari.Kohde, barbaari.Location); 635 636 636 637 // Reittiä ei löyty, kuollaan nälkään. … … 750 751 void LuoSpawn() 751 752 { 752 spawn = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0];753 var spawn = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 753 754 spawn.Dug = true; 755 spawnit.Add(spawn); 754 756 755 757 Direction oviSuunta = Direction.Down; … … 840 842 void AsetaPaivitys(Room huone) 841 843 { 842 if (ostamassa != null && huone.Dug && kultuuri.Value >= ostamassa.Price && huone.Upgrade == null && huone != spawn)844 if (ostamassa != null && huone.Dug && kultuuri.Value >= ostamassa.Price && huone.Upgrade == null && spawnit.All(s => huone != s)) 843 845 { 844 846 // Kultuuripäivityksistä pitää olla reitti spawniin. 845 if (ostamassa is CultureUpgrade && FindPath(huone.Location, spawn.Location).Count== 0)847 if (ostamassa is CultureUpgrade && spawnit.Sum(s => FindPath(huone.Location, s.Location).Count) == 0) 846 848 return; 847 849 … … 870 872 var upg = room.Upgrade as CultureUpgrade; 871 873 872 List<Point> polku = FindPath(room.Location, spawn.Location);873 upg.Culture.Value = Math.Max(0, upg.Culture.MaxValue - (int)(upg.Culture.MaxValue * 0.10 * polku.Count));874 int lyhinPolku = spawnit.Min(s => FindPath(room.Location, s.Location).Count); 875 upg.Culture.Value = Math.Max(0, upg.Culture.MaxValue - (int)(upg.Culture.MaxValue * 0.10 * lyhinPolku)); 874 876 } 875 877 }
Note: See TracChangeset
for help on using the changeset viewer.