Пример #1
0
        public void LoadCampaign(string worldId, StartNodeFormat start)
        {
            string json = this.handler.GameStateRead("Campaign/" + worldId);

            // If there is no JSON content, load an empty state:
            if (json == "")
            {
                this.Reset();
                this.worldId = worldId;

                // Starting Details
                if (start != null)
                {
                    this.head   = start.character;
                    this.curX   = start.x;
                    this.curY   = start.y;
                    this.zoneId = start.zoneId;
                }
                else
                {
                    this.head   = 1;
                    this.curX   = 3;
                    this.curY   = 3;
                    this.zoneId = 0;
                }

                return;
            }

            CampaignJson campaign = JsonConvert.DeserializeObject <CampaignJson>(json);

            this.SetWorld(campaign.worldId);
            this.SetZone(campaign.zoneId);
            this.SetPosition(campaign.curX, campaign.curY, campaign.lastDir);
            this.SetLives(campaign.lives);
            this.SetWounds(campaign.health, campaign.armor);
            this.SetUpgrades(campaign.suit, campaign.hat, campaign.shoes, campaign.powerAtt, campaign.powerMob, campaign.health, campaign.armor);
            this.SetHead(campaign.head);
            this.SetLevelStatus(campaign.levelStatus);
        }
Пример #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);
        }