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

82 lines
2.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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;
}
}
}