示例#1
0
        public bool CheckType(DonationEntry entry, Type type)
        {
            if (entry.Type == typeof(TimberWolf) && (type == typeof(DireWolf) || type == typeof(GreyWolf) || type == typeof(WhiteWolf)))
            {
                return(true);
            }

            if (entry.Type == typeof(Dragon) && (type == typeof(Drake) || type == typeof(WhiteWyrm)))
            {
                return(true);
            }

            if (entry.Type == typeof(Unicorn) && (type == typeof(Kirin) || type == typeof(Nightmare) || type == typeof(FireSteed) || type == typeof(SwampDragon) || type == typeof(CuSidhe)))
            {
                return(true);
            }

            if (entry.Type == typeof(RuneBeetle) && (type == typeof(FireBeetle) || type == typeof(Beetle)))
            {
                return(true);
            }


            return(entry.Type == type);
        }
示例#2
0
            public override void OnResponse(Mobile from, string text)
            {
                if (from.Backpack == null)
                {
                    return;
                }

                int amount = Utility.ToInt32(text);

                DonationEntry entry = m_Collection.Donations[m_EntryIndex];

                Donate(from, entry.Type, entry.Award, amount);

                from.SendGump(new CollectionDonateGump(m_Collection, from));
            }
示例#3
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                DonationEntry entry = m_Collection.Donations[m_EntryIndex];

                if (!(targeted is Item) || !((Item)targeted).IsChildOf(from.Backpack) || targeted.GetType() != entry.Type)
                {
                    from.SendLocalizedMessage(1073390);                       // The item you selected to donate is not of the type you picked.
                }
                else if (targeted is TreasureMap && !CollectionController.CheckTreasureMap((TreasureMap)targeted, entry.Award))
                {
                    from.SendLocalizedMessage(1073390);                       // The item you selected to donate is not of the type you picked.
                }
                else
                {
                    ((Item)targeted).Delete();

                    m_Collection.Award(from, (int)entry.Award);
                }

                from.SendGump(new CollectionDonateGump(m_Collection, from));
            }
示例#4
0
        public CollectionDonateGump(CollectionController collection, Mobile from)
            : base(250, 50)
        {
            if (from.Backpack == null)
            {
                return;
            }

            m_Collection = collection;
            m_From       = from;

            // Chequeamos la tabla de la colección
            if (!m_Collection.Table.Contains(from))
            {
                m_Collection.Table.Add(from, (Misc.TestCenter.Enabled ? 5000000 : 0));
            }

            GetMax(m_Collection.Donations);

            BuildHeader();

            AddPage(1);
            StartPage();

            int page = 1;

            int offset = 150;
            int next   = 0;

            for (int i = 0; i < m_Collection.Donations.Length; i++)
            {
                DonationEntry entry = m_Collection.Donations[i] as DonationEntry;

                int height = Math.Max(entry.Height, 20);

                if (offset + next >= 310)
                {
                    EndPage(page, false);

                    page++;
                    AddPage(page);
                    StartPage();

                    offset = 150;
                    next   = 0;
                }

                // ******* Build Entry *******
                int amount = 0;

                if (entry.Type == typeof(TreasureMap))
                {
                    List <TreasureMap> maps = from.Backpack.FindItemsByType <TreasureMap>();

                    for (int j = 0; j < maps.Count; j++)
                    {
                        if (CollectionController.CheckTreasureMap(maps[j], entry.Award))
                        {
                            amount++;
                        }
                    }
                }
                else
                {
                    amount = GetTotalAmountByType(from, entry.Type);
                }

                if (amount > 0)
                {
                    int yOffset = offset + (int)(height / 2) - 5;

                    AddButton(35, yOffset, 0x837, 0x838, i + 300, GumpButtonType.Reply, 0);
                    AddHtml(245, yOffset - 4, 60, 20, String.Format("<BODY><BASEFONT COLOR=\"#448844\"><DIV ALIGN=\"RIGHT\">{0}</DIV></BASEFONT></BODY>", amount), false, false);
                }

                int y = offset - entry.Y;

                if (entry.Height < 20)
                {
                    y += (20 - entry.Height) / 2;
                }

                string award;
                if (entry.Type == typeof(BankCheck))
                {
                    award = "1";
                }
                else if (entry.Award > 0 && entry.Award < 1)
                {
                    award = String.Format("1 per {0}", (int)(1 / entry.Award));
                }
                else
                {
                    award = entry.Award.ToString();
                }

                if (entry.Name != null)
                {
                    AddItem(55 - entry.X + m_Max / 2 - entry.Width / 2, y, entry.Tile, entry.Hue);
                    AddLabel(65 + m_Max, offset + (int)(height / 2) - 18, 0x63, entry.Name.ToString());
                    AddLabel(65 + m_Max, offset + (int)(height / 2) - 2, 0x64, award);
                }
                else
                {
                    AddItem(55 - entry.X + m_Max / 2 - entry.Width / 2, y, entry.Tile, entry.Hue);
                    AddTooltip(entry.Cliloc);
                    AddLabel(65 + m_Max, offset + (int)(height / 2) - 10, 0x64, award);
                    AddTooltip(entry.Cliloc);
                }
                // ***** End Build Entry *****

                offset += 10 + height;

                if (i < m_Collection.Donations.Length)
                {
                    next = Math.Max(m_Collection.Donations[i].Height, 20);
                }
                else
                {
                    next = 0;
                }
            }

            EndPage(page, true);
        }
