internal static void SetAchievementStatus(PlayerMobile player, Achievement ach, int progress)
        {
#if STOREONITEM
            if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
            {
                AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary <int, AchieveData>());
            }
            var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial];
#else
            var achieves = (player as MythikPlayerMobile).Achievements;
#endif
            if (achieves.ContainsKey(ach.ID))
            {
                if (achieves[ach.ID].Progress >= ach.CompletionTotal)
                {
                    return;
                }
                achieves[ach.ID].Progress += progress;
            }
            else
            {
                achieves.Add(ach.ID, new AchieveData()
                {
                    Progress = progress
                });
            }

            if (achieves[ach.ID].Progress >= ach.CompletionTotal)
            {
                player.SendGump(new AchievementObtainedGump(ach), false);
                achieves[ach.ID].CompletedOn = DateTime.Now;
#if STOREONITEM
                if (!AchievementSystemMemoryStone.GetInstance().PointsTotals.ContainsKey(player.Serial))
                {
                    AchievementSystemMemoryStone.GetInstance().PointsTotals.Add(player.Serial, 0);
                }
                AchievementSystemMemoryStone.GetInstance().PointsTotals[player.Serial] += ach.RewardPoints;
#else
                (player as MythikPlayerMobile).AchievementPointsTotal += ach.RewardPoints;
#endif
                if (ach.RewardItems != null && ach.RewardItems.Length > 0)
                {
                    try
                    {
                        player.SendAsciiMessage("You have recieved an award for completing this achievment!");
                        var item = (Item)Activator.CreateInstance(ach.RewardItems[0]);
                        if (!WeightOverloading.IsOverloaded(player))
                        {
                            player.Backpack.DropItem(item);
                        }
                        else
                        {
                            player.BankBox.DropItem(item);
                        }
                    }
                    catch { }
                }
            }
        }
        private static void OpenGump(CommandEventArgs e)
        {
            var player = e.Mobile as PlayerMobile;

            if (player != null)
            {
#if STOREONITEM
                if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
                {
                    AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary <int, AchieveData>());
                }
                var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial];
                var total    = AchievementSystemMemoryStone.GetInstance().PointsTotals[player.Serial];
#else
                var achieves = (player as MythikPlayerMobile).Achievements;
                var total    = (player as MythikPlayerMobile).AchievementPointsTotal;
#endif
                e.Mobile.SendGump(new AchievementGump(achieves, total));
            }
        }
Beispiel #3
0
        public static void OpenGump(Mobile from, Mobile target)
        {
            if (from == null || target == null)
            {
                return;
            }
            if (target as PlayerMobile != null)
            {
#if STOREONITEM
                var player = target as PlayerMobile;
                if (!AchievementSystemMemoryStone.GetInstance().Achievements.ContainsKey(player.Serial))
                {
                    AchievementSystemMemoryStone.GetInstance().Achievements.Add(player.Serial, new Dictionary <int, AchieveData>());
                }
                var achieves = AchievementSystemMemoryStone.GetInstance().Achievements[player.Serial];
                var total    = AchievementSystemMemoryStone.GetInstance().GetPlayerPointsTotal(player);
#else
                var achieves = (target as MythikPlayerMobile).Achievements;
                var total    = (target as MythikPlayerMobile).AchievementPointsTotal;
#endif
                from.SendGump(new AchievementGump(achieves, total));
            }
        }