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


C# Container.FindItemsByType方法代码示例

本文整理汇总了C#中Server.Items.Container.FindItemsByType方法的典型用法代码示例。如果您正苦于以下问题:C# Container.FindItemsByType方法的具体用法?C# Container.FindItemsByType怎么用?C# Container.FindItemsByType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Server.Items.Container的用法示例。


在下文中一共展示了Container.FindItemsByType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ContainsKey

		public static bool ContainsKey( Container cont, uint keyValue )
		{
			if ( cont == null )
				return false;

			Item[] items = cont.FindItemsByType( new Type[] { typeof( Key ), typeof( KeyRing ) } );

			foreach ( Item item in items )
			{
				if ( item is Key )
				{
					Key key = (Key) item;

					if ( key.KeyValue == keyValue )
						return true;
				}
				else
				{
					KeyRing keyRing = (KeyRing) item;

					if ( keyRing.ContainsKey( keyValue ) )
						return true;
				}
			}

			return false;
		}
开发者ID:romeov007,项目名称:imagine-uo,代码行数:27,代码来源:Key.cs

示例2: ContainsDeed

		private bool ContainsDeed( Container cont )
		{
			List<HouseRaffleDeed> deeds = cont.FindItemsByType<HouseRaffleDeed>();

			for ( int i = 0; i < deeds.Count; ++i )
			{
				if ( deeds[i] == m_Stone.Deed )
					return true;
			}

			return false;
		}
开发者ID:nathanvy,项目名称:runuo,代码行数:12,代码来源:HouseRaffleRegion.cs

示例3: RemoveKeys

		public static void RemoveKeys( Container cont, uint keyValue )
		{
			if ( cont == null || keyValue == 0 )
				return;

			Item[] items = cont.FindItemsByType( new Type[] { typeof( Key ), typeof( KeyRing ) } );

			foreach ( Item item in items )
			{
				if ( item is Key )
				{
					Key key = (Key) item;

					if ( key.KeyValue == keyValue )
						key.Delete();
				}
				else
				{
					KeyRing keyRing = (KeyRing) item;

					keyRing.RemoveKeys( keyValue );
				}
			}
		}
开发者ID:romeov007,项目名称:imagine-uo,代码行数:24,代码来源:Key.cs

示例4: GETAMOUNTINCONTAINER

			public static int GETAMOUNTINCONTAINER(TriggerObject trigObject, Container container, object typeObjectOrString)
			{
				if (container == null || container.Deleted)
				{
					return 0;
				}

				Type type = TYPE(trigObject, typeObjectOrString);

				if (type == null)
				{
					throw new UberScriptException(
						"GETAMOUNTINCONTAINER typeString " + typeObjectOrString + " did not match any available types!");
				}

				return container.FindItemsByType(type).Sum(t => t.Amount);
			}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:17,代码来源:UberScriptFunctions.cs

示例5: GetHouseDeedsInContainer

        private static int GetHouseDeedsInContainer(Container c, ref int count)
        {
            int iGold = 0;

            Item[] deeds = c.FindItemsByType(typeof(Server.Multis.Deeds.HouseDeed), true);
            foreach (Item i in deeds)
            {
                Server.Multis.Deeds.HouseDeed housedeed = i as Server.Multis.Deeds.HouseDeed;
				// don't count tents as they cannot be redeemed for cash
				if (housedeed != null && housedeed is SiegeTentBag == false && housedeed is TentBag == false)
                {
                    count++;
                    iGold += RealEstateBroker.ComputePriceFor(housedeed);
                }
            }

            Item[] BUCdeeds = c.FindItemsByType(typeof(BaseUpgradeContract), true);
            foreach (Item i in BUCdeeds)
            {
                BaseUpgradeContract budeed = i as BaseUpgradeContract;
                if (budeed != null)
                {
                    count++;
                    iGold += (int)budeed.Price;
                }
            }

            
            return iGold;
        }
