Exemple #1
0
        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);
        }
Exemple #2
0
        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);
        }