当前位置: 首页>>代码示例>>C#>>正文


C# Item.GetType方法代码示例

本文整理汇总了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;
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:60,代码来源:GenericSell.cs

示例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;
            }
        }
开发者ID:greeduomacro,项目名称:unknown-shard-1,代码行数:35,代码来源:ReagentPouches.cs

示例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();
 }
开发者ID:jienoel,项目名称:MissTaraGame,代码行数:13,代码来源:UserData.cs

示例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;
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:50,代码来源:RunicReforging.cs

示例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);
        }
    }
开发者ID:IzumiMirai,项目名称:CSSeniorProject,代码行数:51,代码来源:Items.cs

示例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 )
                );
        }
开发者ID:breadval,项目名称:azure_uo_script,代码行数:29,代码来源:BasePigmentsOfTokuno.cs

示例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
                );
        }
开发者ID:kamronbatman,项目名称:Defiance-AOS-Pre-2012,代码行数:32,代码来源:BasePigmentsOfTokuno.cs

示例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;
		}
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:32,代码来源:LootBag.cs

示例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;
			}
开发者ID:romeov007,项目名称:imagine-uo,代码行数:60,代码来源:Resmelt.cs

示例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();
		}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:31,代码来源:DispelField.cs

示例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();
		}
开发者ID:FreeReign,项目名称:imaginenation,代码行数:32,代码来源:DispelField.cs

示例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();
				}
			}
		}
开发者ID:greeduomacro,项目名称:cov-shard-svn-1,代码行数:35,代码来源:BaseUniqueItem.cs

示例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;
        }
开发者ID:justdanofficial,项目名称:khaeros,代码行数:34,代码来源:CraftState.cs

示例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;
		}
开发者ID:greeduomacro,项目名称:cov-shard-svn-1,代码行数:33,代码来源:BaseGranery.cs

示例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;
		}
开发者ID:Ravenwolfe,项目名称:Core,代码行数:30,代码来源:TrashProfile.cs


注:本文中的Item.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。