本文整理汇总了C#中Server.Item.IsChildOf方法的典型用法代码示例。如果您正苦于以下问题:C# Item.IsChildOf方法的具体用法?C# Item.IsChildOf怎么用?C# Item.IsChildOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server.Item
的用法示例。
在下文中一共展示了Item.IsChildOf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanImbueItem
public static bool CanImbueItem(Mobile from, Item item)
{
if (item == null || !item.IsChildOf(from.Backpack))
from.SendLocalizedMessage(1079575); // The item must be in your backpack to imbue it.
else if (item.LootType == LootType.Blessed || item.LootType == LootType.Newbied)
from.SendLocalizedMessage(1080438); // You cannot imbue a blessed item.
else if (item is BaseWeapon && Spells.Mystic.EnchantSpell.IsUnderSpellEffects(from, (BaseWeapon)item))
from.SendLocalizedMessage(1080130); // You cannot imbue an item that is currently enchanted.
else if (item is BaseWeapon && ((BaseWeapon)item).FocusWeilder != null)
from.SendLocalizedMessage(1080444); //You cannot imbue an item that is under the effects of the ninjitsu focus attack ability.
else if (IsSpecialItem(item))
from.SendMessage("You cannot imbue an item with such strange magical properties.");
else if (item is IFactionItem && ((IFactionItem)item).FactionItemState != null)
from.SendLocalizedMessage(1114312); // You cannot imbue faction items.
else if (item is BaseJewel && !(item is BaseRing) && !(item is BaseBracelet))
from.SendLocalizedMessage(1079576); // You cannot imbue this item.
else if (IsInNonImbueList(item.GetType()))
from.SendLocalizedMessage(1079576); // You cannot imbue this item.
else if (item is BaseWeapon && ((BaseWeapon)item).TimesImbued >= 20)
from.SendMessage("This item has been modified too many times and cannot be imbued any further.");
else if (item is BaseArmor && ((BaseArmor)item).TimesImbued >= 20)
from.SendMessage("This item has been modified too many times and cannot be imbued any further.");
else if (item is BaseJewel && ((BaseJewel)item).TimesImbued >= 20)
from.SendMessage("This item has been modified too many times and cannot be imbued any further.");
else if (item is BaseHat && ((BaseHat)item).TimesImbued >= 20)
from.SendMessage("This item has been modified too many times and cannot be imbued any further.");
else
return true;
return false;
}
示例2: DestroyFurniture
private void DestroyFurniture( Mobile from, Item item )
{
if ( !from.InRange( item.GetWorldLocation(), 3 ) )
{
from.SendLocalizedMessage( 500446 ); // That is too far away.
return;
}
else if ( !item.IsChildOf( from.Backpack ) && !item.Movable )
{
from.SendLocalizedMessage( 500462 ); // You can't destroy that while it is here.
return;
}
from.SendLocalizedMessage( 500461 ); // You destroy the item.
Effects.PlaySound( item.GetWorldLocation(), item.Map, 0x3B3 );
if ( item is Container )
{
if ( item is TrapableContainer )
(item as TrapableContainer).ExecuteTrap( from );
((Container)item).Destroy();
}
else
{
item.Delete();
}
}
示例3: OnTarget
protected override void OnTarget( Mobile from, object targeted )
{
if ( targeted is ContainerReNameTool )
{
ContainerReNameTool knife = targeted as ContainerReNameTool;
if (knife != null)
{
// int knifeuses = knife.Charges;
// m_ContainerReNameTool.Charges += knifeuses;
// knife.Delete();
from.SendMessage( 38,"You cant use this on it self!");
}
}
else if ( targeted is CommodityDeedBox )
from.SendMessage( 38, "You cant use this on Commodity Deed Box!");
// put in else if statements to have it not engrave certain things, like baseweapons, or basearmor, etc etc
// else if ( targeted is Item )
else if ( targeted is BaseContainer )
{
m_engtarg = (Item)targeted;
if(!m_engtarg.IsChildOf(from.Backpack)) from.SendMessage( 38, "This must be in your backpack to change its name." );
else
{
from.SendMessage( 75,"What would you like to re-name this item to?" );
m_ContainerReNameTool.Charges -= 1 ;
m_ContainerReNameTool.InvalidateProperties();
from.Prompt = new RenameContPrompt( m_engtarg );
}
}
else from.SendMessage( 38, "You cannot re-name that." );
}
示例4: HasAccess
public static bool HasAccess( Mobile mob, Item item )
{
if( item == mob.Backpack )
return false;
else if( mob.AccessLevel >= AccessLevel.GameMaster ) // staff have no limits
return true;
else if( item.IsChildOf( mob.Backpack ) )
return true;
return false;
}
示例5: AddContextMenuEntries
public static void AddContextMenuEntries(Mobile from, Item item, List<ContextMenus.ContextMenuEntry> list, HarvestSystem system)
{
if ( system != Mining.System )
return;
if ( !item.IsChildOf( from.Backpack ) && item.Parent != from )
return;
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
return;
list.Add( new ContextMenuEntry( pm.ToggleMiningStone ? 6179 : 6178 ) );
list.Add( new ToggleMiningStoneEntry( pm, false, 6176 ) );
list.Add( new ToggleMiningStoneEntry( pm, true, 6177 ) );
}
示例6: CheckAccessible
public static bool CheckAccessible( Item tool, Mobile m )
{
return ( tool.IsChildOf( m ) || tool.Parent == m );
}
示例7: AddContextMenuEntries
public static void AddContextMenuEntries( Mobile from, Item item, List<ContextMenuEntry> list, HarvestSystem system )
{
if ( system != Mining.System )
return;
if ( !item.IsChildOf( from.Backpack ) && item.Parent != from )
return;
PlayerMobile pm = from as PlayerMobile;
if ( pm == null )
return;
int typeentry = 0;
if( pm.ToggleMiningStone )
typeentry = 6179;
if( pm.ToggleMiningGem )
typeentry = 1112239;
if( !pm.ToggleMiningStone && !pm.ToggleMiningGem)
typeentry = 6178;
ContextMenuEntry miningEntry = new ContextMenuEntry( typeentry );
miningEntry.Color = 0x421F;
list.Add( miningEntry );
list.Add( new ToggleMiningStoneEntry( pm, false, false, 6176 ) );
list.Add( new ToggleMiningStoneEntry( pm, true, false, 6177 ) );
list.Add( new ToggleMiningStoneEntry( pm, false, true, 1112237 ) );
}
示例8: OnDroppedOnto
public override bool OnDroppedOnto(Mobile from, Item target)
{
if (target == from.Backpack)
{
Item item = from.Backpack.FindItemByType(typeof(GoldLedger));
if (item != null)
{
from.SendMessage(2125, "You can only carry one gold ledger!");
return false;
}
}
else if (target.IsChildOf(from.Backpack))
{
Item item = from.Backpack.FindItemByType(typeof(GoldLedger));
if (item != null)
{
from.SendMessage(2125, "You can only carry one gold ledger!");
return false;
}
}
return target.OnDragDrop(from, this);
}
示例9: OnSubItemAdded
public override void OnSubItemAdded(Item item)
{
if (AccessLevel < AccessLevel.GameMaster && item.IsChildOf(this.Backpack))
{
int maxWeight = WeightOverloading.GetMaxWeight(this);
int curWeight = Mobile.BodyWeight + this.TotalWeight;
if (curWeight > maxWeight)
this.SendLocalizedMessage(1019035, true, String.Format(" : {0} / {1}", curWeight, maxWeight));
}
}
示例10: Invoke
public static EnhanceResult Invoke( Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage )
{
if ( item == null )
return EnhanceResult.BadItem;
if ( !item.IsChildOf( from.Backpack ) )
return EnhanceResult.NotInBackpack;
if ( !(item is BaseArmor) && !(item is BaseWeapon) )
return EnhanceResult.BadItem;
if ( CraftResources.IsStandard( resource ) )
return EnhanceResult.BadResource;
CraftItem craftItem = craftSystem.CraftItems.SearchFor( item.GetType() );
if ( craftItem == null || craftItem.Ressources.Count == 0 )
return EnhanceResult.BadItem;
int quality = 0;
bool allRequiredSkills = false;
if ( !craftItem.CheckSkills( from, resType, craftSystem, ref quality, ref allRequiredSkills, false ) )
return EnhanceResult.NoSkill;
CraftResourceInfo info = CraftResources.GetInfo( resource );
if ( info == null || info.ResourceTypes.Length == 0 )
return EnhanceResult.BadResource;
CraftAttributeInfo attributes = info.AttributeInfo;
if ( attributes == null )
return EnhanceResult.BadResource;
int resHue = 0, maxAmount = 0;
if ( !craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage ) )
return EnhanceResult.NoResources;
if ( craftSystem is DefBlacksmithy )
{
AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
if ( hammer != null )
{
hammer.UsesRemaining--;
if ( hammer.UsesRemaining < 1 )
hammer.Delete();
}
}
int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0;
int dura = 0, luck = 0, lreq = 0, dinc = 0;
int baseChance = 0;
bool physBonus = false;
bool fireBonus = false;
bool coldBonus = false;
bool nrgyBonus = false;
bool poisBonus = false;
bool duraBonus = false;
bool luckBonus = false;
bool lreqBonus = false;
bool dincBonus = false;
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( !CraftResources.IsStandard( weapon.Resource ) )
return EnhanceResult.AlreadyEnhanced;
baseChance = 20;
dura = weapon.MaxHitPoints;
luck = weapon.Attributes.Luck;
lreq = weapon.WeaponAttributes.LowerStatReq;
dinc = weapon.Attributes.WeaponDamage;
fireBonus = ( attributes.WeaponFireDamage > 0 );
coldBonus = ( attributes.WeaponColdDamage > 0 );
nrgyBonus = ( attributes.WeaponEnergyDamage > 0 );
poisBonus = ( attributes.WeaponPoisonDamage > 0 );
duraBonus = ( attributes.WeaponDurability > 0 );
luckBonus = ( attributes.WeaponLuck > 0 );
lreqBonus = ( attributes.WeaponLowerRequirements > 0 );
dincBonus = ( dinc > 0 );
}
else
{
BaseArmor armor = (BaseArmor)item;
if ( !CraftResources.IsStandard( armor.Resource ) )
return EnhanceResult.AlreadyEnhanced;
baseChance = 20;
phys = armor.PhysicalResistance;
fire = armor.FireResistance;
//.........这里部分代码省略.........
示例11: Invoke
public static EnhanceResult Invoke( Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage )
{
if ( item == null )
return EnhanceResult.BadItem;
if ( !item.IsChildOf( from.Backpack ) )
return EnhanceResult.NotInBackpack;
if ( !( item is BaseArmor ) && !( item is BaseWeapon ) )
return EnhanceResult.BadItem;
if ( CraftResources.IsStandard( resource ) )
return EnhanceResult.BadResource;
CraftItem craftItem;
if ( m_CheckForSubclass.Contains( item.GetType() ) )
craftItem = craftSystem.CraftItems.SearchForSubclass( item.GetType() );
else
craftItem = craftSystem.CraftItems.SearchFor( item.GetType() );
if ( craftItem == null || craftItem.Ressources.Count == 0 || craftItem.ForceCannotEnhance )
return EnhanceResult.BadItem;
if ( CraftableArtifacts.IsCraftableArtifact( item ) )
return EnhanceResult.BadItem;
bool exceptional = false;
bool allRequiredSkills = false;
if ( !craftItem.CheckSkills( from, resType, craftSystem, ref exceptional, ref allRequiredSkills, false ) )
return EnhanceResult.NoSkill;
CraftResourceInfo info = CraftResources.GetInfo( resource );
if ( info == null || info.ResourceTypes.Length == 0 )
return EnhanceResult.BadResource;
CraftAttributeInfo attributes = info.AttributeInfo;
if ( attributes == null )
return EnhanceResult.BadResource;
int resHue = 0, maxAmount = 0;
if ( !craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage ) )
return EnhanceResult.NoResources;
AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
if ( hammer != null )
{
if ( !( tool != null && ( tool is SewingKit || tool is RunicSewingKit ) ) )
{
hammer.UsesRemaining--;
if ( hammer.UsesRemaining < 1 )
hammer.Delete();
}
}
int phys = 0, fire = 0, cold = 0, pois = 0, nrgy = 0;
int dura = 0, luck = 0, lreq = 0, dinc = 0;
int baseChance = 0;
bool physBonus = false;
bool fireBonus = false;
bool coldBonus = false;
bool nrgyBonus = false;
bool poisBonus = false;
bool duraBonus = false;
bool luckBonus = false;
bool lreqBonus = false;
bool dincBonus = false;
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon) item;
if ( !CraftResources.IsStandard( weapon.Resource ) )
return EnhanceResult.AlreadyEnhanced;
baseChance = 20;
dura = weapon.MaxHitPoints;
luck = weapon.Attributes.Luck;
lreq = weapon.WeaponAttributes.LowerStatReq;
dinc = weapon.Attributes.WeaponDamage;
fireBonus = ( attributes.WeaponFireDamage > 0 );
coldBonus = ( attributes.WeaponColdDamage > 0 );
nrgyBonus = ( attributes.WeaponEnergyDamage > 0 );
poisBonus = ( attributes.WeaponPoisonDamage > 0 );
duraBonus = ( attributes.WeaponDurability > 0 );
luckBonus = ( attributes.WeaponLuck > 0 );
lreqBonus = ( attributes.WeaponLowerRequirements > 0 );
dincBonus = ( dinc > 0 );
}
else
//.........这里部分代码省略.........
示例12: TryPlace
public static bool TryPlace(Mobile from, int boardsRequired, int ingotsRequired, Item tool)
{
bool bReturn = false;
if (tool.IsChildOf(from.Backpack) || tool.Parent == from)
{
PlayerMobile pm = from as PlayerMobile;
if (pm != null)
{
Point3D targetPoint = from.Location;
CustomRegion cr = CustomRegion.FindDRDTRegion(from.Map, targetPoint);
if (cr is TownshipRegion)
{
TownshipRegion tsr = cr as TownshipRegion;
if (tsr != null && tsr.TStone != null && tsr.TStone.Guild != null &&
tsr.TStone.Guild == from.Guild)
{
//for Adam, check for 100% ownership
if (1.0 == TownshipDeed.GetPercentageOfGuildedHousesInArea(tsr.TStone.TownshipCenter, tsr.TStone.Map, tsr.TStone.Extended ? TownshipStone.EXTENDED_RADIUS : TownshipStone.INITIAL_RADIUS, tsr.TStone.Guild, false))
{
//make sure we're not in a house, or right beside it
BaseHouse house = null;
bool bHouseRestriction = false;
//find all the houses within 5 tiles of this location
int radius = 5;
Dictionary<BaseHouse, int> houseDict = new Dictionary<BaseHouse, int>();
for (int i = radius * -1; i <= radius && house == null; i++)
{
for (int j = radius * -1; j <= radius && house == null; j++)
{
Point3D currentCheck = new Point3D(targetPoint.X + i, targetPoint.Y + j, targetPoint.Z);
house = BaseHouse.FindHouseAt(currentCheck, from.Map, 16);
if (house != null)
{
int distance = (int)Math.Sqrt(sqr(currentCheck.X - targetPoint.X) + sqr(currentCheck.Y - targetPoint.Y));
if (houseDict.ContainsKey(house))
{
int saveddistance = houseDict[house];
if (saveddistance > distance)
{
houseDict[house] = distance;
}
}
else
{
houseDict.Add(house, distance);
}
}
}
}
//now we have a list of all houses within the radius from the point where the wall is to be built and their distance from the point
foreach (BaseHouse h in houseDict.Keys)
{
if (h.Owner != null)
{
if (tsr.TStone.Guild.IsMember(h.Owner) == false && houseDict[h] <= 5.0)
{
bHouseRestriction = true;
break;
}
// else if (houseDict[h] <= 1.0)
// {
// bHouseRestriction = true;
// break;
// }
}
}
if (bHouseRestriction == false)
{
//next check for teleporters
bool bTeleporterRestriction = false;
int iTeleporterDistanceRange = TownshipSettings.WallTeleporterDistance;
IPooledEnumerable itemlist = from.Map.GetItemsInRange(targetPoint, iTeleporterDistanceRange);
foreach (Item item in itemlist)
{
if (item is Teleporter)
{
bTeleporterRestriction = true;
break;
}
}
itemlist.Free();
if (bTeleporterRestriction == false)
{
bool hasResources = false;
Item[] boards = from.Backpack.FindItemsByType(typeof(Board), true);
Item[] ingots = from.Backpack.FindItemsByType(typeof(IronIngot), true);
int boardCount = 0;
int ingotCount = 0;
for (int i = 0; i < boards.Length; i++)
{
//.........这里部分代码省略.........
示例13: TryAddEntry
public void TryAddEntry(Item item, Mobile from)
{
if (!CanUse(from) || item == null)
return;
if (!CheckRange(from))
from.SendLocalizedMessage(3000268); // that is too far away.
else if (!(item is TreasureMap || item is SOS || item is MessageInABottle))
from.SendLocalizedMessage(1153564); // That is not a treasure map or message in a bottle.
else if (!item.IsChildOf(from.Backpack))
from.SendLocalizedMessage(1054107); // This item must be in your backpack.
else if (m_Entries.Count >= 500)
from.SendLocalizedMessage(1153565); // The locker is full
else
{
DaviesLockerEntry entry = null;
if (item is TreasureMap)
entry = new TreasureMapEntry((TreasureMap)item);
else if (item is SOS)
entry = new SOSEntry((SOS)item);
else if (item is MessageInABottle)
entry = new SOSEntry((MessageInABottle)item);
if (entry != null)
{
m_Entries.Add(entry);
from.CloseGump(typeof(DaviesLockerGump));
from.SendGump(new DaviesLockerGump(from, this));
item.Delete();
InvalidateProperties();
}
}
}
示例14: CanUse
public static bool CanUse( Mobile from, Item toUse )
{
if( from == null || toUse == null )
return false;
if( from.Frozen )
from.SendAsciiMessage( "You are frozen and you cannot do that." );
else if( !toUse.Movable )
from.SendAsciiMessage( "You can't use that." );
else if( !toUse.IsChildOf( from.Backpack ) && toUse.Parent != from && !from.InRange( toUse.Location, 4 ) && !toUse.IsChildOf( from.BankBox ) && !from.BankBox.Opened )
from.SendAsciiMessage( "You can't reach that." );
else if( !from.InLOS( toUse ) && !toUse.IsChildOf( from.BankBox ) && !from.BankBox.Opened )
from.SendAsciiMessage( "You can't see that." );
else
return toUse.CanEquip( from );
return false;
}
示例15: Invoke
public static EnhanceResult Invoke( Mobile from, CraftSystem craftSystem, BaseTool tool, Item item, CraftResource resource, Type resType, ref object resMessage )
{
if ( item == null )
return EnhanceResult.BadItem;
if ( !item.IsChildOf( from.Backpack ) )
return EnhanceResult.NotInBackpack;
if ( !(item is BaseArmor) && !(item is BaseWeapon) && !(item is BaseOtherEquipable) )
return EnhanceResult.BadItem;
if ( item is IArcaneEquip )
{
IArcaneEquip eq = (IArcaneEquip)item;
if ( eq.IsArcane )
return EnhanceResult.BadItem;
}
if ( CraftResources.IsStandard( resource ) )
return EnhanceResult.BadResource;
int num = craftSystem.CanCraft( from, tool, item.GetType() );
if ( num > 0 )
{
resMessage = num;
return EnhanceResult.None;
}
CraftItem craftItem = craftSystem.CraftItems.SearchFor( item.GetType() );
if ( craftItem == null || craftItem.Resources.Count == 0 )
return EnhanceResult.BadItem;
bool allRequiredSkills = false;
if( craftItem.GetSuccessChance( from, resType, craftSystem, false, ref allRequiredSkills ) <= 0.0 )
return EnhanceResult.NoSkill;
CraftResourceInfo info = CraftResources.GetInfo( resource );
if ( info == null || info.ResourceTypes.Length == 0 )
return EnhanceResult.BadResource;
CraftAttributeInfo attributes = info.AttributeInfo;
if ( attributes == null )
return EnhanceResult.BadResource;
int resHue = 0, maxAmount = 0;
if ( !craftItem.ConsumeRes( from, resType, craftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref resMessage ) )
return EnhanceResult.NoResources;
if ( craftSystem is DefBlacksmithy )
{
AncientSmithyHammer hammer = from.FindItemOnLayer( Layer.OneHanded ) as AncientSmithyHammer;
if ( hammer != null )
{
hammer.UsesRemaining--;
if ( hammer.UsesRemaining < 1 )
hammer.Delete();
}
}
int baseChance = 0;
BonusAttribute[] bonusAttrs = null;
BonusAttribute[] randomAttrs = null;
if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( !CraftResources.IsStandard( weapon.Resource ) )
return EnhanceResult.AlreadyEnhanced;
baseChance = 18; // Silver: used to be 20
CheckSkill( ref baseChance, from, craftSystem );
int numOfRand = attributes.RandomAttributeCount;
bonusAttrs = attributes.WeaponAttributes;
randomAttrs = BonusAttributesHelper.GetRandomAttributes( attributes.WeaponRandomAttributes, numOfRand );
}
else if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor)item;
if ( !CraftResources.IsStandard( armor.Resource ) )
return EnhanceResult.AlreadyEnhanced;
baseChance = 18; // Silver: used to be 20
CheckSkill( ref baseChance, from, craftSystem );
int numOfRand = attributes.RandomAttributeCount;
if ( armor.UsesShieldAttrs )
{
//.........这里部分代码省略.........