当前位置: 首页>>代码示例>>C#>>正文


C# Backpack.Delete方法代码示例

本文整理汇总了C#中Server.Items.Backpack.Delete方法的典型用法代码示例。如果您正苦于以下问题:C# Backpack.Delete方法的具体用法?C# Backpack.Delete怎么用?C# Backpack.Delete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Items.Backpack的用法示例。


在下文中一共展示了Backpack.Delete方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddLootBackpack

        public virtual void AddLootBackpack(LootPack pack)
        {
            if (pack == null)
                return;

            if (Summoned)
                return;

            Container backpack = Backpack;
            if (backpack == null)
            {
                backpack = new Backpack();

                backpack.Movable = false;

                AddItem(backpack);
            }

            //find top most container
            while (backpack.FindItemByType(typeof(Backpack)) != null)
                backpack = (Container)backpack.FindItemByType(typeof(Backpack));

            Container LootBag = new Backpack();
            backpack.DropItem(LootBag);

            //base loot
            pack.Generate(this, LootBag, m_Spawning, m_KillersLuck);

            if (LootBag.Items.Count <= 0 && pack != LootPack.Undead)
            {
                LootBag.Delete();
                return;
            }

            //extras
            if (pack == LootPack.Poor)
            {
                switch (Utility.RandomMinMax(1, 2))
                {
                    case 0: AddLootBackpack(LootPack.Poor); break;
                    case 1: AddLootGold(LootPack.PoorPile); break;
                    case 2: AddLootPouch(LootPack.PoorPouch); break;
                }
            }
            else if (pack == LootPack.Meager)
            {
                switch (Utility.RandomMinMax(1,2))
                {
                    case 0: AddLootBackpack(LootPack.Meager); break;
                    case 1: AddLootGold(LootPack.MeagerPile); break;
                    case 2: AddLootPouch(LootPack.MeagerPouch); break;
                }
            }
            else if (pack == LootPack.Average)
            {
                switch (Utility.RandomMinMax(1, 2))
                {
                    case 0: AddLootBackpack(LootPack.Average); break;
                    case 1: AddLootGold(LootPack.AveragePile); break;
                    case 2: AddLootPouch(LootPack.AveragePouch); break;
                }
            }
            else if (pack == LootPack.Rich)
            {
                switch (Utility.RandomMinMax(1, 2))
                {
                    case 0: AddLootBackpack(LootPack.Rich); break;
                    case 1: AddLootGold(LootPack.RichPile); break;
                    case 2: AddLootPouch(LootPack.RichPouch); break;
                }
            }
            else if (pack == LootPack.FilthyRich)
            {
                switch (Utility.RandomMinMax(1,2))
                {
                    case 0: AddLootBackpack(LootPack.FilthyRich); break;
                    case 1: AddLootGold(LootPack.FilthyRichPile); break;
                    case 2: AddLootPouch(LootPack.FilthyRichPouch); break;
                }
            }
            else if (pack == LootPack.UltraRich)
            {
                switch (Utility.RandomMinMax(1, 2))
                {
                    case 0: AddLootBackpack(LootPack.UltraRich); break;
                    case 1: AddLootGold(LootPack.UltraRichPile); break;
                    case 2: AddLootPouch(LootPack.UltraRichPouch); break;
                }
            }
            else if (pack == LootPack.SuperBoss)
            {
                switch (Utility.RandomMinMax(1, 2))
                {
                    case 0: AddLootBackpack(LootPack.SuperBoss); break;
                    case 1: AddLootGold(LootPack.SuperBossPile); break;
                    case 2: AddLootPouch(LootPack.SuperBossPouch); break;
                }
            }
            else if (pack == LootPack.Special)
            {
//.........这里部分代码省略.........
开发者ID:Godkong,项目名称:Origins,代码行数:101,代码来源:BaseCreature.cs

示例2: Destroy

        public override void Destroy( bool toBackpack )
        {
            if ( RentalGold > 0 && House != null && House.IsAosRules )
            {
                if ( House.MovingCrate == null )
                    House.MovingCrate = new MovingCrate( House );

                Banker.Deposit( House.MovingCrate, RentalGold );
                RentalGold = 0;
            }

            if ( HoldGold > 0 && Owner != null)
            {
                Banker.Deposit(Owner, HoldGold);
                HoldGold = 0;
            }

            List<Item> list = GetItems();
            if ( list.Count > 0 && Owner != null && Owner.BankBox != null && Owner.BankBox.TotalItems < 124)
                if ( ( !toBackpack || this.Map == Map.Internal ) && House != null && House.IsAosRules )
                {
                    int itemsCanDrop = 124 - Owner.BankBox.TotalItems;
                    Backpack bag = new Backpack();
                    bag.Name = "Vendor Inventory Bag";
                    foreach ( Item item in list )
                    {
                        if (item is Container)
                        {
                            if (((Container)item).TotalItems == 0)
                                item.Delete();
                            else if (((Container)item).TotalItems < itemsCanDrop - 1)
                            {
                                bag.DropItem( item );
                                itemsCanDrop -= ((Container)item).TotalItems + 1;
                            }
                        }
                        else if (itemsCanDrop > 0)
                        {
                            bag.DropItem( item );
                            itemsCanDrop--;
                        }
                    }
                    if (bag.TotalItems > 0)
                        Owner.BankBox.DropItem( bag );
                    else bag.Delete();
                }

            base.Destroy( toBackpack );
        }
开发者ID:kamronbatman,项目名称:Defiance-AOS-Pre-2012,代码行数:49,代码来源:RentedVendor.cs


注:本文中的Server.Items.Backpack.Delete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。