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 { }
                }
            }
        }
 public static AchievementSystemMemoryStone GetInstance()
 {
     if (m_instance == null)
     {
         m_instance = new AchievementSystemMemoryStone();
     }
     m_instance.MoveToWorld(new Point3D(0, 0, 0), Map.Felucca);
     return(m_instance);
 }
        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));
            }
        }
Esempio n. 4
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));
            }
        }
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            int count = reader.ReadInt();

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    m_PointsTotal.Add(reader.ReadInt(), reader.ReadInt());
                }
            }

            count = reader.ReadInt();
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Serial id     = reader.ReadInt();
                    var    dict   = new Dictionary <int, AchieveData>();
                    int    iCount = reader.ReadInt();
                    if (iCount > 0)
                    {
                        for (int x = 0; x < iCount; x++)
                        {
                            dict.Add(reader.ReadInt(), new AchieveData(reader));
                        }
                    }
                    Achievements.Add(id, dict);
                }
            }
            System.Console.WriteLine("Loaded Achievent store: " + m_PointsTotal.Count);
            m_instance = this;
        }
 public AchievementSystemMemoryStone(Serial serial) : base(serial)
 {
     m_instance = this;
 }
 public AchievementSystemMemoryStone() : base(0xED4)
 {
     Visible    = false;
     Name       = "AchievementSystemStone DO NOT REMOVE";
     m_instance = this;
 }