private static void TryWallIn(Dungeon dungeon, DungeonRoom room, DungeonTheme theme, int2 key, BuilderDirection direction) { var value = dungeon.ValueMap[key]; if (value.Theme != theme) { return; } var adjacentKey = GetAdjacentKey(dungeon, key, direction); if (dungeon.ValueMap.ContainsKey(adjacentKey) == false) { var tile = new Dungeon.MapValue { Theme = theme, Index = DungeonTile.Index.Wall, Room = room, }; dungeon.ValueMap.Add(adjacentKey, tile); room.ValueMap.Add(adjacentKey, value); } var adjacent = dungeon.ValueMap[adjacentKey]; if (adjacent.Theme != theme) { // If we're at a forest tile and the adjacent tile is already a wall, we don't always want to place a forest wall tile. if (adjacent.Index == DungeonTile.Index.Wall && value.Theme == DungeonTheme.Forest) { if (Random.value < 0.4f) { dungeon.ValueMap[key].Index = DungeonTile.Index.Wall; } } else { dungeon.ValueMap[key].Index = DungeonTile.Index.Wall; } if (room.ConnectionMap.ContainsKey(key) == false) { var adjacentRoom = dungeon.GetRoom(adjacentKey); if (adjacentRoom != null) { room.ConnectionMap.Add(key, new Tuple <int2, DungeonRoom>( adjacentKey, adjacentRoom)); if (adjacentRoom.ConnectionMap.ContainsKey(adjacentKey) == false) { adjacentRoom.ConnectionMap.Add(adjacentKey, new Tuple <int2, DungeonRoom>( key, room)); } } } } }
private void SetSprite(SpriteRenderer tileView, Dungeon.MapValue value, bool isEdge, bool isBorder) { Color color; var sprite = _sprites.Find(value.Theme, value.Index, isEdge, isBorder, out color); tileView.sprite = sprite; tileView.color = color; }
private static void TryWallOutTheVoid(Dungeon dungeon, DungeonRoom room, int2 key, Dungeon.MapValue origin, BuilderDirection direction) { var value = dungeon.ValueMap[key]; var adjacentKey = GetAdjacentKey(dungeon, key, direction); if (dungeon.ValueMap.ContainsKey(adjacentKey) == false) { var tile = new Dungeon.MapValue { Theme = origin.Theme, Index = DungeonTile.Index.Wall, Room = room, }; dungeon.ValueMap.Add(adjacentKey, tile); room.ValueMap.Add(adjacentKey, value); } }
private void AddCircularFloor(Dungeon dungeon) { var halfWidth = _meta.Width / 2; var halfHeight = _meta.Height / 2; for (var dx = -halfWidth; dx <= halfWidth; dx++) { for (var dy = -halfHeight; dy <= halfHeight; dy++) { var x = _meta.CenterX + dx; var y = _meta.CenterY + dy; var key = new int2(x, y); if (dungeon.ValueMap.ContainsKey(key)) { var tile = dungeon.ValueMap[key]; if (tile.Index != DungeonTile.Index.Wall) { tile.Theme = _meta.Theme; tile.Index = DungeonTile.Index.Floor; if (tile.Room != this) { tile.Room.ValueMap.Remove(key); tile.Room = this; tile.Room.ValueMap.Add(key, tile); } } } else { var tile = new Dungeon.MapValue { Theme = _meta.Theme, Index = DungeonTile.Index.Floor, Room = this, }; dungeon.ValueMap.Add(key, tile); ValueMap.Add(key, tile); } } } }