/// <summary> /// Constructor. /// </summary> /// <param name="id">the reward's ID (unique id to distinguish between rewards).</param> /// <param name="name">the reward's name.</param> public Reward(string id, string name) : base(name, "", id) { Schedule = Schedule.AnyTimeOnce(); if (RewardsMap.ContainsKey(this.mID)) { RewardsMap[this.mID] = this; } else { RewardsMap.Add(this.mID, this); } }
/// <summary> /// Factory method to easily create a reward according to the given JSONObject. /// </summary> /// <returns>A JSONObject representation of <c>Reward</c>.</returns> /// <param name="rewardObj">The actual reward according to the given JSONObject.</param> public static Reward fromJSONObject(JSONObject rewardObj) { string className = rewardObj[JSONConsts.SOOM_CLASSNAME].str; Reward reward = (Reward)Activator.CreateInstance(Type.GetType("Soomla." + className), new object[] { rewardObj }); if (RewardsMap.ContainsKey(reward.mID)) { RewardsMap[reward.mID] = reward; } else { RewardsMap.Add(reward.mID, reward); } return(reward); }
/// <summary> /// Constructor. /// </summary> /// <param name="jsonReward">A JSONObject representation of <c>Reward</c>.</param> public Reward(JSONObject jsonReward) : base(jsonReward) { JSONObject scheduleObj = jsonReward[JSONConsts.SOOM_SCHEDULE]; if (scheduleObj) { Schedule = new Schedule(scheduleObj); } else { Schedule = null; } if (RewardsMap.ContainsKey(this.mID)) { RewardsMap[this.mID] = this; } else { RewardsMap.Add(this.mID, this); } }