示例#5
0
        public override void OnResponse(GameClient sender, RelayInfo info)
        {
            PlayerMobile pm = sender.Mobile as PlayerMobile;

            if (pm == null)
            {
                return;
            }

            if (m_Collection is BritainLibraryCollection)
            {
                BritainLibraryCollection col = m_Collection as BritainLibraryCollection;

                if (col.Representative != null && pm.GetDistanceToSqrt(col.Representative.Location) > 10)
                {
                    return;
                }
            }
            else if (pm.GetDistanceToSqrt(m_Collection.Location) > 10)
            {
                return;
            }

            if (info.ButtonID == 1)
            {
                pm.SendGump(new CollectionRewardGump(m_Collection, m_From));
            }
            else if (info.ButtonID >= 300)
            {
                int i = info.ButtonID - 300;

                if (i < 0 || i >= m_Collection.Donations.Length || pm.Backpack == null)
                {
                    return;
                }

                if (m_Collection is BritainLibraryCollection && !pm.FriendOfTheLibrary)
                {
                    pm.SendLocalizedMessage(1074273);                       // You must speak with Librarian Verity before you can donate to this collection.
                    pm.SendGump(new CollectionDonateGump(m_Collection, m_From));

                    return;
                }

                DonationEntry entry = m_Collection.Donations[i];

                if (entry.Type == typeof(BankCheck))
                {
                    List <BankCheck> checks = pm.Backpack.FindItemsByType <BankCheck>();

                    if (checks.Count == 0)
                    {
                        // You do not have enough of that item to make a donation!
                        pm.SendLocalizedMessage(1073167);
                    }
                    else
                    {
                        int balance = 0;

                        for (int j = 0; j < checks.Count; j++)
                        {
                            BankCheck check = checks[j];

                            balance += check.Worth;
                            check.Delete();
                        }

                        int award = (int)(balance * entry.Award);

                        m_Collection.Award(pm, award);
                    }

                    pm.SendGump(new CollectionDonateGump(m_Collection, m_From));
                }
                else
                {
                    Item item = FindItemByType(pm.Backpack, entry.Type);

                    if (item == null)
                    {
                        // You do not have enough of that item to make a donation!
                        pm.SendLocalizedMessage(1073167);

                        pm.SendGump(new CollectionDonateGump(m_Collection, m_From));
                    }
                    else if (item.Stackable)
                    {
                        pm.Prompt = new AmountPrompt(m_Collection, i);
                    }
                    else
                    {
                        pm.SendLocalizedMessage(1073389);                           // Please target the item you wish to donate.
                        pm.Target = new DonationTarget(m_Collection, i);
                    }
                }
            }
        }
示例#6
0
        public void GetMax( DonationEntry[] list )
        {
            m_Max = 0;

            if ( list != null )
            {
                for ( int i = 0; i < list.Length; i++ )
                    if ( m_Max < list[i].Width )
                        m_Max = list[i].Width;
            }
        }
示例#7
0
        public bool CheckType( DonationEntry entry, Type type )
        {
            if ( entry.Type == typeof( TimberWolf ) && ( type == typeof( DireWolf ) || type == typeof( GreyWolf ) || type == typeof( WhiteWolf ) ) )
                return true;

            if ( entry.Type == typeof( Dragon ) && ( type == typeof( Drake ) || type == typeof( WhiteWyrm ) ) )
                return true;

            if ( entry.Type == typeof( Unicorn ) && ( type == typeof( Kirin ) || type == typeof( Nightmare ) || type == typeof( FireSteed ) || type == typeof( SwampDragon ) || type == typeof( CuSidhe ) ) )
                return true;

            if ( entry.Type == typeof( RuneBeetle ) && ( type == typeof( FireBeetle ) || type == typeof( Beetle ) ) )
                return true;

            return entry.Type == type;
        }