public List<clsTemplate> getAllTemplates() { clsTemplate template = new clsTemplate(this.db); return template.getAllTemplates(); }
public string SaveMap(clsPoint worldLocation) { int size = heights.GetLength(0); // clear block clsPoint worldLocationBotRight = new clsPoint(worldLocation.x + heights.Length - 1, worldLocation.y + heights.Length - 1); this.destroyArea(worldLocation, worldLocationBotRight); // load templates clsTemplate template = new clsTemplate(_db); List<clsTemplate> templates = template.getAllTemplates(); int waterLevel = 0; // save results to database clsObject obj = new clsObject(_db); List<clsObject> results = new List<clsObject>(); for (int y = 0; y < size; y++) { for (int x = 0; x < size; x++) { obj = this.createObject((int)worldLocation.x + x, (int)worldLocation.y + y, heights[x, y] * 32, templates.Find(i => i.name.Contains("MC Grass"))); if (heights[x, y] < waterLevel) { for (int z = heights[x, y] + 1; z <= waterLevel; z++) { obj = this.createObject((int)worldLocation.x + x, (int)worldLocation.y + y, z * 32, templates.Find(i => i.name.Contains("MC Water"))); } } } } // height map to JSON string JSON; JSON = "{"; JSON = "\"objectsCreated\":" + results.Count + ""; JSON += "}"; return JSON; }