示例#1
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));
            }
示例#2
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);
        }