public ChunkTemplate(Chunk chunk, ChunkConnector[][] connectors, params DungeonClass[] mapTypes) { myConnectors = connectors; myWidth = chunk.Width; myHeight = chunk.Height; myMapTypes = mapTypes; myEntities = chunk.Entities; myTiles = new TileTemplate[Width, Height]; for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { GameTile tile = chunk.GetTile(x - chunk.X, y - chunk.Y); myTiles[x, y] = new TileTemplate { IsWall = tile.IsWall, Skin = tile.Skin, Alt = tile.Alt }; } } FindOrganisedConnectors(); }
public GameTile GetTile(int x, int y) { Chunk chunk = GetChunk(x, y); if (chunk == null) { if (IsInterior) { return(InteriorTile.Default); } else { return(ExteriorTile.Default); } } return(chunk.GetTile(x, y) ?? (IsInterior ? (GameTile)InteriorTile.Default : (GameTile)ExteriorTile.Default)); }
public void GenerateChunk(Chunk chunk) { for (int x = chunk.X; x < chunk.X + chunk.Width; ++x) { for (int y = chunk.Y; y < chunk.Y + chunk.Height; ++y) { double height = GetHeight(x, y); double temp = GetTemperature(x, y); ExteriorTile tile = chunk.GetTile(x, y) as ExteriorTile; tile.IsWall = false; if (height >= 0.25) { if (height >= 0.5) { tile.Skin = 3; } else { tile.Skin = 1; } tile.WallHeight = 1; } else if (height >= -1.0 && temp < 0.25) { tile.Skin = 1; } else if (height < -0.5 && temp < 0.25) { tile.Skin = 2; } else { tile.Skin = 0; } } } chunk.UpdateTiles(); }