Example #1
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            /*int version = */
            reader.ReadInt();

            m_Controller = reader.ReadItem() as BritainLibraryCollection;
        }
        public override void Deserialize( GenericReader reader )
        {
            base.Deserialize( reader );

            /*int version = */
            reader.ReadInt();

            m_Controller = reader.ReadItem() as BritainLibraryCollection;
        }
Example #3
0
        public override void OnResponse(NetState 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.CloseGump<CollectionRewardGump>();
                pm.SendGump(new CollectionDonateGump(m_Collection, m_From));
            }
            else if (info.ButtonID >= 100)
            {
                int i = info.ButtonID - 100;

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

                IRewardEntry entry = m_Collection.Rewards[i];

                if (entry.Hues == null)
                {
                    pm.SendGump(new CollectionConfirmReward(m_Collection, entry, pm, 0));
                }
                else if (entry.Hues.Length == 1)
                {
                    pm.SendGump(new CollectionConfirmReward(m_Collection, entry, pm, entry.Hues[0]));
                }
                else
                {
                    pm.SendGump(new CollectionSelectHueGump(m_Collection, entry, pm));
                }
            }
        }
Example #4
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);
                    }
                }
            }
        }