本文整理汇总了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;
}
示例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;
}
示例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);
}
}