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


C# Container.TryDropItem方法代码示例

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


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

示例1: ForceGenerate

		public void ForceGenerate(Mobile m, Container c)
		{
			if (c == null)
			{
				return;
			}

			foreach (Item i in
				m_Entries.Where(e => e.Chance > Utility.Random(10000))
						 .Select(entry => entry.ForceConstruct(m))
						 .Where(i => i != null)
						 .Where(i => !i.Stackable || (m == null || !c.TryDropItem(m, i, false))))
			{
				c.DropItem(i);
			}
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:16,代码来源:LootPack.cs

示例2: Generate

		public void Generate( Mobile from, Container cont, bool spawning )
		{
			if ( cont == null )
				return;

			for ( int i = 0; i < m_Entries.Length; ++i )
			{
				LootPackEntry entry = m_Entries[i];

				bool shouldAdd = ( entry.Chance > Utility.Random( 10000 ) );

				if ( !shouldAdd )
					continue;

				Item item = entry.Construct( from, spawning );

				if ( item != null )
				{
					if ( !item.Stackable || !cont.TryDropItem( from, item, false ) )
						cont.DropItem( item );
				}
			}
		}
开发者ID:Grimoric,项目名称:RunUO.T2A,代码行数:23,代码来源:LootPack.cs

示例3: ProcessValidPurchase

		private void ProcessValidPurchase( int amount, IBuyItemInfo bii, Mobile buyer, Container cont )
		{
			if ( amount > bii.Amount )
				amount = bii.Amount;

			if ( amount < 1 )
				return;

			bii.Amount -= amount;

			IEntity o = bii.GetEntity();

			if ( o is Item )
			{
				Item item = (Item)o;

				if ( item.Stackable )
				{
					item.Amount = amount;

					if ( cont == null || !cont.TryDropItem( buyer, item, false ) )
						item.MoveToWorld( buyer.Location, buyer.Map );
				}
				else
				{
					item.Amount = 1;

					if ( cont == null || !cont.TryDropItem( buyer, item, false ) )
						item.MoveToWorld( buyer.Location, buyer.Map );

					for ( int i = 1; i < amount; i++ )
					{
						item = bii.GetEntity() as Item;

						if ( item != null )
						{
							item.Amount = 1;

							if ( cont == null || !cont.TryDropItem( buyer, item, false ) )
								item.MoveToWorld( buyer.Location, buyer.Map );
						}
					}
				}
			}
			else if ( o is Mobile )
			{
				Mobile m = (Mobile)o;

				m.Direction = (Direction)Utility.Random( 8 );
				m.MoveToWorld( buyer.Location, buyer.Map );
				m.PlaySound( m.GetIdleSound() );

				if ( m is BaseCreature )
					( (BaseCreature)m ).SetControlMaster( buyer );

				for ( int i = 1; i < amount; ++i )
				{
					m = bii.GetEntity() as Mobile;

					if ( m != null )
					{
						m.Direction = (Direction)Utility.Random( 8 );
						m.MoveToWorld( buyer.Location, buyer.Map );

						if ( m is BaseCreature )
							( (BaseCreature)m ).SetControlMaster( buyer );
					}
				}
			}
		}
开发者ID:greeduomacro,项目名称:last-wish,代码行数:70,代码来源:BaseVendor.cs

示例4: Generate

		public void Generate(Mobile from, Container cont, bool spawning, int luckChance)
		{
			if (cont == null)
			{
				return;
			}

			bool checkLuck = Core.AOS;

			for (int i = 0; i < m_Entries.Length; ++i)
			{
				LootPackEntry entry = m_Entries[i];

				bool shouldAdd = (entry.Chance > Utility.Random(10000));

				if (!shouldAdd && checkLuck)
				{
					checkLuck = false;

					if (CheckLuck(luckChance))
					{
						shouldAdd = (entry.Chance > Utility.Random(10000));
					}
				}

				if (!shouldAdd)
				{
					continue;
				}

				Item item = entry.Construct(from, luckChance, spawning);

				if (item != null)
				{
					if (!item.Stackable || !cont.TryDropItem(from, item, false))
					{
						cont.DropItem(item);
					}
				}
			}
		}
开发者ID:mcarriere,项目名称:ServUO,代码行数:41,代码来源:LootPack.cs

示例5: GenerateLoot

		public void GenerateLoot( Mobile creature, Container c )
		{
			int value = m_TotalValue;

			//do
			//{
				for ( int i = 0; value > 0 && i < m_LootSets.Count; i++ )
				{
					Tuple<BaseLootSet,double> set = m_LootSets[i];

					if ( set.Item2 > Utility.RandomDouble() )
					{
						Tuple<Item[],int> lootitem = set.Item1.GenerateLootItem( creature );

						if ( value - lootitem.Item2 >= 0 )
						{
							for ( int j = 0;j < lootitem.Item1.Length; j++ )
								c.DropItem( lootitem.Item1[j] );

							value -= lootitem.Item2;
						}
						else
						{
							for ( int j = 0;j < lootitem.Item1.Length; j++ )
								lootitem.Item1[j].Delete();
						}
					}
				}
			//}
			//while ( ((double)value / m_TotalValue / 2.0) > Utility.RandomDouble() );

			if ( LootSystem.ExtraLootAsGold && (value = Utility.RandomMinMax( value / 10, value / 5 )) > 0 ) //We have some left, lets give it as partial gold
				c.TryDropItem( creature, new Gold( value ), false, false );
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:34,代码来源:LootCollection.cs

示例6: GenerateGold

		public void GenerateGold( Mobile creature, Container c )
		{
			c.TryDropItem( creature, new Gold( m_Gold.Roll() ), false, false );
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:4,代码来源:LootCollection.cs

示例7: ProcessValidPurchase

		private void ProcessValidPurchase( int amount, IBuyItemInfo bii, Mobile buyer, Container cont )
		{
			if ( amount > bii.Amount )
				amount = bii.Amount;

			if ( amount < 1 )
				return;

			bii.Amount -= amount;

			IEntity o = bii.GetEntity();

			if ( o is Item )
			{
				Item item = (Item)o;

                if (item is Food)
                {
                    Food food = item as Food;
                    if (Utility.RandomDouble() <= 0.05)
                        food.Poison = Poison.Lesser;
                }
                if (item is BaseWeapon)
                {
                    BaseWeapon wpn = item as BaseWeapon;
                    if (Utility.RandomDouble() <= 0.05)
                        wpn.Quality = WeaponQuality.Low;
                }
                if (item is BaseArmor)
                {
                    BaseArmor arm = item as BaseArmor;
                    if (Utility.RandomDouble() <= 0.05)
                        arm.Quality = ArmorQuality.Low;
                }
                if (item is BaseTool)
                {
                    BaseTool tool = item as BaseTool;
                    if (Utility.RandomDouble() <= 0.05)
                        tool.UsesRemaining /= 2;
                }

				if ( item.Stackable )
				{
					item.Amount = amount;

					if ( cont == null || !cont.TryDropItem( buyer, item, false ) )
						item.MoveToWorld( buyer.Location, buyer.Map );
				}
				else
				{
					item.Amount = 1;

					if ( cont == null || !cont.TryDropItem( buyer, item, false ) )
						item.MoveToWorld( buyer.Location, buyer.Map );

					for ( int i = 1; i < amount; i++ )
					{
						item = bii.GetEntity() as Item;

						if ( item != null )
						{
							item.Amount = 1;

							if ( cont == null || !cont.TryDropItem( buyer, item, false ) )
								item.MoveToWorld( buyer.Location, buyer.Map );
						}
					}
				}
			}
			else if ( o is Mobile )
			{
				Mobile m = (Mobile)o;

				m.Direction = (Direction)Utility.Random( 8 );
				m.MoveToWorld( buyer.Location, buyer.Map );
				m.PlaySound( m.GetIdleSound() );

				if ( m is BaseCreature )
					( (BaseCreature)m ).SetControlMaster( buyer );

				for ( int i = 1; i < amount; ++i )
				{
					m = bii.GetEntity() as Mobile;

					if ( m != null )
					{
						m.Direction = (Direction)Utility.Random( 8 );
						m.MoveToWorld( buyer.Location, buyer.Map );

						if ( m is BaseCreature )
							( (BaseCreature)m ).SetControlMaster( buyer );
					}
				}
			}
		}
开发者ID:greeduomacro,项目名称:vivre-uo,代码行数:95,代码来源:BaseVendor.cs

示例8: Generate

        public void Generate(Mobile from, Container cont, bool spawning, int luckChance)
        {
            if (cont == null)
                return;

            bool checkLuck = Core.AOS;

            for (int i = 0; i < m_Entries.Length; ++i)
            {
                LootPackEntry entry = m_Entries[i];

                bool shouldAdd = (entry.Chance > Utility.Random(10000));

                if (!shouldAdd && checkLuck)
                {
                    checkLuck = false;

                    if (LootPack.CheckLuck(luckChance))
                        shouldAdd = (entry.Chance > Utility.Random(10000));
                }

                if (!shouldAdd)
                    continue;

                Item item = entry.Construct(from, luckChance, spawning);

                // Plume begin check Identification
                if (item is BaseWeapon || item is BaseArmor || item is BaseClothing || item is BaseJewel)
                {

                    bool IsID = true;

                    int bonusProps = entry.GetBonusProperties();
                    double min = (double)entry.MinIntensity;
                    double max = (double)entry.MaxIntensity;

                    if (bonusProps < entry.MaxProps && LootPack.CheckLuck(luckChance))
                        ++bonusProps;

                    int props = 1 + bonusProps;

                    double dblID = (((min / max) + (min / 5.0) + (max / 10.0)) * (props + props / 10.0)) / 100.0;

                    if (props >= 5 && Utility.Random(0, 100) > 1)
                        IsID = false;
                    else if (dblID > Utility.RandomDouble())
                        IsID = false;

                    if (!IsID)
                    {
                        if (item is BaseWeapon)
                            ((BaseWeapon)item).Identified = false;
                        else if (item is BaseArmor)
                            ((BaseArmor)item).Identified = false;
                        else if (item is BaseClothing)
                            ((BaseClothing)item).Identified = false;
                        else if (item is BaseJewel)
                            ((BaseJewel)item).Identified = false;
                    }
                }
                // End
                if (item != null)
                {
                    if (!item.Stackable || !cont.TryDropItem(from, item, false))
                        cont.DropItem(item);
                }
            }
        }
开发者ID:greeduomacro,项目名称:vivre-uo,代码行数:68,代码来源:LootPack.cs

示例9: ProcessValidPurchase

		private void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
		{
			if (amount > bii.Amount)
				amount = bii.Amount;

			if (amount < 1)
				return;

			if (ResourcePool.IsPooledResource(bii.Type) && ResourcePool.GetTotalCount(bii.Type) > 0)
			{
				ResourcePool.SellOff(bii.Type, amount, this.Serial, buyer);
			}
			else
			{
				bii.Amount -= amount;
			}

			object o = bii.GetObject();

			if (o is Item)
			{
				Item item = (Item)o;

				// all weapons and armor are exceptional during server wars
				if (Server.Misc.TestCenter.Enabled == true)
				{
					if (item is BaseArmor)
					{
						(item as BaseArmor).Quality = ArmorQuality.Exceptional;
						(item as BaseArmor).Durability = ArmorDurabilityLevel.Fortified;
						(item as BaseArmor).Identified = true;
					}
					if (item is BaseWeapon)
					{
						(item as BaseWeapon).Quality = WeaponQuality.Exceptional;
						(item as BaseWeapon).DurabilityLevel = WeaponDurabilityLevel.Fortified;
						(item as BaseWeapon).Identified = true;
					}
				}

				if (item.Stackable)
				{
					item.Amount = amount;

					if (ResourcePool.IsPooledResource(item.GetType()) && item.Amount >= 100)
						item = new CommodityDeed(item);

					if (cont == null || !cont.TryDropItem(buyer, item, false))
						item.MoveToWorld(buyer.Location, buyer.Map);
				}
				else
				{
					item.Amount = 1;

					if (cont == null || !cont.TryDropItem(buyer, item, false))
						item.MoveToWorld(buyer.Location, buyer.Map);

					for (int i = 1; i < amount; i++)
					{
						item = bii.GetObject() as Item;

						if (item != null)
						{
							item.Amount = 1;

							if (cont == null || !cont.TryDropItem(buyer, item, false))
								item.MoveToWorld(buyer.Location, buyer.Map);
						}
					}
				}
			}
			else if (o is Mobile)
			{
				Mobile m = (Mobile)o;

				m.Direction = (Direction)Utility.Random(8);
				m.MoveToWorld(buyer.Location, buyer.Map);
				m.PlaySound(m.GetIdleSound());

				if (m is BaseCreature)
					((BaseCreature)m).SetControlMaster(buyer);

				for (int i = 1; i < amount; ++i)
				{
					m = bii.GetObject() as Mobile;

					if (m != null)
					{
						m.Direction = (Direction)Utility.Random(8);
						m.MoveToWorld(buyer.Location, buyer.Map);

						if (m is BaseCreature)
							((BaseCreature)m).SetControlMaster(buyer);
					}
				}
			}
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:97,代码来源:BaseVendor.cs

示例10: Generate

        public void Generate( Mobile npc, Container cont )
        {
            if ( cont == null || npc == null )
                return;

            for ( int i = 0; i < m_Entries.Length; ++i )
            {
                LootPackEntry entry = m_Entries[i];
                if ( !( entry.Chance > Utility.Random( 10000 ) ) )
                    continue;

                Item item = entry.Construct();
                if ( item != null )
                {
                    if ( !item.Stackable || !cont.TryDropItem( npc, item, false ) )
                        cont.DropItem( item );
                }
            }
        }
开发者ID:FreeReign,项目名称:Rebirth-Repack,代码行数:19,代码来源:LootPack.cs

示例11: ProcessValidPurchase

		private static void ProcessValidPurchase(int amount, IBuyItemInfo bii, Mobile buyer, Container cont)
		{
			if (amount > bii.Amount)
			{
				amount = bii.Amount;
			}

			if (amount < 1)
			{
				return;
			}

			bii.Amount -= amount;

			IEntity o = bii.GetEntity();

			if (o is Item)
			{
				var item = (Item)o;

				if (item.Stackable)
				{
					item.Amount = amount;

					if (cont is BankBox)
					{
						buyer.LocalOverheadMessage(
							MessageType.Regular, 0x38, false, "Given the cost of the items, they will be delivered to your bank.");
					}

					if (cont == null || !cont.TryDropItem(buyer, item, false))
					{
						// try to put it in the bank
						cont = buyer.BankBox;
						if (cont == null || !cont.TryDropItem(buyer, item, false))
						{
							//buyer.SendMessage(38, "You don't have enough room for that in your pack OR in your bank. It has been placed on the ground!");
							buyer.LocalOverheadMessage(
								MessageType.Regular,
								38,
								false,
								"You don't have enough room for that in your pack OR in your bank. It has been placed on the ground!");
							item.MoveToWorld(buyer.Location, buyer.Map);
						}
						else
						{
							//buyer.SendMessage(0x38, "Since you could not carry the item, it has been delivered to your bank.");   
							buyer.LocalOverheadMessage(
								MessageType.Regular, 38, false, "Since you could not carry the item, it has been delivered to your bank.");
						}
					}
				}
				else
				{
					item.Amount = 1;

					if (cont is BankBox)
					{
						buyer.LocalOverheadMessage(
							MessageType.Regular, 0x38, false, "Given the cost of the items, they will be delivered to your bank.");
					}

					if (cont == null || !cont.TryDropItem(buyer, item, false))
					{
						// try to put it in the bank
						cont = buyer.BankBox;

						if (cont == null || !cont.TryDropItem(buyer, item, false))
						{
							buyer.LocalOverheadMessage(
								MessageType.Regular,
								38,
								false,
								"You don't have enough room for that in your pack OR in your bank. It has been placed on the ground!");
							//buyer.SendMessage(38, );
							item.MoveToWorld(buyer.Location, buyer.Map);
						}
						else
						{
							buyer.LocalOverheadMessage(
								MessageType.Regular, 38, false, "Since you could not carry the item, it has been delivered to your bank.");
							//buyer.SendMessage(0x38, "Since you could not carry the item, it has been delivered to your bank.");
						}
					}

					for (int i = 1; i < amount; i++)
					{
						item = bii.GetEntity() as Item;

						if (item == null)
						{
							continue;
						}

						item.Amount = 1;

						if (cont != null && cont.TryDropItem(buyer, item, false))
						{
							continue;
						}
//.........这里部分代码省略.........
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:101,代码来源:BaseVendor.cs

示例12: DropLoot

		public static void DropLoot( Mobile from, Item loot, Container lootBag )
		{
			if ( !lootBag.TryDropItem( from, loot, false ) )	// Attempt to stack it
				lootBag.DropItem( loot );

			from.PlaySound( 0x2E6 ); // drop gold sound
		}
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:7,代码来源:Claim.cs

示例13: DropSilver

		public static void DropSilver( Mobile from, Server.Factions.Silver silver, Container silverBag )
		{
			if ( !silverBag.TryDropItem( from, silver, false ) )	// Attempt to stack it
				silverBag.DropItem( silver );

			from.PlaySound( 0x2E6 ); // drop gold sound
		}
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:7,代码来源:Claim.cs

示例14: DropGold

		public static void DropGold( Mobile from, Gold gold, Container goldBag )
		{
			if ( !goldBag.TryDropItem( from, gold, false ) )	// Attempt to stack it
				goldBag.DropItem( gold );

			from.PlaySound( 0x2E6 ); // drop gold sound
		}
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:7,代码来源:Claim.cs


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