Example #1
0
        public static PlayerPortalProfile EnsureProfile(PlayerMobile pm)
        {
            PlayerPortalProfile p;

            if (!PlayerProfiles.TryGetValue(pm, out p))
            {
                PlayerProfiles.Add(pm, p = new PlayerPortalProfile(pm));
            }
            else if (p == null)
            {
                PlayerProfiles[pm] = p = new PlayerPortalProfile(pm);
            }

            return p;
        }
Example #2
0
        public static PlayerPortalProfile EnsureProfile(PlayerMobile pm)
        {
            PlayerPortalProfile p;

            if (!PlayerProfiles.TryGetValue(pm, out p))
            {
                PlayerProfiles.Add(pm, p = new PlayerPortalProfile(pm));
            }
            else if (p == null)
            {
                PlayerProfiles[pm] = p = new PlayerPortalProfile(pm);
            }

            return(p);
        }
Example #3
0
        private static bool DeserializePlayerProfiles(GenericReader reader)
        {
            reader.GetVersion();

            reader.ReadBlockDictionary(
                () =>
            {
                var e = reader.ReadMobile <PlayerMobile>();

                var p = new PlayerPortalProfile(reader);

                return(new KeyValuePair <PlayerMobile, PlayerPortalProfile>(e, p));
            },
                PlayerProfiles);

            return(true);
        }
Example #4
0
        public void AddScore(Mobile damager, int amount)
        {
            Mobile creditMob = null;

            if (damager is BaseCreature)
            {
                var bc = (BaseCreature)damager;

                if (bc.ControlMaster is PlayerMobile)
                {
                    creditMob = bc.ControlMaster;
                }
                else if (bc.SummonMaster is PlayerMobile)
                {
                    creditMob = bc.SummonMaster;
                }
                else if (bc.BardMaster is PlayerMobile)
                {
                    creditMob = bc.BardMaster;
                }
            }
            else if (damager is PlayerMobile)
            {
                creditMob = damager;
            }

            if (creditMob != null)
            {
                PlayerPortalProfile profile = Portals.EnsureProfile(creditMob as PlayerMobile);
                profile.AddScore(amount, this);
                if (ParticipantsScores.ContainsKey(creditMob as PlayerMobile))
                {
                    ParticipantsScores[creditMob as PlayerMobile] += amount;
                }
                else
                {
                    ParticipantsScores.Add(creditMob as PlayerMobile, amount);
                }
            }
        }
Example #5
0
        private static bool DeserializePlayerProfiles(GenericReader reader)
        {
            reader.GetVersion();

            reader.ReadBlockDictionary(
                () =>
                {
                    var e = reader.ReadMobile<PlayerMobile>();

                    var p = new PlayerPortalProfile(reader);

                    return new KeyValuePair<PlayerMobile, PlayerPortalProfile>(e, p);
                },
                PlayerProfiles);

            return true;
        }