63 lines
1.6 KiB
C#
63 lines
1.6 KiB
C#
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;
|
||
}
|
||
}
|
||
}
|
||
}
|