zxl
/
CTT
forked from Cal/CTT
1
0
Fork 0
CTT/Unity/Assets/Hotfix/Logic/Behaviour/Game/Helper/BagHelper.cs

63 lines
1.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 ET;
using FairyGUI;
using Cal.DataTable;
using System.Collections.Generic;
namespace ET
{
public class BagHelper
{
/// <summary>
/// 获取背包物品的名字和图标名 (名,图标资源名)
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static (string, string) GetIconName(int id)
{
if (id == 0) return (null,null);
if (id < 110000)
{
var materialBase = DataTableHelper.Get<MaterialBase>(id);
return (materialBase.Name, materialBase.IconName);
}
if (id < 120000)
{
var goodsBase = DataTableHelper.Get<GoodsBase>(id);
return (goodsBase.Name, goodsBase.IconName);
}
else
{
var equipBase = DataTableHelper.Get<EquipBase>(id);
return (equipBase.Name, equipBase.IconName);
}
}
/// <summary>
/// 根据Id获取物品类型自行判断类型
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public static IConfig GetItemBase(int id)
{
if (id == 0) return null;
if (id < 110000)
{
return DataTableHelper.Get<MaterialBase>(id) as IConfig;
}
if (id < 120000)
{
return DataTableHelper.Get<GoodsBase>(id) as IConfig;
}
else
{
return DataTableHelper.Get<EquipBase>(id) as IConfig;
}
}
}
}