开发者ID:zerodowned,项目名称:angelisland,代码行数:30,代码来源:GoldTracker.cs

示例6: GetQuantity

		public int GetQuantity( Container cont, Type[] types )
		{
			Item[] items = cont.FindItemsByType( types, true );

			int amount = 0;

			for ( int i = 0; i < items.Length; ++i )
			{
				IHasQuantity hq = items[i] as IHasQuantity;

				if ( hq == null )
				{
					amount += items[i].Amount;
				}
				else
				{
					if ( hq is BaseBeverage && ((BaseBeverage)hq).Content != BeverageType.Water )
						continue;

					amount += hq.Quantity;
				}
			}

			return amount;
		}
开发者ID:Leodinas,项目名称:uolite,代码行数:25,代码来源:CraftItem.cs

示例7: GetReeds

 public static List<SoftenedReeds> GetReeds( Container cont, PlantHue hue )
 {
     return GetReeds( cont.FindItemsByType<SoftenedReeds>(), hue );
 }
开发者ID:Ravenwolfe,项目名称:xrunuo,代码行数:4,代码来源:SoftenedReeds.cs

示例8: Consume

        /// <summary>
        /// Tries to consume the given amount out of the total amount of currency in the provided container.
        /// Automatically redistributes coins.
        /// </summary>
        /// <param name="cont">the container to consume from</param>
        /// <param name="currencyType">the target currency to consume from</param>
        /// <param name="amount">the amount of the target currency to consume</param>
        /// <returns>true if the container has the exact amount of the currencyType, or if the container has enough total monies</returns>
        public static bool Consume( Container cont, Type currencyType, int amount )
        {
            if( cont == null )
                return false;

            if( cont.ConsumeTotal(currencyType, amount) )
                return true;

            int availableCopper = 0;
            Item[] coins = cont.FindItemsByType(AllCurrencies);

            //calculate monies as copper total
            for( int i = 0; i < coins.Length; i++ )
                availableCopper += ConvertTo(FindType(coins[i].GetType()), CurrencyType.Copper, coins[i].Amount);

            //if we have enough to pay...
            if( availableCopper >= amount )
            {
                //delete all the coins
                for( int i = 0; i < coins.Length; i++ )
                    coins[i].Consume(coins[i].Amount);

                availableCopper -= amount;

                //if we should still have money, redistribute
                if( availableCopper > 0 )
                    DistributeCoins(cont, Compress(availableCopper, 0, 0));

                return true;
            }

            return false;
        }
开发者ID:ITLongwell,项目名称:Ulmeta,代码行数:41,代码来源:Currency.cs

