Пример #1
0
        private void PlaceHotspot(int x, int y, int danger)
        {
            var dangerGradientSize = (int)(Math.Sqrt(Width * Height) / DangerHotspotTightness);

            if (CoordsInBounds(x, y))
            {
                Tiles[x, y].DangerLevel = Math.Max(danger, Tiles[x, y].DangerLevel);
                Tiles[x, y].Formation   = Formation.SpawnMonsters(danger);
            }
            for (int dx = 0; dx < danger * dangerGradientSize; dx++)
            {
                for (int dy = 0; dy < danger * dangerGradientSize; dy++)
                {
                    if (CoordsInBounds(x + dx, y + dy))
                    {
                        Tiles[x + dx, y + dy].DangerLevel = Math.Max(danger - dx / dangerGradientSize - dy / dangerGradientSize, Tiles[x + dx, y + dy].DangerLevel);
                    }
                    if (CoordsInBounds(x + dx, y - dy))
                    {
                        Tiles[x + dx, y - dy].DangerLevel = Math.Max(danger - dx / dangerGradientSize - dy / dangerGradientSize, Tiles[x + dx, y - dy].DangerLevel);
                    }
                    if (CoordsInBounds(x - dx, y + dy))
                    {
                        Tiles[x - dx, y + dy].DangerLevel = Math.Max(danger - dx / dangerGradientSize - dy / dangerGradientSize, Tiles[x - dx, y + dy].DangerLevel);
                    }
                    if (CoordsInBounds(x - dx, y - dy))
                    {
                        Tiles[x - dx, y - dy].DangerLevel = Math.Max(danger - dx / dangerGradientSize - dy / dangerGradientSize, Tiles[x - dx, y - dy].DangerLevel);
                    }
                }
            }
        }
Пример #2
0
 private void PlaceMonsters()
 {
     for (var i = 0; i < Width * Height / MonsterRarity; i++)
     {
         var tile = Tiles.Cast <Tile>().Where(t => t.Formation == null && t.DangerLevel > 0).Pick();
         tile.Formation = Formation.SpawnMonsters(tile.DangerLevel);
     }
 }