本文整理汇总了C#中Mobile.FindBankNoCreate方法的典型用法代码示例。如果您正苦于以下问题:C# Mobile.FindBankNoCreate方法的具体用法?C# Mobile.FindBankNoCreate怎么用?C# Mobile.FindBankNoCreate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mobile
的用法示例。
在下文中一共展示了Mobile.FindBankNoCreate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetBalance
public static ulong GetBalance(Mobile from, Type currencyType, out Item[] currency, out ulong credit)
{
ulong balance = 0;
BankBox bank = from.FindBankNoCreate();
if (bank != null)
{
Type cType = bank.Expansion == Expansion.T2A ? typeof(Silver) : typeof(Gold);
credit = cType == currencyType ? bank.Credit : 0;
balance += credit;
currency = bank.FindItemsByType(currencyType, true).ToArray();
balance = currency.Aggregate(balance, (current, t) => current + (ulong)t.Amount);
}
else
{
currency = new Item[0];
credit = 0;
}
return balance;
}
示例2: GetBalance
public static int GetBalance(Mobile m)
{
double balance = 0;
if (AccountGold.Enabled && m.Account != null)
{
int goldStub;
m.Account.GetGoldBalance(out goldStub, out balance);
if (balance > Int32.MaxValue)
{
return Int32.MaxValue;
}
}
Container bank = m.FindBankNoCreate();
if (bank != null)
{
var gold = bank.FindItemsByType<Gold>();
var checks = bank.FindItemsByType<BankCheck>();
balance += gold.Aggregate(0.0, (c, t) => c + t.Amount);
balance += checks.Aggregate(0.0, (c, t) => c + t.Worth);
}
return (int)Math.Max(0, Math.Min(Int32.MaxValue, balance));
}
示例3: OnDoubleClick
public override void OnDoubleClick( Mobile from )
{
BankBox box = from.FindBankNoCreate();
if ( box != null && IsChildOf( box ) )
{
Delete();
int deposited = 0;
int toAdd = m_Worth;
Gold gold;
while ( toAdd > 60000 )
{
gold = new Gold( 60000 );
if ( box.TryDropItem( from, gold, false ) )
{
toAdd -= 60000;
deposited += 60000;
}
else
{
gold.Delete();
from.AddToBackpack( new BankCheck( toAdd ) );
toAdd = 0;
break;
}
}
if ( toAdd > 0 )
{
gold = new Gold( toAdd );
if ( box.TryDropItem( from, gold, false ) )
{
deposited += toAdd;
}
else
{
gold.Delete();
from.AddToBackpack( new BankCheck( toAdd ) );
}
}
// Gold was deposited in your account:
from.SendLocalizedMessage( 1042672, true, " " + deposited.ToString() );
}
else
{
from.SendLocalizedMessage( 1047026 ); // That must be in your bank box to use it.
}
}
示例4: Deposit
public static bool Deposit(Mobile from, int amount)
{
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
{
return true;
}
var box = from.FindBankNoCreate();
if (box == null)
{
return false;
}
var items = new List<Item>();
while (amount > 0)
{
Item item;
if (amount < 5000)
{
item = new Gold(amount);
amount = 0;
}
else if (amount <= 1000000)
{
item = new BankCheck(amount);
amount = 0;
}
else
{
item = new BankCheck(1000000);
amount -= 1000000;
}
if (box.TryDropItem(from, item, false))
{
items.Add(item);
}
else
{
item.Delete();
foreach (var curItem in items)
{
curItem.Delete();
}
return false;
}
}
return true;
}
示例5: Deposit
public static bool Deposit( Mobile from, int amount )
{
BankBox box = from.FindBankNoCreate();
if ( box == null )
return false;
List<Item> items = new List<Item>();
while ( amount > 0 )
{
Item item;
if ( amount < 5000 )
{
item = new Gold( amount );
amount = 0;
}
else if ( amount <= 1000000 )
{
item = new BankCheck( amount );
amount = 0;
}
else
{
item = new BankCheck( 1000000 );
amount -= 1000000;
}
if ( box.TryDropItem( from, item, false ) )
{
items.Add( item );
}
else
{
item.Delete();
foreach ( Item curItem in items )
{
curItem.Delete();
}
return false;
}
}
return true;
}
示例6: AllowHousing
public override bool AllowHousing(Mobile from, Point3D p)
{
if (this.m_Stone == null)
return false;
if (this.m_Stone.IsExpired)
return true;
if (this.m_Stone.Deed == null)
return false;
Container pack = from.Backpack;
if (pack != null && this.ContainsDeed(pack))
return true;
BankBox bank = from.FindBankNoCreate();
if (bank != null && this.ContainsDeed(bank))
return true;
return false;
}
示例7: PackToBank
/// <summary>
/// Moves all of the given Mobile's items to their bank.
/// </summary>
public virtual void PackToBank( Mobile m )
{
if( m == null || !m.Player )
return;
BankBox bank = m.FindBankNoCreate();
Backpack pack = new Backpack();
pack.Hue = 1157;
List<Item> items = new List<Item>();
for( int i = 0; i < m.Items.Count; i++ )
{
if( m.Items[i] is BankBox || (m.Backpack != null && m.Items[i].Serial == m.Backpack.Serial) )
continue;
items.Add(m.Items[i]);
}
if( m.Backpack != null )
{
for( int i = 0; i < m.Backpack.Items.Count; i++ )
items.Add(m.Backpack.Items[i]);
}
items.ForEach(
delegate( Item i )
{
pack.AddItem(i);
});
items.Clear();
if( bank == null )
pack.MoveToWorld(m.Location, m.Map);
else
bank.AddItem(pack);
}
示例8: GetBalance
public static int GetBalance( Mobile from, out Item[] gold, out Item[] checks )
{
int balance = 0;
Container bank = from.FindBankNoCreate();
if ( bank != null )
{
gold = bank.FindItemsByType( typeof( Gold ) );
checks = bank.FindItemsByType( typeof( BankCheck ) );
for ( int i = 0; i < gold.Length; ++i )
balance += gold[i].Amount;
for ( int i = 0; i < checks.Length; ++i )
balance += ((BankCheck)checks[i]).Worth;
}
else
{
gold = checks = new Item[0];
}
return balance;
}
示例9: OnDoubleClick
public override void OnDoubleClick( Mobile from )
{
int number;
BankBox box = from.FindBankNoCreate();
CommodityDeedBox cox = CommodityDeedBox.Find( this );
// Veteran Rewards mods
if ( m_Commodity != null )
{
if ( box != null && IsChildOf( box ) )
{
number = 1047031; // The commodity has been redeemed.
box.DropItem( m_Commodity );
m_Commodity = null;
Delete();
}
else if ( cox != null )
{
if ( cox.IsSecure )
{
number = 1047031; // The commodity has been redeemed.
cox.DropItem( m_Commodity );
m_Commodity = null;
Delete();
}
else
number = 1080525; // The commodity deed box must be secured before you can use it.
}
else
{
if( Core.ML )
{
number = 1080526; // That must be in your bank box or commodity deed box to use it.
}
else
{
number = 1047024; // To claim the resources ....
}
}
}
else if ( cox != null && !cox.IsSecure )
{
number = 1080525; // The commodity deed box must be secured before you can use it.
}
else if ( ( box == null || !IsChildOf( box ) ) && cox == null )
{
if( Core.ML )
{
number = 1080526; // That must be in your bank box or commodity deed box to use it.
}
else
{
number = 1047026; // That must be in your bank box to use it.
}
}
else
{
number = 1047029; // Target the commodity to fill this deed with.
from.Target = new InternalTarget( this );
}
from.SendLocalizedMessage( number );
}
示例10: OnTarget
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Deed.Deleted )
return;
int number;
if ( m_Deed.Commodity != null )
{
number = 1047028; // The commodity deed has already been filled.
}
else if ( targeted is Item )
{
BankBox box = from.FindBankNoCreate();
CommodityDeedBox cox = CommodityDeedBox.Find( m_Deed );
// Veteran Rewards mods
if ( box != null && m_Deed.IsChildOf( box ) && ((Item)targeted).IsChildOf( box ) ||
cox != null && cox.IsSecure && ((Item)targeted).IsChildOf( cox ) )
{
if ( m_Deed.SetCommodity( (Item) targeted ) )
{
m_Deed.Hue = 0x592;
number = 1047030; // The commodity deed has been filled.
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
}
else
{
if( Core.ML )
{
number = 1080526; // That must be in your bank box or commodity deed box to use it.
}
else
{
number = 1047026; // That must be in your bank box to use it.
}
}
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
from.SendLocalizedMessage( number );
}
示例11: OnTarget
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Deed.Deleted )
return;
int number;
if ( m_Deed.Commodity != null )
{
number = 1047028; // The commodity deed has already been filled.
}
else if ( targeted is Item )
{
BankBox box = from.FindBankNoCreate();
if ( box != null && m_Deed.IsChildOf( box ) && ((Item)targeted).IsChildOf( box ) )
{
if ( m_Deed.SetCommodity( (Item) targeted ) )
{
number = 1047030; // The commodity deed has been filled.
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
}
else
{
number = 1047026; // That must be in your bank box to use it.
}
}
else
{
number = 1047027; // That is not a commodity the bankers will fill a commodity deed with.
}
from.SendLocalizedMessage( number );
}
示例12: IsUsableBy
public bool IsUsableBy(Mobile from)
{
Item root = this.RootParent as Item;
return this.IsChildOf(from.Backpack) || this.IsChildOf(from.FindBankNoCreate()) || this.IsLockedDown && this.IsAccessibleTo(from) || root != null && root.IsSecure && root.IsAccessibleTo(from);
}
示例13: OnTarget
protected override void OnTarget( Mobile from, object targeted )
{
if ( m_Deed.Deleted )
return;
int number;
if ( m_Deed.Commodity != null )
{
number = 1047028; // The commodity deed has already been filled.
}
else if ( targeted is Item )
{
BankBox box = from.FindBankNoCreate();
string XferResource = "...";
int XferAmount = 0;
int r = 0;
if (box != null && m_Deed.IsChildOf(box) && ((Item)targeted).IsChildOf(box))
{
// RESOURCE EDIT
if (targeted is BaseIngot) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
{
from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
number = 1047027;
m_Deed.Delete();
BaseIngot youringots = (BaseIngot)targeted;
string s_resource = Convert.ToString(youringots.Resource);
XferAmount = youringots.Amount;
switch (s_resource)
{
case "Iron": r = 1; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "DullCopper": r = 2; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "ShadowIron": r = 3; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Copper": r = 4; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Bronze": r = 5; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Gold": r = 6; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Silver": r = 7; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Agapite": r = 8; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Verite": r = 9; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Valorite": r = 10; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Jade": r = 11; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Moonstone": r = 12; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
case "Sunstone": r = 13; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youringots.Delete(); break;
//case "": r = 13; box.DropItem(new YaksCommodityDeed(XferAmount, r)); youringots.Delete(); break;
}
}
else if (targeted is BaseLeather) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
{
from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
number = 1047027;
m_Deed.Delete();
BaseLeather youritem = (BaseLeather)targeted;
string s_resource = Convert.ToString(youritem.Resource);
XferAmount = youritem.Amount;
switch (s_resource)
{
case "RegularLeather": r = 101; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "SpinedLeather": r = 102; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "HornedLeather": r = 103; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "BarbedLeather": r = 104; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "DaemonLeather": r = 105; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "DragonLeather": r = 106; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
}
}
else if (targeted is BaseScales) // || targeted is BaseBoards || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
{
from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
number = 1047027;
m_Deed.Delete();
BaseScales youritem = (BaseScales)targeted;
string s_resource = Convert.ToString(youritem.Resource);
XferAmount = youritem.Amount;
switch (s_resource)
{
case "RedScales": r = 201; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "YellowScales": r = 202; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "BlackScales": r = 203; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "GreenScales": r = 204; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "WhiteScales": r = 205; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
case "BlueScales": r = 206; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
//case "IceScales": r = 207; box.DropItem(new YaksCommodityDeed(XferAmount, r)); youritem.Delete(); break;
}
}
else if (targeted is BaseLog)// || targeted is BaseLog || targeted is BaseLeather || targeted is BaseScales || targeted is BasePowder || targeted is BaseCrystal)
{
from.SendMessage("You require a 'Special Commodity Deed' for this custom resource item...");
number = 1047027;
m_Deed.Delete();
BaseLog youritem = (BaseLog)targeted;
string s_resource = Convert.ToString(youritem.Resource);
XferAmount = youritem.Amount;
switch (s_resource)
{
case "Regular": r = 301; box.DropItem(new SpecialCommodityDeed(XferAmount, r)); youritem.Delete(); break;
//.........这里部分代码省略.........
示例14: OnDoubleClick
public override void OnDoubleClick( Mobile from )
{
int number;
BankBox box = from.FindBankNoCreate();
if ( m_Commodity != null )
{
if ( box != null && IsChildOf( box ) )
{
number = 1047031; // The commodity has been redeemed.
box.DropItem( m_Commodity );
m_Commodity = null;
Delete();
}
else
{
number = 1047024; // To claim the resources ....
}
}
else if ( box == null || !IsChildOf( box ) )
{
number = 1047026; // That must be in your bank box to use it.
}
else
{
number = 1047029; // Target the commodity to fill this deed with.
from.Target = new InternalTarget( this );
}
from.SendLocalizedMessage( number );
}
示例15: DepositUpTo
public static int DepositUpTo(Mobile from, int amount)
{
// If for whatever reason the TOL checks fail, we should still try old methods for depositing currency.
if (AccountGold.Enabled && from.Account != null && from.Account.DepositGold(amount))
{
return amount;
}
var box = from.FindBankNoCreate();
if (box == null)
{
return 0;
}
var amountLeft = amount;
while (amountLeft > 0)
{
Item item;
int amountGiven;
if (amountLeft < 5000)
{
item = new Gold(amountLeft);
amountGiven = amountLeft;
}
else if (amountLeft <= 1000000)
{
item = new BankCheck(amountLeft);
amountGiven = amountLeft;
}
else
{
item = new BankCheck(1000000);
amountGiven = 1000000;
}
if (box.TryDropItem(from, item, false))
{
amountLeft -= amountGiven;
}
else
{
item.Delete();
break;
}
}
return amount - amountLeft;
}