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


C# GamePlayer.GetItemsInRadius方法代码示例

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


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

示例1: CheckForTools

		/// <summary>
		/// Check if the player is near the needed tools (forge, lathe, etc)
		/// </summary>
		/// <param name="player">the crafting player</param>
		/// <param name="recipe">the recipe being used</param>
		/// <param name="itemToCraft">the item to make</param>
		/// <param name="rawMaterials">a list of raw materials needed to create this item</param>
		/// <returns>true if required tools are found</returns>
		protected override bool CheckForTools(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft, IList<DBCraftedXItem> rawMaterials)
		{
            bool needForge = false;

            foreach (DBCraftedXItem material in rawMaterials)
            {
				ItemTemplate template = GameServer.Database.FindObjectByKey<ItemTemplate>(material.IngredientId_nb);
                if (template != null && template.Model == 519) // metal bar
                {
                    needForge = true;
                    break;
                }
            }

            if (needForge)
            {
                foreach (GameStaticItem item in player.GetItemsInRadius(CRAFT_DISTANCE))
                {
                    if (item.Name == "forge" || item.Model == 478) // Forge
                        return true;
                }

                player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client, "Crafting.CheckTool.NotHaveTools", itemToCraft.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
                player.Out.SendMessage(LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Crafting.CheckTool.FindForge"), eChatType.CT_System, eChatLoc.CL_SystemWindow);

				if (player.Client.Account.PrivLevel > 1)
					return true;

				return false;
            }

            return true;
        }
开发者ID:boscorillium,项目名称:dol,代码行数:41,代码来源:Tailoring.cs

示例2: CheckForTools

		/// <summary>
		/// Check if the player is near the needed tools (forge, lathe, etc)
		/// </summary>
		/// <param name="player">the crafting player</param>
		/// <param name="recipe">the recipe being used</param>
		/// <param name="itemToCraft">the item to make</param>
		/// <param name="rawMaterials">a list of raw materials needed to create this item</param>
		/// <returns>true if required tools are found</returns>
		protected override bool CheckForTools(GamePlayer player, DBCraftedItem recipe, ItemTemplate itemToCraft, IList<DBCraftedXItem> rawMaterials)
		{
			foreach (GameStaticItem item in player.GetItemsInRadius(CRAFT_DISTANCE))
			{
				if (item.Name.ToLower() == "forge" || item.Model == 478) // Forge
					return true;
			}

			player.Out.SendMessage(LanguageMgr.GetTranslation(player.Client.Account.Language, "Crafting.CheckTool.NotHaveTools", itemToCraft.Name), eChatType.CT_System, eChatLoc.CL_SystemWindow);
			player.Out.SendMessage(LanguageMgr.GetTranslation(ServerProperties.Properties.DB_LANGUAGE, "Crafting.CheckTool.FindForge"), eChatType.CT_System, eChatLoc.CL_SystemWindow);

			if (player.Client.Account.PrivLevel > 1)
				return true;

			return false;
		}
开发者ID:mynew4,项目名称:DAoC,代码行数:24,代码来源:MetalWorking.cs

示例3: UpdatePlayerItems

		/// <summary>
		/// Send Game Static Item depending on last refresh time
		/// </summary>
		/// <param name="player"></param>
		/// <param name="nowTicks"></param>
		private static void UpdatePlayerItems(GamePlayer player, long nowTicks)
		{
			// Get All Static Item in Range
			var objs = player.GetItemsInRadius(WorldMgr.OBJ_UPDATE_DISTANCE).Cast<GameStaticItem>().Where(i => i != null && i.IsVisibleTo(player)).ToArray();

			try
			{
				// Clean Cache
				foreach (var objEntry in player.Client.GameObjectUpdateArray)
				{
					var objKey = objEntry.Key;
					GameObject obj = WorldMgr.GetRegion(objKey.Item1).GetObject(objKey.Item2);
					// We have a Static Item in cache that is not in vincinity
					if (obj is GameStaticItem && !objs.Contains((GameStaticItem)obj) && (nowTicks - objEntry.Value) >= GetPlayerItemUpdateInterval)
					{
						long dummy;
						player.Client.GameObjectUpdateArray.TryRemove(objKey, out dummy);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while Cleaning Static Item cache for Player : {0}, Exception : {1}", player.Name, e);
			}
			
			try
			{
				// Now Send remaining objects
				foreach (GameStaticItem lobj in objs)
				{
					GameStaticItem staticObj = lobj;
					// Get last update time
					long lastUpdate;
					if (player.Client.GameObjectUpdateArray.TryGetValue(new Tuple<ushort, ushort>(staticObj.CurrentRegionID, (ushort)staticObj.ObjectID), out lastUpdate))
					{
						// This Static Object Needs Update
						if ((nowTicks - lastUpdate) >= GetPlayerItemUpdateInterval)
						{
							player.Client.Out.SendObjectCreate(staticObj);
						}
					}
					else
					{
						// Not in cache, Object entering in range, sending update will add it to cache
						player.Client.Out.SendObjectCreate(staticObj);
					}
				}
			}
			catch (Exception e)
			{
				if (log.IsErrorEnabled)
					log.ErrorFormat("Error while updating Static Item for Player : {0}, Exception : {1}", player.Name, e);
			}
		}
开发者ID:dudemanvox,项目名称:Dawn-of-Light-Server,代码行数:60,代码来源:WorldUpdateThread.cs


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