12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- using FL.Data.Items;
- using XGame.Database;
- using XGame.Framework.Data;
- namespace FL.Data
- {
- public class ItemService : DataSingleton<ItemService>
- {
- public bool IsEnough(int id, long needNum, bool showTips)
- {
- var num = ItemData.Instance.GetItemNum(id);
- if (needNum > num)
- {
- if (showTips)
- {
- var table = ItemTableRepo.Get(id);
- if (table != null)
- EventSingle.Instance.Notify(
- EventDefine.ShowTips,
- string.Format(StringDefine.itemNotEnough, table.Name)
- );
- }
- return false;
- }
- else
- {
- return true;
- }
- }
- /// <summary>
- /// 给界面上Itembase展示用,KindItem道具类型kind:技术定义类型 0默认道具表id 1装备临时库序号ID
- /// </summary>
- /// <param name="id"></param>
- /// <param name="count"></param>
- /// <param name="kind"></param>
- /// <returns></returns>
- public IItemBase GetItemBase(int id, long count, int kind, bool isGet = false)
- {
- if (kind == 1)
- {
- var equipItem = new EquipItemBase();
- equipItem.InitById(id);
- return equipItem;
- }
- else
- {
- var table = ItemTableRepo.Get(id);
- if (table.Type == (int)EItemType.Partner)
- {
- var item = new PartnerItemBase();
- item.Init(id);
- return item;
- }
- else
- {
- var item = new ItemBase();
- item.Init(id, count, isGet);
- return item;
- }
- }
- }
- }
- }
|