------------------------------------------------ --作者: 王圣 --日期: 2020-08-22 --文件: FashionTuJianData.lua --模块: FashionTuJianData --描述: 时装图鉴数据 ------------------------------------------------ local FashionTuJianData = { StarNum = 0, IsActive = false, CfgId = 0, Cfg = nil, IconId = -1, Name = nil, --收集的时装数据 --{FashionId : 时装ID, SortId : 排序Id, IsActive : 是否激活, StarNum : 升星数} ListNeedData = List:New(), --套装属性 --{AttId : 属性ID, Value : 属性值 Num : 激活数量} ListRentAtt = List:New(), --属性列表 --{AttId : 属性ID, Value : 属性值 Add : 增加值} ListAttr = List:New(), } function FashionTuJianData:New(id, cfg) local _m = Utils.DeepCopy(self) _m.Cfg = cfg _m.CfgId = cfg.Id return _m end function FashionTuJianData:SetData(msg) end --设置图鉴激活需要的时装数据列表 function FashionTuJianData:UpdateNeedDataList() local needList = self:GetNeedDataList() if needList == nil then return end for i = 1, #needList do local need = needList[i] if need ~= nil then local fashionData = GameCenter.NewFashionSystem:GetFashionData(need.FashionId) if fashionData ~= nil then need.IsActive = fashionData.IsActive end end end end function FashionTuJianData:SetNeedData(fashionData) if fashionData == nil then return end local needList = self:GetNeedDataList() if needList == nil then return end for i = 1, #needList do local need = needList[i] if need ~= nil then if need.FashionId == fashionData:GetCfgId() then need.IsActive = fashionData.IsActive break end end end end --获取图鉴激活需要的时装数据列表 function FashionTuJianData:GetNeedDataList() if #self.ListNeedData == 0 then if self.Cfg ~= nil then local list = Utils.SplitStr(self.Cfg.NeedFashionId, ';') for i = 1,#list do local subList = Utils.SplitNumber(list[i], '_') if #subList ~= 2 then Debug.LogError("fashion_link cfg needFashionId param is error!") else local data = {SortId = subList[1], FashionId = subList[2], IsActive = false} self.ListNeedData:Add(data) end end end end return self.ListNeedData end --获取图鉴ID function FashionTuJianData:GetCfgId() return self.CfgId end --获取图鉴名字 function FashionTuJianData:GetName() if self.Name == nil then self.Name = self.Cfg.Name end return self.Name end --获取图鉴图标 function FashionTuJianData:GetIconId(occ) if self.IconId == -1 then if self.Cfg ~= nil then local list = Utils.SplitStr(self.Cfg.Icon, ';') for i = 1,#list do local subList = Utils.SplitNumber(list[i], '_') if #subList ~= 2 then Debug.LogError("fashion_link cfg icon param is error!") else if occ == subList[1] then self.IconId = subList[2] end end end end end return self.IconId end --获取套装属性列表 function FashionTuJianData:GetRentAttList() if #self.ListRentAtt == 0 then if self.Cfg ~= nil then local list = Utils.SplitStr(self.Cfg.RentAtt, ';') for i = 1,#list do local subList = Utils.SplitNumber(list[i], '_') if #subList ~= 3 then Debug.LogError("fashion_link cfg rentAtt param is error!") else local data = {AttId = subList[2], Value = subList[3], Num = subList[1]} self.ListRentAtt:Add(data) end end end end return self.ListRentAtt end function FashionTuJianData:GetQuality() local ret = 0 if self.Cfg ~= nil then ret = self.Cfg.Quality end return ret end --获取图鉴属性列表 function FashionTuJianData:GetAttList() if #self.ListAttr == 0 then --设置基础属性 if self.Cfg ~= nil then local list = Utils.SplitStr(self.Cfg.ActivationAtt, ';') for i = 1,#list do local subList = Utils.SplitNumber(list[i], '_') if #subList ~= 2 then Debug.LogError("fashion_link cfg activationAtt param is error!") else local data = {AttId = subList[1], Value = subList[2], Add = 0} self.ListAttr:Add(data) end end --设置属性增加值 list = Utils.SplitStr(self.Cfg.StarAtt, ';') for i = 1,#list do local subList = Utils.SplitNumber(list[i], '_') if #subList ~= 2 then Debug.LogError("fashion_link cfg starAtt param is error!") else local id = subList[1] local value = subList[2] for m = 1, #self.ListAttr do local data = self.ListAttr[m] if data.AttId == id then data.Add = value end end end end end end return self.ListAttr end return FashionTuJianData