示例#1
0
        /// <summary>
        /// Constructs a <c>World</c> from a JSON object.
        /// </summary>
        /// <param name="jsonWorld">Json World.</param>
        public World(JSONObject jsonWorld)
            : base(jsonWorld)
        {
            InnerWorldsMap = new Dictionary <string, World>();
            List <JSONObject> worldsJSON = jsonWorld[LUJSONConsts.LU_WORLDS].list;

            // Iterates over all inner worlds in the JSON array and for each one creates
            // an instance according to the world type.
            foreach (JSONObject worldJSON in worldsJSON)
            {
                World innerWorld = World.fromJSONObject(worldJSON);
                if (innerWorld != null)
                {
                    InnerWorldsMap.Add(innerWorld._id, innerWorld);
                    innerWorld.ParentWorld = this;
                }
            }

            Scores = new Dictionary <String, Score>();
            List <JSONObject> scoresJSON = jsonWorld[LUJSONConsts.LU_SCORES].list;

            // Iterates over all scores in the JSON array and for each one creates
            // an instance according to the score type.
            foreach (JSONObject scoreJSON in scoresJSON)
            {
                Score score = Score.fromJSONObject(scoreJSON);
                if (score != null)
                {
                    Scores.Add(score.ID, score);
                }
            }

            Missions = new List <Mission>();
            List <JSONObject> missionsJSON = jsonWorld[LUJSONConsts.LU_MISSIONS].list;

            // Iterates over all challenges in the JSON array and creates an instance for each one.
            foreach (JSONObject missionJSON in missionsJSON)
            {
                Missions.Add(Mission.fromJSONObject(missionJSON));
            }

            JSONObject gateJSON = jsonWorld[LUJSONConsts.LU_GATE];

            if (gateJSON != null && gateJSON.keys != null && gateJSON.keys.Count > 0)
            {
                Gate = Gate.fromJSONObject(gateJSON);
            }
        }
示例#2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="jsonGate">JSON gate.</param>
        public GatesList(JSONObject jsonGate)
            : base(jsonGate)
        {
            List <JSONObject> gatesJSON = jsonGate[LUJSONConsts.LU_GATES].list;

            // Iterate over all gates in the JSON array and for each one create
            // an instance according to the gate type
            foreach (JSONObject gateJSON in gatesJSON)
            {
                Gate gate = Gate.fromJSONObject(gateJSON);
                if (gate != null)
                {
                    Gates.Add(gate);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Constructor.
        /// Generates an instance of <c>Mission</c> from the given JSONObject.
        /// </summary>
        /// <param name="jsonObj">JSON object.</param>
        public Mission(JSONObject jsonObj)
            : base(jsonObj)
        {
            this.Rewards = new List <Reward>();
            List <JSONObject> jsonRewardList = jsonObj [JSONConsts.SOOM_REWARDS].list;

            foreach (JSONObject jsonRewardObj in jsonRewardList)
            {
                this.Rewards.Add(Reward.fromJSONObject(jsonRewardObj));
            }

            this.Gate = Gate.fromJSONObject(jsonObj[LUJSONConsts.LU_GATE]);
            if (jsonObj[JSONConsts.SOOM_SCHEDULE])
            {
                this.Schedule = new Schedule(jsonObj[JSONConsts.SOOM_SCHEDULE]);
            }
            registerEvents();
        }