コード例 #1
0
ファイル: PointsSystem.cs プロジェクト: travismills82/TrueUO
        public PointsEntry GetEntry(Mobile from, bool create = false)
        {
            PlayerMobile pm = from as PlayerMobile;

            if (pm == null)
            {
                return(null);
            }

            PointsEntry entry = null;

            for (var index = 0; index < PlayerTable.Count; index++)
            {
                var e = PlayerTable[index];

                if (e.Player == pm)
                {
                    entry = e;
                    break;
                }
            }

            if (entry == null && (create || AutoAdd))
            {
                entry = AddEntry(pm);
            }

            return(entry);
        }
コード例 #2
0
        public virtual void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            case 1:
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    PlayerMobile player = reader.ReadMobile() as PlayerMobile;
                    PointsEntry  entry  = GetSystemEntry(player);

                    if (version > 0)
                    {
                        entry.Deserialize(reader);
                    }
                    else
                    {
                        entry.Points = reader.ReadDouble();
                    }

                    if (player != null)
                    {
                        if (!PlayerTable.Contains(entry))
                        {
                            PlayerTable.Add(entry);
                        }
                    }
                }
                break;
            }
        }
コード例 #3
0
ファイル: PointsSystem.cs プロジェクト: travismills82/TrueUO
        public TEntry GetPlayerEntry <TEntry>(Mobile mobile, bool create = false) where TEntry : PointsEntry
        {
            PlayerMobile pm = mobile as PlayerMobile;

            if (pm == null)
            {
                return(null);
            }

            PointsEntry first = null;

            for (var index = 0; index < PlayerTable.Count; index++)
            {
                var p = PlayerTable[index];

                if (p.Player == pm)
                {
                    first = p;
                    break;
                }
            }

            TEntry e = first as TEntry;

            if (e == null && (AutoAdd || create))
            {
                e = AddEntry(pm) as TEntry;
            }

            return(e);
        }
コード例 #4
0
        public virtual void Deserialize(GenericReader reader)
        {
            Version = reader.ReadInt();

            switch (Version)
            {
            case 2:     // added serialize/deserialize in all base classes. Poor implementation on my part, should have had from the get-go
            case 1:
            case 0:
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    PlayerMobile player = reader.ReadMobile() as PlayerMobile;
                    PointsEntry  entry  = GetSystemEntry(player);

                    if (Version > 0)
                    {
                        entry.Deserialize(reader);
                    }
                    else
                    {
                        entry.Points = reader.ReadDouble();
                    }

                    if (player != null)
                    {
                        if (!PlayerTable.Contains(entry))
                        {
                            PlayerTable.Add(entry);
                        }
                    }
                }
                break;
            }
        }
コード例 #5
0
        public void SetPoints(PlayerMobile pm, double points)
        {
            PointsEntry entry = GetEntry(pm);

            if (entry != null)
            {
                entry.Points = points;
            }
        }
コード例 #6
0
        public void SetPointsBC(PlayerMobile pm, double points)
        {
            PointsEntry entry = GetEntry(pm);

            if (entry != null)
            {
                entry.Points = points;
                pm.SendLocalizedMessage(1113719);
            }
        }
コード例 #7
0
        public double GetPoints(Mobile from)
        {
            PointsEntry entry = GetEntry(from);

            if (entry != null)
            {
                return(entry.Points);
            }

            return(0.0);
        }
コード例 #8
0
        public void SetPoints(PlayerMobile pm, double points)
        {
            PointsEntry entry = GetEntry(pm);

            if (entry != null)
            {
                entry.Points = points;
                pm.SendMessage($"У вас {(int)PvPPoints.GetPoints(pm)} PvM Points");
                pm.SendMessage($"У вас {(int)PvMPoints.GetPoints(pm)} PvP Points");
            }
        }
コード例 #9
0
ファイル: PointsSystem.cs プロジェクト: Brrm1/New-One
        public virtual PointsEntry AddEntry(PlayerMobile pm)
        {
            PointsEntry entry = GetSystemEntry(pm);

            if (!PlayerTable.Contains(entry))
            {
                PlayerTable.Add(entry);
                OnPlayerAdded(pm);
            }

            return(entry);
        }