示例9: OnDeath

        public override bool OnDeath( Mobile mob, Container corpse )
        {
            Mobile killer = mob.FindMostRecentDamager( false );

            bool hadFlag = false;

            Item[] flags = corpse.FindItemsByType( typeof( CTFFlag ), false );

            for ( int i = 0; i < flags.Length; ++i )
                ( flags[i] as CTFFlag ).DropTo( mob, killer );

            hadFlag = ( hadFlag || flags.Length > 0 );

            if ( mob.Backpack != null )
            {
                flags = mob.Backpack.FindItemsByType( typeof( CTFFlag ), false );

                for ( int i = 0; i < flags.Length; ++i )
                    ( flags[i] as CTFFlag ).DropTo( mob, killer );

                hadFlag = ( hadFlag || flags.Length > 0 );
            }

            if ( killer != null && killer.Player )
            {
                CTFTeamInfo teamInfo = GetTeamInfo( killer );
                CTFTeamInfo victInfo = GetTeamInfo( mob );

                if ( teamInfo != null && teamInfo != victInfo )
                {
                    CTFPlayerInfo playerInfo = teamInfo[killer];

                    if ( playerInfo != null )
                    {
                        playerInfo.Kills += 1;
                        playerInfo.Score += 1; // base frag

                        if ( hadFlag )
                            playerInfo.Score += 4; // fragged flag carrier

                        if ( mob.InRange( teamInfo.Origin, 24 ) && mob.Map == this.Facet )
                            playerInfo.Score += 1; // fragged in base -- guarding

                        for ( int i = 0; i < m_Controller.TeamInfo.Length; ++i )
                        {
                            if ( m_Controller.TeamInfo[i] == teamInfo )
                                continue;

                            Mobile ourFlagCarrier = null;

                            if ( m_Controller.TeamInfo[i].Flag != null )
                                ourFlagCarrier = m_Controller.TeamInfo[i].Flag.RootParent as Mobile;

                            if ( ourFlagCarrier != null && GetTeamInfo( ourFlagCarrier ) == teamInfo )
                            {
                                for ( int j = 0; j < ourFlagCarrier.Aggressors.Count; ++j )
                                {
                                    AggressorInfo aggr = ourFlagCarrier.Aggressors[j];

                                    if ( aggr == null || aggr.Defender != ourFlagCarrier || aggr.Attacker != mob )
                                        continue;

                                    playerInfo.Score += 2; // helped defend guy capturing enemy flag
                                    break;
                                }

                                if ( mob.Map == ourFlagCarrier.Map && ourFlagCarrier.InRange( mob, 12 ) )
                                    playerInfo.Score += 1; // helped defend guy capturing enemy flag
                            }
                        }
                    }
                }
            }

            mob.CloseGump( typeof( CTFBoardGump ) );
            mob.SendGump( new CTFBoardGump( mob, this ) );

            m_Context.Requip( mob, corpse );
            DelayBounce( TimeSpan.FromSeconds( 30.0 ), mob, corpse );

            return false;
        }
开发者ID:greeduomacro,项目名称:divinity,代码行数:82,代码来源:CTF.cs

示例10: GetCommodityType

        public int GetCommodityType(Container c, Type type)
        {
            if (c == null)
                return 0;

            Item[] items = c.FindItemsByType(typeof(CommodityDeed));
            int amt = 0;

            foreach (Item item in items)
            {
                if (item is CommodityDeed && ((CommodityDeed)item).Commodity != null && ((CommodityDeed)item).Commodity.GetType() == type)
                    amt += ((CommodityDeed)item).Commodity.Amount;
            }

            return amt;
        }
开发者ID:Crome696,项目名称:ServUO,代码行数:16,代码来源:CommodityBroker.cs

示例11: TakeItems

		private void TakeItems(Container c, Type type, ref int amount)
		{
            if (c == null)
                return;

			Item[] items = c.FindItemsByType(type);
			List<Item> toSell = new List<Item>();
			
			foreach(Item item in items)
			{
				if(amount <= 0)
					break;
					
				if(item.Amount <= amount)
				{
					toSell.Add(item);
					amount -= item.Amount;
				}
				else
				{
					Item newItem = Loot.Construct(type);
					newItem.Amount = amount;
					item.Amount -= amount;
					toSell.Add(newItem);
					amount = 0;
				}
			}
			
			foreach(Item item in toSell)
			{
				AddInventory(null, item);
			}
		}
开发者ID:Crome696,项目名称:ServUO,代码行数:33,代码来源:CommodityBroker.cs

示例12: TakeCommodities

		private void TakeCommodities(Container c, Type type, ref int amount)
		{
            if (c == null)
                return;

			Item[] items = c.FindItemsByType(typeof(CommodityDeed));
			List<Item> toSell = new List<Item>();
			
			foreach(Item item in items)
			{
                CommodityDeed commodityDeed = item as CommodityDeed;

                if (commodityDeed != null && commodityDeed.Commodity != null && commodityDeed.Commodity.GetType() == type)
				{
					Item commodity = commodityDeed.Commodity;

                    if (commodity.Amount <= amount)
					{
						toSell.Add(item);
                        amount -= commodity.Amount;
					}
					else
					{
						CommodityDeed newDeed = new CommodityDeed();
						Item newItem = Loot.Construct(type);
						newItem.Amount = amount;
						newDeed.SetCommodity(newItem);
						
						commodity.Amount -= amount;
						commodityDeed.InvalidateProperties();
						toSell.Add(newDeed);
						amount = 0;
					}
				}
			}
			
			foreach(Item item in toSell)
			{
				AddInventory(null, item);
			}
		}
