1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- using XGame.Database;
- namespace FL.Data.Items
- {
- public class EquipItemBase : IItemBase
- {
- /// <summary>
- /// 装备唯一id
- /// </summary>
- public int Id { get; private set; }
- private EquipmentTable _table;
- private ItemTable _itemTable;
- /// <summary>
- /// 装备表格id
- /// </summary>
- public int TableId => _table.Id;
- public EItemType ItemType => EItemType.Equip;
- /// <summary>
- /// 装备部位
- /// </summary>
- public EEquipType EquipType => _table.Part;
- public EQualityLevel Quality => _table.Quality;
- public string Name => _table.Name;
- public int Level { get; set; }
- /// <summary>
- /// 装备属性转化的战斗力
- /// </summary>
- public long FightingPower { get; set; }
- public string Description { get; set; }
- public string Icon => _itemTable?.Icon;
- /// <summary>
- /// 根据uid从装备背包获取装备信息
- /// </summary>
- /// <param name="id"></param>
- public void InitById(int id)
- {
- var attr = EquipData.Instance.GetBagEquipItem(id);
- XGame.Framework.Assert.IsNotNull(attr, $"装备信息不存在,id:{id}");
- Id = id;
- Level = attr.Level;
- var tableId = attr.TableId;
- _table = EquipmentTableRepo.Get(tableId);
- XGame.Framework.Assert.IsNotNull(_table, $"装备表不存在,id:{tableId}");
- _itemTable = ItemTableRepo.Get(tableId);
- XGame.Framework.Assert.IsNotNull(_itemTable, $"道具表不存在,id:{tableId}");
- }
- /// <summary>
- /// 根据装备部位从身上穿戴的装备获取装备信息
- /// </summary>
- /// <param name="id"></param>
- public void InitByEquipPart(EEquipType equipPart)
- {
- var attr = EquipData.Instance.GetWearEquipData(equipPart);
- XGame.Framework.Assert.IsNotNull(attr, $"装备信息不存在,部位id:{equipPart}");
- Id = 0;
- Level = attr.Level;
- var tableId = attr.TableId;
- _table = EquipmentTableRepo.Get(tableId);
- XGame.Framework.Assert.IsNotNull(_table, $"装备表不存在,id:{tableId}");
- _itemTable = ItemTableRepo.Get(tableId);
- XGame.Framework.Assert.IsNotNull(_itemTable, $"道具表不存在,id:{tableId}");
- }
- }
- }
|