コード例 #10
0
        public virtual PointsEntry AddEntry(PlayerMobile pm, bool existed = false)
        {
            PointsEntry entry = GetSystemEntry(pm);

            if (!PlayerTable.Contains(entry))
            {
                PlayerTable.Add(entry);

                if (!existed)
                {
                    OnPlayerAdded(pm);
                }
            }

            return(entry);
        }
コード例 #11
0
ファイル: PointsSystem.cs プロジェクト: Brrm1/New-One
        public PointsEntry GetEntry(Mobile from, bool create = false)
        {
            if (from == null)
            {
                return(null);
            }

            PointsEntry entry = PlayerTable.FirstOrDefault(e => e.Player == from);

            if (entry == null && AutoAdd && from is PlayerMobile)
            {
                entry = AddEntry((PlayerMobile)from);
            }

            return(entry);
        }
コード例 #12
0
ファイル: PointsSystem.cs プロジェクト: Brrm1/New-One
        public virtual void Deserialize(GenericReader reader)
        {
            int version = reader.ReadInt();

            switch (version)
            {
            case 0:
            case 1:
                int count = reader.ReadInt();
                for (int i = 0; i < count; i++)
                {
                    PlayerMobile player = reader.ReadMobile() as PlayerMobile;

                    PointsEntry entry = GetSystemEntry(player);

                    if (version > 0)
                    {
                        entry.Deserialize(reader);
                    }
                    else
                    {
                        entry.Points = reader.ReadDouble();
                    }

                    if (player != null)
                    {
                        PlayerTable.Add(entry);
                    }
                }
                break;
            }

            //Old player data, not uses the above

            /*PlayerTable = new Dictionary<PlayerMobile, double>();
             *
             * int count = reader.ReadInt();
             *
             * for (int i = 0; i < count; i++)
             * {
             *  PlayerMobile pm = reader.ReadMobile() as PlayerMobile;
             *  double points = reader.ReadDouble();
             *
             *  if (pm != null)
             *      PlayerTable.Add(pm, points);
             * }*/
        }
コード例 #13
0
ファイル: PointsSystem.cs プロジェクト: Evad-lab/ServUOX
        public virtual void AwardPoints(Mobile from, double points, bool quest = false, bool message = true)
        {
            if (!(from is PlayerMobile) || points <= 0)
            {
                return;
            }

            PointsEntry entry = GetEntry(from);

            if (entry != null)
            {
                double old = entry.Points;

                SetPoints((PlayerMobile)from, Math.Min(MaxPoints, entry.Points + points));
                SendMessage((PlayerMobile)from, old, points, quest);
            }
        }
コード例 #14
0
        public PointsEntry GetEntry(Mobile from, bool create = false)
        {
            PlayerMobile pm = from as PlayerMobile;

            if (pm == null)
            {
                return(null);
            }

            PointsEntry entry = PlayerTable.FirstOrDefault(e => e.Player == pm);

            if (entry == null && (create || AutoAdd))
            {
                entry = AddEntry(pm);
            }

            return(entry);
        }
コード例 #15
0
ファイル: PointsSystem.cs プロジェクト: travismills82/TrueUO
        public virtual bool DeductPoints(Mobile from, double points, bool message = false)
        {
            PointsEntry entry = GetEntry(from);

            if (entry == null || entry.Points < points)
            {
                return(false);
            }

            entry.Points -= points;

            if (message)
            {
                from.SendLocalizedMessage(1115921, $"{Name}\t{((int) points).ToString()}"); // Your loyalty to ~1_GROUP~ has decreased by ~2_AMOUNT~;Original
            }

            return(true);
        }
コード例 #16
0
        public virtual void ConvertFromOldSystem(PlayerMobile from, double points)
        {
            PointsEntry entry = GetEntry(from, false);

            if (entry == null)
            {
                if (points > MaxPoints)
                {
                    points = MaxPoints;
                }

                AddEntry(from, true);
                GetEntry(from).Points = points;

                Utility.PushColor(ConsoleColor.Green);
                Console.WriteLine("Converted {0} points for {1} to {2}!", (int)points, from.Name, this.GetType().Name);
                Utility.PopColor();
            }
        }