public static void Fill(MapBlock _block, int _worldSeed, EMapBlockTypes _baseType) { if (_baseType == EMapBlockTypes.NONE) return; switch (Constants.WORLD_SEED) { case 0: World.TheWorld.Avatar.GeoInfo.Layer.Ambient = FColor.Empty; _block.Map[16, 16] = ETerrains.GRAY_BRICK_WALL; _block.AddEssence(new IndoorLight(new LightSource(32, new FColor(1f, 1f, 0f, 0f)), EssenceHelper.GetFirstFoundedMaterial<MetalMaterial>()), new Point(10, 17)); _block.AddEssence(new IndoorLight(new LightSource(32, new FColor(1f, 0f, 1f, 0f)), EssenceHelper.GetFirstFoundedMaterial<MetalMaterial>()), new Point(22, 22)); _block.AddEssence(new IndoorLight(new LightSource(32, new FColor(1f, 0f, 0f, 1f)), EssenceHelper.GetFirstFoundedMaterial<MetalMaterial>()), new Point(22, 10)); break; case 1: _block.AddEssence(EssenceHelper.GetFirstFoundedThing<ClosedDoor>(), new Point(2, 1)); _block.AddEssence(EssenceHelper.GetFirstFoundedThing<ClosedDoor>(), new Point(1, 2)); _block.AddEssence(EssenceHelper.GetRandomFakedItem<AbstractWeapon>(World.Rnd), new Point(4, 1)); _block.AddEssence(EssenceHelper.GetRandomFakedItem<AbstractWeapon>(World.Rnd), new Point(3, 2)); _block.AddEssence(EssenceHelper.GetRandomFakedItem<Ring>(World.Rnd), new Point(5, 5)); _block.AddEssence(EssenceHelper.GetRandomFakedItem<StackOfAmmo>(World.Rnd), new Point(5, 5)); break; case 2: _block.AddEssence(new MagicPlate(EssenceHelper.GetFirstFoundedMaterial<MetalMaterial>(), 0, EMagicPlateEffect.RANDOM_MONSTER_APPEAR), new Point(10, 10)); _block.AddEssence(new Button(EssenceHelper.GetFirstFoundedMaterial<MetalMaterial>(), 0), new Point(1, 1)); break; } }
private List <ushort> GetInnerPatches(EMapBlockTypes _type) { var zone = m_infos[_type].Zone; var list = new List <ushort>(); foreach (var i in m_allZones) { var flag = true; if (m_united[i] != zone) { continue; } foreach (var j in m_allZones) { if (m_neighbours[i, j]) { if (m_united[j] != zone) { flag = false; break; } } } if (flag) { list.Add(i); } } return(list); }
public EMapBlockTypes[,] CreatePatchMap() { GenerateBaseMap(); var result = new EMapBlockTypes[m_size, m_size]; var zoneTypes = new Dictionary <ushort, EMapBlockTypes>(); foreach (var pair in m_infos) { if (pair.Value.Zone == 0) { continue; } zoneTypes.Add(pair.Value.Zone, pair.Key); } for (var x = 0; x < m_size; ++x) { for (var y = 0; y < m_size; ++y) { var val = m_united[m_map[x, y]]; EMapBlockTypes type; if (!zoneTypes.TryGetValue(val, out type)) { type = EMapBlockTypes.GROUND; } result[x, y] = type; } } return(result); }
public EMapBlockTypes[,] CreatePatchMap() { GenerateBaseMap(); var result = new EMapBlockTypes[m_size, m_size]; var zoneTypes = new Dictionary<ushort, EMapBlockTypes>(); foreach (var pair in m_infos) { if(pair.Value.Zone==0) continue; zoneTypes.Add(pair.Value.Zone, pair.Key); } for (var x = 0; x < m_size; ++x) { for (var y = 0; y < m_size; ++y) { var val = m_united[m_map[x, y]]; EMapBlockTypes type; if (!zoneTypes.TryGetValue(val, out type)) { type = EMapBlockTypes.GROUND; } result[x, y] = type; } } return result; }
public static void Fill(MapBlock _block, int _worldSeed, EMapBlockTypes _baseType) { if (_baseType == EMapBlockTypes.NONE) { return; } switch (Constants.WORLD_SEED) { case 0: World.TheWorld.Avatar.GeoInfo.Layer.Ambient = FColor.Empty; _block.Map[16, 16] = ETerrains.GRAY_BRICK_WALL; _block.AddEssence(new IndoorLight(new LightSource(32, new FColor(1f, 1f, 0f, 0f)), EssenceHelper.GetFirstFoundedMaterial <MetalMaterial>()), new Point(10, 17)); _block.AddEssence(new IndoorLight(new LightSource(32, new FColor(1f, 0f, 1f, 0f)), EssenceHelper.GetFirstFoundedMaterial <MetalMaterial>()), new Point(22, 22)); _block.AddEssence(new IndoorLight(new LightSource(32, new FColor(1f, 0f, 0f, 1f)), EssenceHelper.GetFirstFoundedMaterial <MetalMaterial>()), new Point(22, 10)); break; case 1: _block.AddEssence(EssenceHelper.GetFirstFoundedThing <ClosedDoor>(), new Point(2, 1)); _block.AddEssence(EssenceHelper.GetFirstFoundedThing <ClosedDoor>(), new Point(1, 2)); _block.AddEssence(EssenceHelper.GetRandomFakedItem <AbstractWeapon>(World.Rnd), new Point(4, 1)); _block.AddEssence(EssenceHelper.GetRandomFakedItem <AbstractWeapon>(World.Rnd), new Point(3, 2)); _block.AddEssence(EssenceHelper.GetRandomFakedItem <Ring>(World.Rnd), new Point(5, 5)); _block.AddEssence(EssenceHelper.GetRandomFakedItem <StackOfAmmo>(World.Rnd), new Point(5, 5)); break; case 2: _block.AddEssence(new MagicPlate(EssenceHelper.GetFirstFoundedMaterial <MetalMaterial>(), 0, EMagicPlateEffect.RANDOM_MONSTER_APPEAR), new Point(10, 10)); _block.AddEssence(new Button(EssenceHelper.GetFirstFoundedMaterial <MetalMaterial>(), 0), new Point(1, 1)); break; } }
private void Fill(EMapBlockTypes _type) { m_blocks[0, 0] = _type; m_blocks[1, 0] = _type; m_blocks[0, 1] = _type; m_blocks[1, 1] = _type; }
private void FillInnerPatches(IEnumerable <ushort> _list, EMapBlockTypes _type) { if (!_list.Any()) { return; } m_infos[_type].Zone = _list.First(_arg => !m_forbidToUnite[_arg]); foreach (var i in _list) { m_united[i] = m_infos[_type].Zone; } }
public TreeMazeDungeonLayer(Point _enterCoords, Random _rnd) : base(_enterCoords) { var enterBlock = BaseMapBlock.GetBlockId(_enterCoords); var size = _rnd.Next(5) + _rnd.Next(5) + 5; var center = new Point(size, size)/2; var map = new EMapBlockTypes[size,size]; var list = LayerHelper.GetRandomPoints(center, _rnd, map, size, EMapBlockTypes.GROUND, EMapBlockTypes.NONE); var blockIds = list.Distinct().Select(_point => _point - center + enterBlock).ToArray(); foreach (var blockId in blockIds) { BaseMapBlock block; if (!m_mazeBlocks.TryGetValue(blockId, out block)) { block = new BaseMapBlock(blockId); } if (BaseMapBlock.GetBlockId(EnterCoords) == blockId) { GenerateInternal(block, new[] {BaseMapBlock.GetInBlockCoords(EnterCoords)}); } else { GenerateInternal(block); } m_mazeBlocks[block.BlockId] = block; } var connectionPoints = new List<ConnectionPoint>(); foreach (var block in blockIds.Select(_blockId => m_mazeBlocks[_blockId])) { var rnd = new Random(block.RandomSeed); foreach (var room in block.Rooms) { connectionPoints.AddRange(AddConnectionPoints(block, room, rnd)); } } LinkRooms(connectionPoints); foreach (var mapBlock in m_mazeBlocks.Values) { foreach (var room in mapBlock.Rooms.Where(_room => _room.IsConnected)) { var border = room.RoomRectangle.BorderPoints.ToArray(); foreach (var point in border) { if (_rnd.NextDouble() > 0.7) { var dir = EDirections.NONE; if (point.X > 0 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X - 1, point.Y]).IsNotPassable) { dir = EDirections.RIGHT; } else if (point.X < Constants.MAP_BLOCK_SIZE - 1 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X + 1, point.Y]).IsNotPassable) { dir = EDirections.LEFT; } else if (point.Y > 0 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X, point.Y - 1]).IsNotPassable) { dir = EDirections.DOWN; } else if (point.Y < Constants.MAP_BLOCK_SIZE - 1 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X, point.Y + 1]).IsNotPassable) { dir = EDirections.UP; } if (dir == EDirections.NONE) continue; var fColor = new FColor(3f, (float) _rnd.NextDouble(), (float) _rnd.NextDouble(), (float) _rnd.NextDouble()); mapBlock.AddEssence(new OnWallTorch(new LightSource(_rnd.Next(4) + 3, fColor), dir, EssenceHelper.GetFirstFoundedMaterial<WoodMaterial>()), point); break; } } } } }
public static FColor GetColor(EMapBlockTypes _type) { return(m_colors[_type]); }
public static MapBlock GenerateBlock(Point _blockId, Surface _surface) { var block = new MapBlock(_blockId); var baseType = _surface.GetBlockType(_blockId); if (baseType == EMapBlockTypes.NONE) { return(block); } var rnd = new Random(block.RandomSeed); var pm = new EMapBlockTypes[Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE]; var points = Constants.MAP_BLOCK_SIZE * Constants.MAP_BLOCK_SIZE; var toAdd = new List <EMapBlockTypes> { baseType, baseType, baseType }; #region размытие границ с соседними блоками foreach (var dir in Util.AllDirections) { Point from; Point to; switch (dir) { case EDirections.UP: from = Point.Zero; to = new Point(Constants.MAP_BLOCK_SIZE - 2, 0); break; case EDirections.DOWN: from = new Point(1, Constants.MAP_BLOCK_SIZE - 1); to = new Point(Constants.MAP_BLOCK_SIZE - 1, Constants.MAP_BLOCK_SIZE - 1); break; case EDirections.LEFT: from = new Point(0, Constants.MAP_BLOCK_SIZE - 1); to = new Point(0, 1); break; case EDirections.RIGHT: from = new Point(Constants.MAP_BLOCK_SIZE - 1, 0); to = new Point(Constants.MAP_BLOCK_SIZE - 1, Constants.MAP_BLOCK_SIZE - 2); break; default: throw new ArgumentOutOfRangeException(); } var delta = dir.GetDelta(); var nearestBlockId = _blockId + delta; var type = _surface.GetBlockType(nearestBlockId); if (type == EMapBlockTypes.NONE) { type = baseType; } toAdd.Add(type); if (_surface.Blocks.ContainsKey(nearestBlockId)) { var nearestBlock = _surface.Blocks[nearestBlockId]; foreach (var point in from.GetLineToPoints(to)) { type = TerrainAttribute.GetMapBlockType( nearestBlock.Map[ (point.X + delta.X + Constants.MAP_BLOCK_SIZE) % Constants.MAP_BLOCK_SIZE, (point.Y + delta.Y + Constants.MAP_BLOCK_SIZE) % Constants.MAP_BLOCK_SIZE]); pm[point.X, point.Y] = type; points--; } } else { foreach (var point in from.GetLineToPoints(to)) { pm[point.X, point.Y] = type; points--; } } } #endregion foreach (var t in toAdd) { var pnt = Point.Zero; while (pm[pnt.X, pnt.Y] != EMapBlockTypes.NONE) { pnt = new Point(1 + rnd.Next(Constants.MAP_BLOCK_SIZE - 2), 1 + rnd.Next(Constants.MAP_BLOCK_SIZE - 2)); } pm[pnt.X, pnt.Y] = t; points--; } var dpoints = Util.AllDeltas; while (points > 0) { foreach (var point in Point.AllBlockPoints) { var xy = pm[point.X, point.Y]; if (xy == 0) { continue; } var dpoint = dpoints[rnd.Next(4)]; var x1 = point.X + dpoint.X; if (x1 < 0 || x1 == Constants.MAP_BLOCK_SIZE) { continue; } var y1 = point.Y + dpoint.Y; if (y1 < 0 || y1 == Constants.MAP_BLOCK_SIZE) { continue; } var xy1 = pm[x1, y1]; if (xy1 == 0) { pm[x1, y1] = xy; points--; } } } #region заполнение карты блока foreach (var pnt in new Rct(0, 0, Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE).AllPoints) { ETerrains tr; switch (pm[pnt.X, pnt.Y]) { case EMapBlockTypes.NONE: continue; case EMapBlockTypes.GROUND: tr = ETerrains.GRASS; break; case EMapBlockTypes.FOREST: tr = ETerrains.FOREST; break; case EMapBlockTypes.SEA: tr = ETerrains.SEA; break; case EMapBlockTypes.DEEP_SEA: tr = ETerrains.DEEP_SEA; break; case EMapBlockTypes.FRESH_WATER: tr = ETerrains.FRESH_WATER; break; case EMapBlockTypes.DEEP_FRESH_WATER: tr = ETerrains.DEEP_FRESH_WATER; break; case EMapBlockTypes.CITY: tr = ETerrains.GROUND; break; case EMapBlockTypes.COAST: tr = ETerrains.COAST; break; case EMapBlockTypes.LAKE_COAST: tr = ETerrains.LAKE_COAST; break; case EMapBlockTypes.MOUNT: tr = ETerrains.MOUNT; break; case EMapBlockTypes.SWAMP: tr = ETerrains.SWAMP; break; case EMapBlockTypes.ETERNAL_SNOW: tr = ETerrains.ETERNAL_SNOW; break; case EMapBlockTypes.SHRUBS: tr = ETerrains.SHRUBS; break; default: throw new ArgumentOutOfRangeException(); } block.Map[pnt.X, pnt.Y] = tr; } #endregion return(block); }
public static FColor GetColor(EMapBlockTypes _type) { return m_colors[_type]; }
private static IEnumerable <Point> Add(Point _xy, EMapBlockTypes[,] _map, ref int _size, EMapBlockTypes _set, Random _rnd, EMapBlockTypes _empty) { var list = new List <Point>(); if (_map[_xy.X, _xy.Y] == _empty) { list.Add(_xy); _map[_xy.X, _xy.Y] = _set; if (_size == 0 || _rnd.NextDouble() < 0.1) { return(list); } _size--; } var dirs = _rnd.GetRandomDirections(); foreach (var dir in dirs.AllDirectionsIn()) { var xy = _xy + dir.GetDelta(); if (_map.GetLength(0) <= xy.X || xy.X < 0) { continue; } if (_map.GetLength(1) <= xy.Y || xy.Y < 0) { continue; } if (_map[xy.X, xy.Y] == _empty) { list.AddRange(Add(xy, _map, ref _size, _set, _rnd, _empty)); } } return(list); }
public static IEnumerable <Point> GetRandomPoints(Point _center, Random _rnd, EMapBlockTypes[,] _map, int _size, EMapBlockTypes _set, EMapBlockTypes _empty) { var tries = 10; var list = new List <Point> { _center }; do { var point = list[_rnd.Next(list.Count)]; var add = Add(point, _map, ref _size, _set, _rnd, _empty); if (add.Any()) { tries = 10; } else { tries--; } list.AddRange(add); } while (_size > 0 && tries > 0); return(list.Distinct()); }
public static MapBlock GenerateBlock(Point _blockId, Surface _surface) { var block = new MapBlock(_blockId); var baseType = _surface.GetBlockType(_blockId); if (baseType == EMapBlockTypes.NONE) { return block; } var rnd = new Random(block.RandomSeed); var pm = new EMapBlockTypes[Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE]; var points = Constants.MAP_BLOCK_SIZE * Constants.MAP_BLOCK_SIZE; var toAdd = new List<EMapBlockTypes> { baseType, baseType, baseType }; #region размытие границ с соседними блоками foreach (var dir in Util.AllDirections) { Point from; Point to; switch (dir) { case EDirections.UP: from = Point.Zero; to = new Point(Constants.MAP_BLOCK_SIZE - 2, 0); break; case EDirections.DOWN: from = new Point(1, Constants.MAP_BLOCK_SIZE - 1); to = new Point(Constants.MAP_BLOCK_SIZE - 1, Constants.MAP_BLOCK_SIZE - 1); break; case EDirections.LEFT: from = new Point(0, Constants.MAP_BLOCK_SIZE - 1); to = new Point(0, 1); break; case EDirections.RIGHT: from = new Point(Constants.MAP_BLOCK_SIZE - 1, 0); to = new Point(Constants.MAP_BLOCK_SIZE - 1, Constants.MAP_BLOCK_SIZE - 2); break; default: throw new ArgumentOutOfRangeException(); } var delta = dir.GetDelta(); var nearestBlockId = _blockId + delta; var type = _surface.GetBlockType(nearestBlockId); if (type == EMapBlockTypes.NONE) { type = baseType; } toAdd.Add(type); if (_surface.Blocks.ContainsKey(nearestBlockId)) { var nearestBlock = _surface.Blocks[nearestBlockId]; foreach (var point in from.GetLineToPoints(to)) { type = TerrainAttribute.GetMapBlockType( nearestBlock.Map[ (point.X + delta.X + Constants.MAP_BLOCK_SIZE) % Constants.MAP_BLOCK_SIZE, (point.Y + delta.Y + Constants.MAP_BLOCK_SIZE) % Constants.MAP_BLOCK_SIZE]); pm[point.X, point.Y] = type; points--; } } else { foreach (var point in from.GetLineToPoints(to)) { pm[point.X, point.Y] = type; points--; } } } #endregion foreach (var t in toAdd) { var pnt = Point.Zero; while (pm[pnt.X, pnt.Y] != EMapBlockTypes.NONE) { pnt = new Point(1 + rnd.Next(Constants.MAP_BLOCK_SIZE - 2), 1 + rnd.Next(Constants.MAP_BLOCK_SIZE - 2)); } pm[pnt.X, pnt.Y] = t; points--; } var dpoints = Util.AllDeltas; while (points > 0) { foreach (var point in Point.AllBlockPoints) { var xy = pm[point.X, point.Y]; if (xy == 0) continue; var dpoint = dpoints[rnd.Next(4)]; var x1 = point.X + dpoint.X; if (x1 < 0 || x1 == Constants.MAP_BLOCK_SIZE) continue; var y1 = point.Y + dpoint.Y; if (y1 < 0 || y1 == Constants.MAP_BLOCK_SIZE) continue; var xy1 = pm[x1, y1]; if (xy1 == 0) { pm[x1, y1] = xy; points--; } } } #region заполнение карты блока foreach (var pnt in new Rct(0, 0, Constants.MAP_BLOCK_SIZE, Constants.MAP_BLOCK_SIZE).AllPoints) { ETerrains tr; switch (pm[pnt.X, pnt.Y]) { case EMapBlockTypes.NONE: continue; case EMapBlockTypes.GROUND: tr = ETerrains.GRASS; break; case EMapBlockTypes.FOREST: tr = ETerrains.FOREST; break; case EMapBlockTypes.SEA: tr = ETerrains.SEA; break; case EMapBlockTypes.DEEP_SEA: tr = ETerrains.DEEP_SEA; break; case EMapBlockTypes.FRESH_WATER: tr = ETerrains.FRESH_WATER; break; case EMapBlockTypes.DEEP_FRESH_WATER: tr = ETerrains.DEEP_FRESH_WATER; break; case EMapBlockTypes.CITY: tr = ETerrains.GROUND; break; case EMapBlockTypes.COAST: tr = ETerrains.COAST; break; case EMapBlockTypes.LAKE_COAST: tr = ETerrains.LAKE_COAST; break; case EMapBlockTypes.MOUNT: tr = ETerrains.MOUNT; break; case EMapBlockTypes.SWAMP: tr = ETerrains.SWAMP; break; case EMapBlockTypes.ETERNAL_SNOW: tr = ETerrains.ETERNAL_SNOW; break; case EMapBlockTypes.SHRUBS: tr = ETerrains.SHRUBS; break; default: throw new ArgumentOutOfRangeException(); } block.Map[pnt.X, pnt.Y] = tr; } #endregion return block; }
private static IEnumerable<Point> Add(Point _xy, EMapBlockTypes[,] _map, ref int _size, EMapBlockTypes _set, Random _rnd, EMapBlockTypes _empty) { var list = new List<Point>(); if (_map[_xy.X, _xy.Y] == _empty) { list.Add(_xy); _map[_xy.X, _xy.Y] = _set; if (_size == 0 || _rnd.NextDouble() < 0.1) { return list; } _size--; } var dirs = _rnd.GetRandomDirections(); foreach (var dir in dirs.AllDirectionsIn()) { var xy = _xy + dir.GetDelta(); if (_map.GetLength(0) <= xy.X || xy.X < 0) continue; if (_map.GetLength(1) <= xy.Y || xy.Y < 0) continue; if (_map[xy.X, xy.Y] == _empty) { list.AddRange(Add(xy, _map, ref _size, _set, _rnd, _empty)); } } return list; }
private List<ushort> GetInnerPatches(EMapBlockTypes _type) { var zone = m_infos[_type].Zone; var list = new List<ushort>(); foreach (var i in m_allZones) { var flag = true; if (m_united[i] != zone) continue; foreach (var j in m_allZones) { if(m_neighbours[i,j]) { if (m_united[j] != zone) { flag = false; break; } } } if (flag) { list.Add(i); } } return list; }
public static IEnumerable<Point> GetRandomPoints(Point _center, Random _rnd, EMapBlockTypes[,] _map, int _size, EMapBlockTypes _set, EMapBlockTypes _empty) { var tries = 10; var list = new List<Point> {_center}; do { var point = list[_rnd.Next(list.Count)]; var add = Add(point, _map, ref _size, _set, _rnd, _empty); if (add.Any()) { tries = 10; } else { tries--; } list.AddRange(add); } while (_size > 0 && tries > 0); return list.Distinct(); }
private void FillInnerPatches(IEnumerable<ushort> _list, EMapBlockTypes _type) { if(!_list.Any()) return; m_infos[_type].Zone = _list.First(_arg => !m_forbidToUnite[_arg]); foreach (var i in _list) { m_united[i] = m_infos[_type].Zone; } }
public TreeMazeDungeonLayer(Point _enterCoords, Random _rnd) : base(_enterCoords) { var enterBlock = BaseMapBlock.GetBlockId(_enterCoords); var size = _rnd.Next(5) + _rnd.Next(5) + 5; var center = new Point(size, size) / 2; var map = new EMapBlockTypes[size, size]; var list = LayerHelper.GetRandomPoints(center, _rnd, map, size, EMapBlockTypes.GROUND, EMapBlockTypes.NONE); var blockIds = list.Distinct().Select(_point => _point - center + enterBlock).ToArray(); foreach (var blockId in blockIds) { BaseMapBlock block; if (!m_mazeBlocks.TryGetValue(blockId, out block)) { block = new BaseMapBlock(blockId); } if (BaseMapBlock.GetBlockId(EnterCoords) == blockId) { GenerateInternal(block, new[] { BaseMapBlock.GetInBlockCoords(EnterCoords) }); } else { GenerateInternal(block); } m_mazeBlocks[block.BlockId] = block; } var connectionPoints = new List <ConnectionPoint>(); foreach (var block in blockIds.Select(_blockId => m_mazeBlocks[_blockId])) { var rnd = new Random(block.RandomSeed); foreach (var room in block.Rooms) { connectionPoints.AddRange(AddConnectionPoints(block, room, rnd)); } } LinkRooms(connectionPoints); foreach (var mapBlock in m_mazeBlocks.Values) { foreach (var room in mapBlock.Rooms.Where(_room => _room.IsConnected)) { var border = room.RoomRectangle.BorderPoints.ToArray(); foreach (var point in border) { if (_rnd.NextDouble() > 0.7) { var dir = EDirections.NONE; if (point.X > 0 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X - 1, point.Y]).IsNotPassable) { dir = EDirections.RIGHT; } else if (point.X < Constants.MAP_BLOCK_SIZE - 1 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X + 1, point.Y]).IsNotPassable) { dir = EDirections.LEFT; } else if (point.Y > 0 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X, point.Y - 1]).IsNotPassable) { dir = EDirections.DOWN; } else if (point.Y < Constants.MAP_BLOCK_SIZE - 1 && TerrainAttribute.GetAttribute(mapBlock.Map[point.X, point.Y + 1]).IsNotPassable) { dir = EDirections.UP; } if (dir == EDirections.NONE) { continue; } var fColor = new FColor(3f, (float)_rnd.NextDouble(), (float)_rnd.NextDouble(), (float)_rnd.NextDouble()); mapBlock.AddEssence(new OnWallTorch(new LightSource(_rnd.Next(4) + 3, fColor), dir, EssenceHelper.GetFirstFoundedMaterial <WoodMaterial>()), point); break; } } } } }