/// <summary> /// Constructor. /// Generates an instance of <c>Challenge</c> from the given JSONObject. /// </summary> /// <param name="jsonMission">JSON mission.</param> public Challenge(JSONObject jsonMission) : base(jsonMission) { Missions = new List <Mission>(); List <JSONObject> missionsJSON = jsonMission[LUJSONConsts.LU_MISSIONS].list; foreach (JSONObject missionJSON in missionsJSON) { Missions.Add(Mission.fromJSONObject(missionJSON)); } }
/// <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); } }