コード例 #1
0
            public void TryDrop(Mobile from, Item dropped)
            {
                if (!m_Box.CheckAccessible(from, m_Box))
                {
                    from.SendLocalizedMessage(1061637); // You are not allowed to access this.
                }
                else if (!dropped.IsChildOf(from.Backpack))
                {
                    from.SendLocalizedMessage(1157726); // You must be carrying the item to add it to the jewelry box.
                }
                else if (m_Box.IsAccept(dropped))
                {
                    if (m_Box.IsFull)
                    {
                        from.SendLocalizedMessage(1157723); // The jewelry box is full.
                    }
                    else
                    {
                        m_Box.DropItem(dropped);
                        from.Target = new InternalTarget(m_Box, m_Page);
                    }
                }
                else if (dropped is Container c)
                {
                    int count = 0;

                    for (int i = c.Items.Count - 1; i >= 0; --i)
                    {
                        if (i < c.Items.Count && m_Box.IsAccept(c.Items[i]))
                        {
                            if (m_Box.IsFull)
                            {
                                from.SendLocalizedMessage(1157723); // The jewelry box is full.
                                break;
                            }

                            m_Box.DropItem(c.Items[i]);
                            count++;
                        }
                    }

                    if (count > 0)
                    {
                        from.CloseGump(typeof(JewelryBoxGump));
                        from.SendGump(new JewelryBoxGump(from, m_Box, m_Page));
                    }
                    else
                    {
                        from.SendLocalizedMessage(1157724); // This is not a ring, bracelet, necklace, earring, or talisman.
                        from.SendGump(new JewelryBoxGump(from, m_Box, m_Page));
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1157724); // This is not a ring, bracelet, necklace, earring, or talisman.
                    from.SendGump(new JewelryBoxGump(from, m_Box, m_Page));
                }
            }
コード例 #2
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            if (!m_Box.CheckAccessible(m_From, m_Box))
            {
                m_From.SendLocalizedMessage(1061637); // You are not allowed to access this.
            }
            else if (!m_From.InRange(m_Box.GetWorldLocation(), 2))
            {
                m_From.SendLocalizedMessage(500446); // That is too far away.
            }
            else
            {
                JewelryBoxFilter f = m_Box.Filter;

                int index = info.ButtonID;

                switch (index)
                {
                case 0:
                {
                    break;
                }

                case 1:     // Previous page
                {
                    if (m_Page > 0)
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, m_Page - 1));
                    }
                    else
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, m_Page));
                    }

                    break;
                }

                case 2:     // Next Page
                {
                    if (GetIndexForPage(m_Page + 1) < m_List.Count)
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, m_Page + 1));
                    }
                    else
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, m_Page));
                    }

                    return;
                }

                case 3:     // ADD JEWELRY
                {
                    m_From.Target = new InternalTarget(m_Box, m_Page);
                    m_From.SendLocalizedMessage(
                        1157725);     // Target rings, bracelets, necklaces, earrings, or talisman in your backpack. You may also target a sub-container to add contents to the the jewelry box. When done, press ESC.
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));
                    break;
                }

                case 11:     // First page
                {
                    if (m_Page > 0)
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, 1));
                    }
                    else
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, m_Page));
                    }

                    break;
                }

                case 12:     // Last Page
                {
                    int pagecount = GetPageCount(m_List.Count);

                    if (m_Page != pagecount && m_Page >= 1)
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, pagecount));
                    }
                    else
                    {
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box, m_Page));
                    }

                    break;
                }

                case 101:     // Ring
                {
                    f.Ring = true;
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));

                    break;
                }

                case 102:     // Bracelet
                {
                    f.Bracelet = true;
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));

                    break;
                }

                case 104:     // Earrings
                {
                    f.Earrings = true;
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));

                    break;
                }

                case 108:     // Necklace
                {
                    f.Necklace = true;
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));

                    break;
                }

                case 116:     // Talisman
                {
                    f.Talisman = true;
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));

                    break;
                }

                case 132:     // ALL
                {
                    f.Clear();
                    m_From.SendGump(new JewelryBoxGump(m_From, m_Box));

                    break;
                }

                default:
                {
                    Item item = m_Box.Items.Find(x => x.Serial == index);

                    if (item != null)
                    {
                        m_From.AddToBackpack(item);
                        m_From.SendGump(new JewelryBoxGump(m_From, m_Box));
                    }

                    break;
                }
                }
            }
        }