示例#1
0
文件: Reward.cs 项目: lickey10/BeerMe
        /// <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(id, name, "")
        {
            Schedule = Schedule.AnyTimeOnce();

            RewardsMap.AddOrUpdate(this.ID, this);
        }
示例#2
0
文件: Reward.cs 项目: lickey10/BeerMe
        /// <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 });

            RewardsMap.AddOrUpdate(reward.ID, reward);

            return(reward);
        }
示例#3
0
        /// <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);
            }
        }
示例#4
0
文件: Reward.cs 项目: lickey10/BeerMe
        /// <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;
            }

            RewardsMap.AddOrUpdate(this.ID, this);
        }
示例#5
0
        /// <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);
        }
示例#6
0
        /// <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);
            }
        }