예제 #1
0
        public AchievementLevel GetLevelForProgress(int progress)
        {
            AchievementLevel l = null;

            foreach (AchievementLevel level in Levels)
            {
                if (l == null && level.Level == 1)
                {
                    l = level;
                }

                if (progress >= level.Progress)
                {
                    if (l != null)
                    {
                        if (l.Level > level.Level)
                        {
                            continue;
                        }
                    }

                    l = level;
                }
            }

            return(l);
        }
예제 #2
0
        internal async Task <IList <AchievementLevel> > ReadLevels(int id)
        {
            IList <AchievementLevel> levels = new List <AchievementLevel>();

            await SelectAsync(async reader =>
            {
                while (await reader.ReadAsync())
                {
                    AchievementLevel level = new AchievementLevel()
                    {
                        Level        = reader.ReadData <int>("level"),
                        RewardAmount = reader.ReadData <int>("reward_amount"),
                        RewardType   = reader.ReadData <int>("reward_type"),
                        RewardPoints = reader.ReadData <int>("reward_points"),
                        Progress     = reader.ReadData <int>("progress")
                    };

                    levels.Add(level);
                }
            }, "SELECT * FROM `achievement_levels` WHERE `id` = @0", id);

            return(levels);
        }