本文整理汇总了C#中Item.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Item.GetType方法的具体用法?C# Item.GetType怎么用?C# Item.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSellPriceFor
public int GetSellPriceFor( Item item )
{
int price = (int)m_Table[item.GetType()];
if (price == -1) // shouldn't ever be asking for this anyway, but for sanity
return (int)ResourcePool.GetWholesalePrice(item.GetType());
if ( item is BaseArmor )
{
BaseArmor armor = (BaseArmor)item;
if ( armor.Quality == ArmorQuality.Low )
price = (int)( price * 0.60 );
else if ( armor.Quality == ArmorQuality.Exceptional )
price = (int)( price * 1.25 );
price += 100 * (int)armor.Durability;
price += 100 * (int)armor.ProtectionLevel;
if ( price < 1 )
price = 1;
}
else if ( item is BaseWeapon )
{
BaseWeapon weapon = (BaseWeapon)item;
if ( weapon.Quality == WeaponQuality.Low )
price = (int)( price * 0.60 );
else if ( weapon.Quality == WeaponQuality.Exceptional )
price = (int)( price * 1.25 );
price += 100 * (int)weapon.DurabilityLevel;
price += 100 * (int)weapon.DamageLevel;
if ( price < 1 )
price = 1;
}
else if ( item is BaseBeverage )
{
int price1 = price, price2 = price;
if ( item is Pitcher )
{ price1 = 3; price2 = 5; }
else if ( item is BeverageBottle )
{ price1 = 3; price2 = 3; }
else if ( item is Jug )
{ price1 = 6; price2 = 6; }
BaseBeverage bev = (BaseBeverage)item;
if ( bev.IsEmpty || bev.Content == BeverageType.Milk )
price = price1;
else
price = price2;
}
return price;
}
示例2: CheckDrop
private bool CheckDrop(Mobile from, Item dropped)
{
bool valid = false;
for (int i = 0; i < m_AllowedReagents.Length; i++)
{
if (dropped.GetType() == m_AllowedReagents[i])
{
valid = true;
break;
}
}
if (valid)
{
int curAmount = 0;
List<Item> items = this.Items;
foreach (Item item in items)
{
if (item.GetType() == dropped.GetType())
curAmount += item.Amount;
}
if ((curAmount + dropped.Amount) > m_MaxReagents)
{
from.SendMessage("That pouch cannot hold anymore of that type of reagent!");
return false;
}
else return true;
}
else
{
from.SendMessage("You can only place reagents in this pouch.");
return false;
}
}
示例3: gainItem
public void gainItem(Item item)
{
if (item.GetType() == typeof(ItemArmour)){
ownedArmours.Add(item.ItemID);
}
if (item.GetType() == typeof(ItemWeapon)){
ownedWeapons.Add(item.ItemID);
}
if (item.GetType() == typeof(ItemMisc)){
ownedMisc.Add(item.ItemID);
}
SaveLoad.Get().SaveUserData();
}
示例4: CanReforge
public static bool CanReforge(Mobile from, Item item, CraftSystem crsystem)
{
CraftItem crItem = null;
bool allowableSpecial = m_AllowableTable.ContainsKey(item.GetType());
if (!allowableSpecial)
{
foreach (CraftSystem system in CraftSystem.Systems)
{
if (system == crsystem && system != null && system.CraftItems != null)
crItem = system.CraftItems.SearchFor(item.GetType());
if (crItem != null)
break;
}
}
if (crItem == null && !allowableSpecial)
{
from.SendLocalizedMessage(1152279); // You cannot re-forge that item with this tool.
return false;
}
bool goodtogo = true;
int mods = GetTotalMods(item);
int maxmods = item is JukaBow ||item is BaseWeapon && !((BaseWeapon)item).DImodded ? 1 : 0;
if(m_AllowableTable.ContainsKey(item.GetType()) && m_AllowableTable[item.GetType()] != crsystem)
goodtogo = false;
else if (mods > maxmods)
goodtogo = false;
else if (item.LootType == LootType.Blessed || item.LootType == LootType.Newbied)
goodtogo = false;
else if (item is BaseWeapon && Server.Spells.Mystic.EnchantSpell.IsUnderSpellEffects(from, (BaseWeapon)item))
goodtogo = false;
else if (item is BaseWeapon && ((BaseWeapon)item).FocusWeilder != null)
goodtogo = false;
else if (!allowableSpecial && ((item is BaseWeapon && !((BaseWeapon)item).PlayerConstructed) || (item is BaseArmor && !((BaseArmor)item).PlayerConstructed)))
goodtogo = false;
else if (!allowableSpecial && item is BaseClothing && !(item is BaseHat))
goodtogo = false;
else if (Imbuing.IsInNonImbueList(item.GetType()))
goodtogo = false;
if (!goodtogo)
from.SendLocalizedMessage(1152113); // You cannot reforge that item.
return goodtogo;
}
示例5: Start
// Use this for initialization
public static void Start()
{
items = new List<Item>();
string[] files = Directory.GetFiles("items");
foreach (string file in files)
{
Item item = new Item();
string[] lines = File.ReadAllLines(file);
foreach (string line in lines)
{
int x = 0;
bool b = false; ;
string[] l = line.Split(' ');
try
{
if (l[0].Equals("tags"))
{
List<string> tags = new List<string>();
for (int i = 2; i < l.Length; i++)
tags.Add(l[i]);
item.tags = tags;
}
else if (l[0].Equals("sprite"))
{
Sprite sprite = Resources.Load<Sprite>(l[2]);
GameObject gameObject = new GameObject();
gameObject.AddComponent<SpriteRenderer>();
SpriteRenderer SR = gameObject.GetComponent<SpriteRenderer>();
SR.sprite = sprite;
item.sprite = Instantiate(gameObject) as GameObject;
item.sprite.SetActive(false);
}
else if (int.TryParse(l[2], out x))
item.GetType().GetProperty(l[0]).SetValue(item, x, null);
else if (bool.TryParse(l[2], out b))
item.GetType().GetProperty(l[0]).SetValue(item, b, null);
else
item.GetType().GetProperty(l[0]).SetValue(item, l[2], null);
}
catch (NullReferenceException)
{
print("Error with item " + file + " property " + l[0] + " is invalid");
}
}
items.Add(item);
}
}
示例6: IsValidItem
public static bool IsValidItem( Item i )
{
if( i is BasePigmentsOfTokuno )
return false;
Type t = i.GetType();
CraftResource resource = CraftResource.None;
if( i is BaseWeapon )
resource = ((BaseWeapon)i).Resource;
else if( i is BaseArmor )
resource = ((BaseArmor)i).Resource;
if( !CraftResources.IsStandard( resource ) )
return true;
return(
IsInTypeList( t, TreasuresOfTokuno.LesserArtifactsTotal )
|| IsInTypeList( t, TreasuresOfTokuno.GreaterArtifacts )
|| IsInTypeList( t, DemonKnight.ArtifactRarity10 )
|| IsInTypeList( t, DemonKnight.ArtifactRarity11 )
|| IsInTypeList( t, BaseCreature.MinorArtifactsMl )
|| IsInTypeList( t, StealableArtifactsSpawner.TypesOfEntires )
|| IsInTypeList( t, Paragon.Artifacts )
|| IsInTypeList( t, Leviathan.Artifacts )
|| IsInTypeList( t, TreasureMapChest.Artifacts )
);
}
示例7: IsValidItem
public static bool IsValidItem( Item i )
{
if( i is BasePigmentsOfTokuno )
return false;
Type t = i.GetType();
CraftResource resource = CraftResource.None;
if( i is BaseWeapon )
resource = ((BaseWeapon)i).Resource;
else if( i is BaseArmor )
resource = ((BaseArmor)i).Resource;
if( !CraftResources.IsStandard( resource ) )
return true;
return(
IsInTypeList( t, TreasuresOfTokuno.LesserArtifactsTotal )
|| IsInTypeList( t, TreasuresOfTokuno.GreaterArtifacts )
|| IsInTypeList( t, DemonKnight.ArtifactRarity10 )
|| IsInTypeList( t, DemonKnight.ArtifactRarity11 )
|| IsInTypeList( t, BaseCreature.MinorArtifactsMl )
|| IsInTypeList( t, StealableArtifactsSpawner.TypesOfEntires )
|| IsInTypeList( t, Paragon.Artifacts )
|| IsInTypeList( t, Leviathan.Artifacts )
|| IsInTypeList( t, TreasureMapChest.Artifacts )
|| (i is BaseHat && !(i is OrcishKinMask) ) // Added by Silver
|| (i is Spellbook && ((Spellbook)i).SpellbookType == SpellbookType.Regular ) // Added by Silver
|| (i is BookOfLostKnowledge) // Added by Silver
);
}
示例8: TypeIsLootable
public static bool TypeIsLootable( Container bag, Item item )
{
if ( item == null )
return false;
if ( ClaimConfig.LootArtifacts && Misc.IsArtifact( item ) )
return true;
Type itemType = item.GetType();
if ( null != bag && bag is LootBag && !bag.Deleted )
{
lock ( ( (LootBag)bag ).SyncRoot )
{
foreach ( Type lootType in ( (LootBag)bag ).TypesToLoot )
{
if ( null != lootType && ( itemType == lootType || itemType.IsSubclassOf( lootType ) ) )
return true;
}
}
}
else
{
foreach ( Type lootType in ClaimConfig.TypesToLoot )
{
if ( null != lootType && ( itemType == lootType || itemType.IsSubclassOf( lootType ) ) )
return true;
}
}
return false;
}
示例9: Resmelt
private SmeltResult Resmelt( Mobile from, Item item, CraftResource resource )
{
try
{
if ( CraftResources.GetType( resource ) != CraftResourceType.Metal )
return SmeltResult.Invalid;
CraftResourceInfo info = CraftResources.GetInfo( resource );
if ( info == null || info.ResourceTypes.Length == 0 )
return SmeltResult.Invalid;
CraftItem craftItem = m_CraftSystem.CraftItems.SearchFor( item.GetType() );
if ( craftItem == null || craftItem.Resources.Count == 0 )
return SmeltResult.Invalid;
CraftRes craftResource = craftItem.Resources.GetAt( 0 );
if ( craftResource.Amount < 2 )
return SmeltResult.Invalid; // Not enough metal to resmelt
double difficulty = 0.0;
switch ( resource )
{
case CraftResource.DullCopper: difficulty = 65.0; break;
case CraftResource.ShadowIron: difficulty = 70.0; break;
case CraftResource.Copper: difficulty = 75.0; break;
case CraftResource.Bronze: difficulty = 80.0; break;
case CraftResource.Gold: difficulty = 85.0; break;
case CraftResource.Agapite: difficulty = 90.0; break;
case CraftResource.Verite: difficulty = 95.0; break;
case CraftResource.Valorite: difficulty = 99.0; break;
}
if ( difficulty > from.Skills[ SkillName.Mining ].Value )
return SmeltResult.NoSkill;
Type resourceType = info.ResourceTypes[0];
Item ingot = (Item)Activator.CreateInstance( resourceType );
if ( item is DragonBardingDeed || (item is BaseArmor && ((BaseArmor)item).PlayerConstructed) || (item is BaseWeapon && ((BaseWeapon)item).PlayerConstructed) || (item is BaseClothing && ((BaseClothing)item).PlayerConstructed) )
ingot.Amount = craftResource.Amount / 2;
else
ingot.Amount = 1;
item.Delete();
from.AddToBackpack( ingot );
from.PlaySound( 0x2A );
from.PlaySound( 0x240 );
return SmeltResult.Success;
}
catch
{
}
return SmeltResult.Invalid;
}
示例10: Target
public void Target( Item item )
{
Type t = item.GetType();
if ( !Caster.CanSee( item ) )
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
else if ( !t.IsDefined( typeof( DispellableFieldAttribute ), false ) )
Caster.SendLocalizedMessage( 1005049 ); // That cannot be dispelled.
else if ( item is Moongate && !((Moongate)item).Dispellable )
Caster.SendLocalizedMessage( 1005047 ); // That magic is too chaotic
else if ( CheckSequence() )
{
SpellHelper.Turn( Caster, item );
if ( item is ILinkDispel )
{
Item second = ((ILinkDispel)item).Link;
Effects.SendLocationParticles( EffectItem.Create( second.Location, second.Map, EffectItem.DefaultDuration ), 0x376A, 9, 20, 5042 );
Effects.PlaySound( second.GetWorldLocation(), second.Map, 0x201 );
second.Delete();
}
Effects.SendLocationParticles( EffectItem.Create( item.Location, item.Map, EffectItem.DefaultDuration ), 0x376A, 9, 20, 5042 );
Effects.PlaySound( item.GetWorldLocation(), item.Map, 0x201 );
item.Delete();
}
FinishSequence();
}
示例11: Target
public void Target( Item item )
{
Type t = item.GetType();
if ( !Caster.CanSee( item ) )
{
Caster.SendLocalizedMessage( 500237 ); // Target can not be seen.
}
else if ( !t.IsDefined( typeof( DispellableFieldAttribute ), false ) )
{
Caster.SendLocalizedMessage( 1005049 ); // That cannot be dispelled.
}
else if ( item is Moongate && !((Moongate)item).Dispellable )
{
Caster.SendLocalizedMessage( 1005047 ); // That magic is too chaotic
}
else if (SphereSpellTarget is BaseWand)
{
BaseWand bw = SphereSpellTarget as BaseWand;
bw.RechargeWand(Caster, this);
}
else if ( CheckSequence() )
{
//Effects.SendLocationParticles( EffectItem.Create( item.Location, item.Map, EffectItem.DefaultDuration ), 0x376A, 9, 20, 5042 );
Effects.PlaySound( item.GetWorldLocation(), item.Map, Sound );
item.Delete();
}
FinishSequence();
}
示例12: Check
public static void Check( Item from, object parent )
{
Mobile m = parent as Mobile;
if ( m == null )
m = ((Item)parent).RootParent as Mobile;
if ( m != null )
{
bool drop = false;
Type type = from.GetType();
for( int i = 0; i < m.Items.Count; i++ )
{
// CS0246: Line 24: The type or namespace name 'type' could not be found (are you missing a using directive or an assembly reference?)
// if ( m.Items[i] != null && m.Items[i] is type )
if ( m.Items[i] != null && m.Items[i].GetType() == type )
drop = true;
}
if ( !drop && m.Backpack != null )
{
Container c = (Container)m.Backpack;
if ( c.FindItemsByType( type ).Length > 1 )
drop = true;
}
if ( drop )
{
new InternalTimer( from ).Start();
}
}
}
示例13: AddComponent
public virtual bool AddComponent( Item item, int index, bool skipupdate )
{
if ( item == null )
{
m_LastMessage = "That's not a valid component.";
return false;
}
Type type = item.GetType();
if (!IsValidComponent( item ))
{
m_LastMessage = "You don't know how to make use of this component.";
return false;
}
if ( GumpComponents[index].Type != null )
RemoveComponent(index, true);
if ( m_Components.ContainsKey( type ) )
m_Components[type]++;
else
m_Components[type] = 1;
GumpComponents[index].Type = type;
GumpComponents[index].Graphic = item.ItemID;
GumpComponents[index].Hue = item.Hue;
if (!skipupdate)
{
m_LastMessage = "You successfully add the component.";
Update();
}
return true;
}
示例14: TryAdd
public bool TryAdd( Item item )
{
foreach( Type[] cat in m_AllTypes )
{
foreach( Type type in cat )
{
if( item.GetType() == type )
{
if( m_Resources.ContainsKey( type ) && (int)m_Resources[type] + item.Amount >= 100000 )
{
this.PublicOverheadMessage( MessageType.Whisper, 0, false, "I cannot hold more of that resource!" );
return false;
}
if ( type == typeof (SackFlour) )
{
SackFlour sack = (SackFlour)item;
if ( sack.Quantity != 20 )
{
this.PublicOverheadMessage( MessageType.Whisper, 0, false, "The sack has to be full!" );
return false;
}
}
AddResource( type, item.Amount );
this.PublicOverheadMessage( MessageType.Whisper, 0, false, "Resource Added." );
item.Delete();
return true;
}
}
}
this.PublicOverheadMessage( MessageType.Whisper, 0, false, "I don't hold that resource!" );
return false;
}
示例15: TrashProfileEntry
public TrashProfileEntry(DateTime when, Mobile source, Item trashed, int tokens)
{
TrashedTime = when;
if (source != null)
{
SourceSerial = source.Serial;
SourceName = source.RawName;
}
else
{
SourceSerial = Serial.Zero;
SourceName = String.Empty;
}
if (trashed != null)
{
TrashedSerial = trashed.Serial;
TrashedType = trashed.GetType().Name;
TrashedName = trashed.ResolveName();
}
else
{
TrashedSerial = Serial.Zero;
TrashedType = String.Empty;
TrashedName = String.Empty;
}
TokenAmount = tokens;
}