/// <summary> /// This constructor is used when creating a new world from scratch. /// </summary> /// <param name="minTile"></param> /// <param name="maxTile"></param> /// <param name="minHeight"></param> /// <param name="maxHeight"></param> /// <param name="defaultHeight"></param> public WorldMap(string worldName, CoordXZ minTile, CoordXZ maxTile, float minHeight, float maxHeight, float defaultHeight) { this.worldName = worldName; this.minTile = minTile; this.maxTile = maxTile; this.minHeight = minHeight; this.maxHeight = maxHeight; emptyOWP = new List<IObjectWithProperties>(); layerAndWorldOWP = new List<IObjectWithProperties>(); properties = new MapProperties(this); layers = new Dictionary<string, MapLayer>(); InitLayers(defaultHeight); // create map sections sections = new Dictionary<CoordXZ, MapSection>(); zones = new Dictionary<string, MapZone>(); CoordXZ minSection = new CoordXZ(minTile, sectionSize); CoordXZ maxSection = new CoordXZ(maxTile, sectionSize); for (int z = minSection.z; z <= maxSection.z; z++) { for (int x = minSection.x; x <= maxSection.x; x++) { CoordXZ sectionCoord = new CoordXZ(x, z, sectionSize); sections[sectionCoord] = new MapSection(this, sectionCoord); } } }
public MapTile GetTile(CoordXZ tileCoord) { MapSection section = GetSection(tileCoord); return(section.GetTile(tileCoord)); }
public MapSection GetSection(CoordXZ tileCoord) { CoordXZ sectionCoord = new CoordXZ(tileCoord, sectionSize); if (!sections.ContainsKey(sectionCoord)) { sections[sectionCoord] = new MapSection(this, sectionCoord, worldPath); } return sections[sectionCoord]; }