Changeset 6115 for 2015/24


Ignore:
Timestamp:
2015-06-21 19:07:24 (8 years ago)
Author:
sieerinn
Message:

Teoreettinen tuki usealle spawnille.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2015/24/ohjaajat/Dungeon/Dungeon/Dungeon/Dungeon.cs

    r6114 r6115  
    283283    public List<Barbaari> barbaarit; 
    284284    private Room[,] huoneet; 
    285     private Room spawn; 
     285    private List<Room> spawnit = new List<Room>(); 
    286286    private Timer barbaariAjastin; 
    287287    private Timer sykliAjastin; 
     
    618618        //Barbaari barbaari = new Barbaari(RUUDUN_KOKO * 0.4, RUUDUN_KOKO * 0.4, 0); 
    619619        barbaari.Color = Color.Red; 
     620        var spawn = RandomGen.SelectOne<Room>(spawnit); 
    620621        barbaari.Position = spawn.Position; 
    621622        barbaari.Location = spawn.Location; 
     
    632633        var kohteet = KultuuriHuoneidenPaikat(); 
    633634        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); 
    635636 
    636637        // Reittiä ei löyty, kuollaan nälkään. 
     
    750751    void LuoSpawn() 
    751752    { 
    752         spawn = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 
     753        var spawn = huoneet[(int)(huoneet.GetLength(0) * 0.5), 0]; 
    753754        spawn.Dug = true; 
     755        spawnit.Add(spawn); 
    754756 
    755757        Direction oviSuunta = Direction.Down; 
     
    840842    void AsetaPaivitys(Room huone) 
    841843    { 
    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)) 
    843845        { 
    844846            // 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) 
    846848                return; 
    847849 
     
    870872            var upg = room.Upgrade as CultureUpgrade; 
    871873 
    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)); 
    874876        } 
    875877    } 
Note: See TracChangeset for help on using the changeset viewer.