本文整理汇总了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);
}
}
示例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 );
}
}
}
示例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 );
}
}
}
}
示例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);
}
}
}
}
示例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 );
}
示例6: GenerateGold
public void GenerateGold( Mobile creature, Container c )
{
c.TryDropItem( creature, new Gold( m_Gold.Roll() ), false, false );
}
示例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 );
}
}
}
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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 );
}
}
}
示例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;
}
//.........这里部分代码省略.........
示例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
}
示例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
}
示例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
}