--作者: xc --日期: 2019-04-24 --文件: NatureFashionData.lua --模块: NatureFashionData --描述: 造化化形通用数据 ------------------------------------------------ local BaseAttrData = require "Logic.Nature.NatureBaseAttrData" local FightUtils = require "Logic.Base.FightUtils.FightUtils" local NatureFashionData = { ModelId = 0,--模型ID也是配置表ID Name = nil, --名字 Item = 0, --激活和升级所需模型ID AttrList = nil, --属性存储的NatureBaseAttrData Level = nil, --等级 NeedItemNum = 0,--激活或者升星所需道具数量 Icon = 0, --列表显示的icon IsActive = false, --是否激活 MaxLevel = 0,-- 最大等级 Fight = 0, --战斗力 IsRed = false, --是否有红点 NeedItemList = nil, --道具列表用于升级后设置所需道具 IsServerActive = false, --是否服务器激活 SortNum = 0, --排序序列号 Cfg = nil, --配置表 } NatureFashionData.__index = NatureFashionData function NatureFashionData:New(info) local _M = Utils.DeepCopy(self) _M.Cfg = info _M.ModelId = info.Id if info.Occ then _M.Occ = info.Occ else _M.Occ = nil end _M.Name = info.Name _M.Item = info.ActiveItem _M.Level = 0 _M.NeedItemNum = 0 _M.Icon = info.Icon _M.AttrList = List:New() _M.IsActive = false _M.MaxLevel = 0 _M.Fight = 0 _M.IsRed = false if info.ActiveCondition and info.ActiveCondition == 1 then _M.IsServerActive = true else _M.IsServerActive = false end if info.Order then _M.SortNum = info.Order end local _cs = {';','_'} _M.NeedItemList = Utils.SplitStrByTableS(info.StarItemnum,_cs) _M:UpDateAttrData(info) _M:GetActiveFight() return _M end --设置属性 function NatureFashionData:UpDateAttrData(info) self.Cfg = info self.MaxLevel = #self.NeedItemList local _cs = {';','_'} local _attr = Utils.SplitStrByTableS(info.RentAtt,_cs) self.AttrList:Clear() local _dic = Dictionary:New() for i=1,#_attr do local _ismax = self.Level >= self.MaxLevel local _addattr = _ismax and 0 or _attr[i][3] local _attrvalue = _attr[i][2] local _pir = self.Level if _addattr then local _data = BaseAttrData:New(_attr[i][1],_attrvalue + _pir * _attr[i][3],_addattr) self.AttrList:Add(_data) self:UpDateNeedItem() _dic:Add(tonumber(_attr[i][1]), tonumber(_attr[i][2]) + tonumber(_attr[i][3]) * self.Level) end end self.Fight = FightUtils.GetPropetryPower(_dic) end --更新所需道具 function NatureFashionData:UpDateNeedItem() if self.IsActive then for i=1,#self.NeedItemList do if self.NeedItemList[i][1] == self.Level then self.NeedItemNum = self.NeedItemList[i][2] break end end else self.NeedItemNum = self.NeedItemList[1][2] end end function NatureFashionData:GetRed() self.IsRed = false local _ismax = self.Level >= self.MaxLevel self:UpDateNeedItem() if GameCenter.ItemContianerSystem:GetItemCountFromCfgId(self.Item) >= self.NeedItemNum and not _ismax and ((self.IsActive and self.IsServerActive) or not self.IsServerActive) then self.IsRed = true end return self.IsRed end function NatureFashionData:GetActiveFight() if self.Cfg then local _cs = {';','_'} local _attr = Utils.SplitStrByTableS(self.Cfg.RentAtt,_cs) local _dic = Dictionary:New() for i=1,#_attr do _dic:Add(tonumber(_attr[i][1]), tonumber(_attr[i][2])) end self.Fight = FightUtils.GetPropetryPower(_dic) end end function NatureFashionData:SetFight() if self.Cfg then local _cs = {';','_'} local _attr = Utils.SplitStrByTableS(self.Cfg.RentAtt,_cs) local _dic = Dictionary:New() for i=1,#_attr do _dic:Add(tonumber(_attr[i][1]), tonumber(_attr[i][2]) + tonumber(_attr[i][3]) * self.Level) end self.Fight = FightUtils.GetPropetryPower(_dic) end end return NatureFashionData