public static async Task <bool> WorldRequest(string worldId) { // Make sure the world doesn't already exist locally. If it does, there's no need to call the online API. if (WorldContent.WorldExists(worldId)) { Systems.handler.worldContent.LoadWorldData(worldId); return(true); } try { string json = await Systems.httpClient.GetStringAsync(GameValues.CreoAPI + "world/" + worldId); // Load World WorldFormat worldData = JsonConvert.DeserializeObject <WorldFormat>(json); // If the retrieval fails: if (worldData.id != worldId) { UIHandler.AddNotification(UIAlertType.Error, "Invalid World", "Was unable to locate the world ID `" + worldId + "`.", 300); return(false); } worldData.id = worldId; Systems.handler.worldContent.LoadWorldData(worldData); // Save World Systems.handler.worldContent.SaveWorld(); return(true); } catch (Exception ex) { return(false); } }
public WorldScene() : base() { // UI State UIHandler.SetUIOptions(false, false); UIHandler.SetMenu(null, false); // Prepare Components this.worldUI = new WorldUI(this); this.playerInput = Systems.localServer.MyPlayer.input; this.campaign = Systems.handler.campaignState; this.atlas = Systems.mapper.atlas[(byte)AtlasGroup.World]; // Prepare Mapper Data this.WorldTerrain = Systems.mapper.WorldTerrain; this.WorldLayers = Systems.mapper.WorldLayers; this.WorldObjects = new Dictionary <byte, string>(); this.WorldCharacters = Systems.mapper.WorldCharacters; this.PrepareWorldObjects(); // Prepare World Content this.worldContent = Systems.handler.worldContent; this.worldData = this.worldContent.data; // Prepare Campaign Details this.campaign.LoadCampaign(Systems.handler.worldContent.worldId, this.worldData.start); // Load World Character this.character = new WorldChar(this); }