NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Utils/CommonUtils.Item.cs

82 lines
2.6 KiB
C#
Raw Normal View History

2024-01-18 13:57:01 +08:00
using cfg.ActorCfg;
2024-01-19 13:24:37 +08:00
using cfg.CharacterCfg;
2024-01-18 13:57:01 +08:00
using Framework;
2024-01-08 13:13:35 +08:00
using Gameplay.Common;
2024-01-04 19:14:18 +08:00
using Gameplay.Net;
using NLDPB;
using System.Collections.Generic;
2024-01-04 19:14:18 +08:00
namespace Gameplay
{
public partial class CommonUtils
{
public static uint GetItemCount(int id)
{
return Actor.Instance.Item.GetItemCount(id);
}
2024-01-19 13:24:37 +08:00
2024-01-08 13:13:35 +08:00
public static string GetItemName(int id)
{
return GetLocalizeText(TableManager.Instance.Tables.Item.Get(id).NameLocal);
2024-01-08 13:13:35 +08:00
}
2024-01-15 14:16:30 +08:00
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,
};
2024-01-18 13:57:01 +08:00
public static int GetItemCharacterCfgId(int id)
{
DataItem item = TableManager.Instance.Tables.Item.Get(id);
if(item==null)
{
2024-01-19 13:24:37 +08:00
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没有配");
2024-01-18 13:57:01 +08:00
return 0;
}
return item.Param1;
}
2024-01-19 13:24:37 +08:00
public static ItemType GetItemType(int id)
{
DataItem item = TableManager.Instance.Tables.Item.Get(id);
return item.Type;
}
2024-04-25 16:21:20 +08:00
/// <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;
}
2024-01-04 19:14:18 +08:00
}
}