本文整理匯總了C#中Server.Items.Container.FindItemByType方法的典型用法代碼示例。如果您正苦於以下問題:C# Container.FindItemByType方法的具體用法?C# Container.FindItemByType怎麽用?C# Container.FindItemByType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Server.Items.Container
的用法示例。
在下文中一共展示了Container.FindItemByType方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: AddSortedItem
public static void AddSortedItem( Item item, Container cont )
{
Item item2 = cont.FindItemByType( item.GetType() );
if ( item2 != null && item2.Amount < 60000 )
{
item2.Amount++;
item.Delete();
}
else
cont.DropItem( item );
}
示例2: IncreaseTypeAmount
private static void IncreaseTypeAmount( Container c, Type type, double iMultiplyValue )
{
Item item = c.FindItemByType(type);
if( item != null && item.Stackable )
item.Amount = (int)(item.Amount * iMultiplyValue);
}
示例3: FindItemByType
//note: this only works for stackable items.
public static Item FindItemByType( Container pack, Type type, int amount )
{
//can't search a null pack!
if( pack == null )
{
return null;
}
//first check the backpack if it exists
Item bagitem = pack.FindItemByType( type );
//if not, then look to pull from keys
if( ( bagitem == null || bagitem.Amount < amount ) && CraftWithdraw( pack, new Type[]{ type }, amount - ( bagitem != null ? bagitem.Amount : 0 ) ) )
{
//the keys will have added this item to pack, so go looking for it again
return pack.FindItemByType( type );
}
//return either the item found from the bag, or null if they weren't found in keys either
return bagitem;
}