protected void AddTileLine(IntPair startPos, DungeonRoomTileType type, int length, Direction direction) { IntPair intDir = direction.ToVector2(); for (int i = 0; i < length; i++) { IntPair tilePos = startPos + intDir * i; AddTile(tilePos, type); } }
protected void AddTile(IntPair tilePos, DungeonRoomTileType type) { int tileIndex = TileIndex(tilePos); if (tileIndex != -1) { tiles[tileIndex] = new DungeonRoomTile(type, tilePos); } else { tiles.Add(new DungeonRoomTile(type, tilePos)); } }
private void CreateTile(int x, int y, DungeonRoomTileType tileType, PlanetVisualData dataSet) { Vector3Int position = new Vector3Int(x, y, 0); switch (tileType) { case DungeonRoomTileType.Wall: wallMap.SetTile(position, dataSet.wallTile); break; case DungeonRoomTileType.Floor: floorMap.SetTile(position, dataSet.floorTile); float randomVal = UnityEngine.Random.value; if (randomVal <= dataSet.detailChance) { floorDetailMap.SetTile(position, dataSet.floorDetailTile); } break; } }
public void GenerateOuterWalls() { for (int x = boundaries.Left - EXIT_LENGTH; x <= boundaries.Right + EXIT_LENGTH; x++) { for (int y = boundaries.Down - EXIT_LENGTH; y <= boundaries.Up + EXIT_LENGTH; y++) { if (x < boundaries.Left || x > boundaries.Right || y < boundaries.Down || y > boundaries.Up) { IntPair tilePos = new IntPair(x, y); AddTile(tilePos, DungeonRoomTileType.Wall); } } } for (int i = 0; i < exitExists.ValuesLength; i++) { Direction dir = (Direction)i; if (exitExists[dir]) { IntPair exitPos = exitPositions[dir]; for (int j = -1; j < EXIT_WIDTH + 1; j++) { DungeonRoomTileType tileType = j == -1 || j == EXIT_WIDTH ? DungeonRoomTileType.Wall : DungeonRoomTileType.Floor; Direction clockwiseDir = dir.Clockwise().ToPositiveDirection(); IntPair lineIntDir = clockwiseDir.ToVector2(); IntPair startPos = exitPos + lineIntDir * j; AddTileLine(startPos, tileType, EXIT_LENGTH, dir); } } } }
public DungeonRoomTile(DungeonRoomTileType type, IntPair position) { this.type = type; Position = position; }