using Thousandto.Cfg.Data; using Thousandto.Code.Center; using Thousandto.Code.Global; using Thousandto.Plugins.Common; using System.Collections.Generic; using UnityEngine; using XLua; namespace Thousandto.Code.Logic { //兽魂装备数据 public class MonsterSoulEquipData: ItemModel { //public string Name { get; set; } //public int CfgID { get; set; } //public ulong DBID { get; set; } //隶属的兽魂,为-1表示在背包 public int MonsterId { get; set; } //物品等级 private int _level; public int Level { get { return _level; } set { if(_level != value) { _level = value; Refresh(); } } } //强化等级 public int StrengthLevel { get { return Level; } } //当前经验 用于强化升级 public int Exp { get; set; } //装备部位(1头盔、2项圈、3铠甲、4利爪、5羽翼) //public int Location { get { // return Config.Part; // } set { } } //是否强化材料 public bool IsMaterial { get; set; } //物品类型 public override int GetItemType() { if (IsMaterial) return ItemType.MonsterSoulMaterial; else return ItemType.MonsterSoulEquip; } //部位 public override int GetPart() { var ret = 0; if (Config != null) ret = Config.Part; return ret; } public override int GetQuality() { int ret = -1; if (Config != null && !IsMaterial) ret = Config.Quality; else ret = ItemInfo.Color; return ret; } public override int GetStarNum() { int ret = -1; if (Config != null) ret = Config.DiamondNumber; return ret; } //战力 private uint _score; public uint Score { get { if(_score == 0) { //_score = FightPowerHelper.GetPropetryPower(GetTotalAttrByLevel()); _score = FightPowerHelper.GetPropetryPower(GetAttrsForFightPower()); //多一颗星就多100战力 //if (Star > 0) // _score += (uint)((Star - 1) * 100); } return _score; } } private DeclareSoulBeastsEquip _config; public DeclareSoulBeastsEquip Config { get { if (_config == null) { if (!IsMaterial) { _config = DeclareSoulBeastsEquip.Get(CfgID); } } return _config; } } private Dictionary _baseAttr; public Dictionary BaseAttr { get { if(_baseAttr == null) { _baseAttr = new Dictionary(); if (!string.IsNullOrEmpty(Config.Attribute1)) { var attrs = Config.Attribute1.Split(';'); for (int i = 0; i < attrs.Length; ++i) { var data = AttribuiteData.Parse(attrs[i]); _baseAttr.Add(data.AttrId, data); } } } return _baseAttr; } } //获取指定等级增加的属性列表 public Dictionary GetAddUpAttrByLevel(int level) { if (level > 0) { int id = GetEquipLevelConfigID(level); var config = DeclareSoulBeastsEquipLevel.Get(id); if (config != null && !string.IsNullOrEmpty(config.Att)) { return AttribuiteData.ParseListToDict(config.Att); } } return null; } //SoulBeastEquipLevel.xls public int GetEquipLevelConfigID(int level) { return Part * 10000 + level; } //获取用于战力计算的属性 public Dictionary GetAttrsForFightPower() { Dictionary ret = new Dictionary(); //基础属性的战力 var itor = BaseAttr.GetEnumerator(); while(itor.MoveNext()) { ret.Add(itor.Current.Key, AttribuiteData.ParseWithThis(itor.Current.Value)); } var strengAtt = GetAddUpAttrByLevel(StrengthLevel); if (strengAtt != null) { var e = strengAtt.GetEnumerator(); while (e.MoveNext()) { if (ret.ContainsKey(e.Current.Key)) { ret[e.Current.Key].AttrValue += e.Current.Value.AttrValue; } else { ret.Add(e.Current.Key, e.Current.Value); } } } return ret; } //当有属性改变时,需要刷新数据 public void Refresh() { _score = 0; _baseAttr = null; } #region//构造函数 public MonsterSoulEquipData(int cfgId, ulong dbid = 0) :base(cfgId,dbid) { Count = 1; if (ItemInfo != null && ItemInfo.Type == (int)ItemType.MonsterSoulMaterial) IsMaterial = true; else IsMaterial = false; } public MonsterSoulEquipData(MSG_backpack.ItemInfo info) :base(info) { Count = 1; } public MonsterSoulEquipData(ItemModel info) :base(info) { Count = 1; } #endregion } }