82 lines
2.6 KiB
C#
82 lines
2.6 KiB
C#
using cfg.ActorCfg;
|
||
using cfg.CharacterCfg;
|
||
using Framework;
|
||
using Gameplay.Common;
|
||
using Gameplay.Net;
|
||
using NLDPB;
|
||
using System.Collections.Generic;
|
||
|
||
namespace Gameplay
|
||
{
|
||
public partial class CommonUtils
|
||
{
|
||
public static uint GetItemCount(int id)
|
||
{
|
||
return Actor.Instance.Item.GetItemCount(id);
|
||
}
|
||
|
||
public static string GetItemName(int id)
|
||
{
|
||
return GetLocalizeText(TableManager.Instance.Tables.Item.Get(id).NameLocal);
|
||
}
|
||
public static string GetItemPath(int id)
|
||
{
|
||
return TableManager.Instance.Tables.Item.Get(id).IconPath;
|
||
}
|
||
|
||
public static readonly List<ItemSource> ItemSourceNotShowInItemWindow = new List<ItemSource>
|
||
{ ItemSource.LevelPassNormal, ItemSource.LevelPassFirst, ItemSource.LevelPassStar1,
|
||
ItemSource.LevelPassStar2, ItemSource.LevelPassStar2, ItemSource.LevelPassStar3,
|
||
ItemSource.ChapterStar,ItemSource.MailItem,ItemSource.Raffle,
|
||
};
|
||
|
||
public static int GetItemCharacterCfgId(int id)
|
||
{
|
||
DataItem item = TableManager.Instance.Tables.Item.Get(id);
|
||
if(item==null)
|
||
{
|
||
DebugUtil.Log("item表格id为{0}的物品不存在",id);
|
||
return 0;
|
||
}
|
||
if(item.Type!=ItemType.Character)
|
||
{
|
||
DebugUtil.Log("item表格id为{0}的物品不是角色物品", id);
|
||
return 0;
|
||
}
|
||
DataCharacterAttri dataCharacterAttri=TableManager.Instance.Tables.CharacterAttri.Get(item.Param1);
|
||
if(dataCharacterAttri==null)
|
||
{
|
||
DebugUtil.Log("item表格id为{0}的物品角色id没有配");
|
||
return 0;
|
||
}
|
||
return item.Param1;
|
||
|
||
}
|
||
public static ItemType GetItemType(int id)
|
||
{
|
||
DataItem item = TableManager.Instance.Tables.Item.Get(id);
|
||
return item.Type;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 道具是否溢出
|
||
/// </summary>
|
||
/// <param name="id"></param>
|
||
/// <param name="count"></param>
|
||
/// <returns></returns>
|
||
public static bool IsItemOverflow(int id, int count)
|
||
{
|
||
DataItem item = TableManager.Instance.Tables.Item.Get(id);
|
||
if (item == null)
|
||
{
|
||
DebugUtil.LogError($"获取道具配置失败,道具id:{id}");
|
||
return true;
|
||
}
|
||
|
||
if (item.MaxCount == 0)
|
||
return count > TableManager.Instance.Tables.GlobalConfig.ItemMaxDefault;
|
||
|
||
return count > item.MaxCount;
|
||
}
|
||
}
|
||
} |