public static WorldFormat BuildEmptyWorld(string worldId) { WorldZoneFormat zone = WorldContent.BuildEmptyZone(); WorldFormat world = new WorldFormat { id = worldId.ToUpper(), account = "", mode = (byte)HardcoreMode.SoftCore, title = "Unnamed World", description = "", lives = 30, version = 0, music = 0, zones = new List <WorldZoneFormat>() { zone }, //start = new StartNodeFormat { // character = 0, // zoneId = 0, // x = 0, // y = 0, //}, }; return(world); }
public bool LoadWorldData(string worldId = "") { worldId = worldId.ToUpper(); // Update the World ID, or use existing World ID if applicable. if (WorldContent.WorldExists(worldId)) { this.worldId = worldId; } else { return(false); } string localPath = WorldContent.GetLocalWorldPath(this.worldId); string json = Systems.filesLocal.ReadFile(localPath); // If there is no JSON content, end the attempt to load world: if (json == "") { return(false); } // Load the Data this.data = JsonConvert.DeserializeObject <WorldFormat>(json); return(true); }
public static bool WorldExists(string worldId) { // Verify the presence of a World ID. if (worldId.Length == 0) { return(false); } worldId = worldId.ToUpper(); string localPath = WorldContent.GetLocalWorldPath(worldId); // Make sure the world exists: return(Systems.filesLocal.FileExists(localPath)); }
public GameHandler(string saveId) { this.saveId = saveId; // Make sure the Saves directory exists. Systems.filesLocal.MakeDirectory("Saves/" + saveId); Systems.filesLocal.MakeDirectory("Saves/" + saveId + "/Campaign"); // Content this.levelContent = new LevelContent(); this.worldContent = new WorldContent(); // State this.campaignState = new CampaignState(this); this.levelState = new LevelState(this); this.playlistState = new PlaylistState(this); }
public void SaveCampaign() { // Verify that the world exists. Otherwise, cannot save the campaign. if (!WorldContent.WorldExists(this.worldId)) { return; } CampaignJson campaignJson = new CampaignJson { // Location Data worldId = this.worldId, zoneId = this.zoneId, curX = this.curX, curY = this.curY, lastDir = this.lastDir, // Character Survival lives = this.lives, health = this.health, armor = this.armor, // Character Nature head = this.head, // Character Equipment suit = this.suit, hat = this.hat, shoes = this.shoes, powerAtt = this.powerAtt, powerMob = this.powerMob, // Nodes Completed / Status levelStatus = this.levelStatus, }; // Save State string json = JsonConvert.SerializeObject(campaignJson); this.handler.GameStateWrite("Campaign/" + this.worldId, json); }
} // MusicTrack enum public void SaveWorld() { // Can only save a world state if the world ID is assigned correctly. if (this.worldId == null || this.worldId.Length == 0) { return; } this.worldId = this.worldId.ToUpper(); // Determine the Destination Path and Destination Level ID string localFile = WorldContent.GetLocalWorldPath(this.worldId); // Make sure the directory exists: string localDir = Path.GetDirectoryName(localFile); Systems.filesLocal.MakeDirectory(localDir, true); // Save State string json = JsonConvert.SerializeObject(this.data); Systems.filesLocal.WriteFile(localFile, json); }