Server.LootPackItem.Construct C# (CSharp) Méthode

Construct() public méthode

public Construct ( ) : Item
Résultat Item
		public Item Construct()
		{
			try
			{
				Item item;

				if ( m_Type == typeof( BaseRanged ) )
					item = Loot.RandomRangedWeapon();
				else if ( m_Type == typeof( BaseWeapon ) )
					item = Loot.RandomWeapon();
				else if ( m_Type == typeof( BaseArmor ) )
					item = Loot.RandomArmorOrHat();
				else if ( m_Type == typeof( BaseShield ) )
					item = Loot.RandomShield();
				else if ( m_Type == typeof( BaseJewel ) )
					item = Loot.RandomArmorOrShieldOrWeapon();
				else if ( m_Type == typeof( BaseInstrument ) )
					item = Loot.RandomInstrument();
				else if ( m_Type == typeof( Amber ) ) // gem
					item = Loot.RandomGem();
				else if ( m_Type == typeof( ClumsyScroll ) ) // low scroll
					item = RandomScroll( 0, 1, 3 );
				else if ( m_Type == typeof( ArchCureScroll ) ) // med scroll
					item = RandomScroll( 1, 4, 7 );
				else if ( m_Type == typeof( SummonAirElementalScroll ) ) // high scroll
					item = RandomScroll( 2, 8, 8 );
				else
					item = Activator.CreateInstance( m_Type ) as Item;

				return item;
			}
			catch
			{
			}

			return null;
		}

Usage Example

Exemple #1
0
        public Item Construct(Mobile from, bool spawning)
        {
            if (m_AtSpawnTime != spawning)
            {
                return(null);
            }

            int totalChance = 0;

            for (int i = 0; i < m_Items.Length; ++i)
            {
                totalChance += m_Items[i].Chance;
            }

            int rnd = Utility.Random(totalChance);

            for (int i = 0; i < m_Items.Length; ++i)
            {
                LootPackItem item = m_Items[i];

                if (rnd < item.Chance)
                {
                    return(Mutate(from, item.Construct(false, false)));
                }

                rnd -= item.Chance;
            }

            return(null);
        }
All Usage Examples Of Server.LootPackItem::Construct