开发者ID:Crome696,项目名称:ServUO,代码行数:41,代码来源:CommodityBroker.cs

示例13: TransferGold

        public static void TransferGold(Mobile m, Container c, GoldLedger ledger, string nametitle)
        {
            Item[] items = c.FindItemsByType(typeof(Gold));

            foreach (Gold ngold in items)
            {
                Gold gold = ngold as Gold;

                if (gold != null)
                {
                    if (ledger.Gold < 999999999)
                    {
                        double maxWeight = (WeightOverloading.GetMaxWeight(m));
                        if ((Mobile.BodyWeight + m.TotalWeight) < (maxWeight))
                        {
                            int golda = gold.Amount;
                            if ((gold.Amount + ledger.Gold) > 999999999)
                                golda = (999999999 - ledger.Gold);
                            double maxgold = golda;
                            if (ledger.d_WeightScale > 0)
                                maxgold = ((maxWeight - ((double)Mobile.BodyWeight + (double)m.TotalWeight)) / ledger.d_WeightScale);
                            if (golda > maxgold)
                                golda = (int)maxgold;
                            int GoldID = 0;
                            if (golda == 1)
                                GoldID = gold.ItemID;
                            else if (golda > 1 && golda < 6)
                                GoldID = gold.ItemID + 1;
                            else if (golda >= 6)
                                GoldID = gold.ItemID + 2;
                            if (golda < gold.Amount)
                                gold.Amount -= golda;
                            else
                                gold.Delete();
                            ledger.Gold += golda;
                            if (ledger.b_open && golda > 0)
                            {
                                m.CloseGump(typeof(GoldLedgerGump));
                                m.SendGump(new GoldLedgerGump(ledger));
                            }

                            if (golda > 0)
                            {
                                m.SendMessage(2125, "You loot {0} gold from {1} and deposit it into your gold ledger.", golda.ToString("#,0"), nametitle);
                                Effects.SendMovingEffect(c, m, GoldID, 5, 50, true, false);
                                m.PlaySound(0x2E6);
                            }
                        }
                    }
                }
            }
        }
开发者ID:Tukaramdas,项目名称:ServUO-EC-Test-Fork,代码行数:52,代码来源:GoldLedger.cs

示例14: GetGoldInContainer

		private static int GetGoldInContainer(Container c)
		{
			int iGold = 0;

			Item[] golds = c.FindItemsByType(typeof(Gold), true);
			foreach(Item g in golds)
			{
				iGold += g.Amount;
			}
			Item[] checks = c.FindItemsByType(typeof(BankCheck), true);
			foreach(Item i in checks)
			{
				BankCheck bc = (BankCheck)i;
				iGold += bc.Worth;
			}	
	
			return iGold;
		}
开发者ID:zerodowned,项目名称:angelisland,代码行数:18,代码来源:GoldTracker.cs

示例15: DELETEFROMCONTAINER

			public static void DELETEFROMCONTAINER(
				TriggerObject trigObject, Container container, object typeObjectOrString, int amount)
			{
				Type type = TYPE(trigObject, typeObjectOrString);

				if (type == null)
				{
					throw new UberScriptException(
						"DELETEFROMCONTAINER typeObjectOrString " + typeObjectOrString + " did not match any available types!");
				}

				var list = container.FindItemsByType(type);

				for (int i = 0; amount > 0 && i < list.Length; i++)
				{
					int consume = Math.Min(list[i].Amount, amount);

					list[i].Consume(consume);
					amount -= consume;
				}
			}
开发者ID:greeduomacro,项目名称:UO-Forever,代码行数:21,代码来源:UberScriptFunctions.cs


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