local CollectionData = class("CollectionData", BaseData) function CollectionData:ctor() self.data.dirtyHero = false end function CollectionData:clear() end function CollectionData:init(data) data = data or GConst.EMPTY_TABLE self:initCollectHero(data.hero) end -- 初始化英雄图鉴数据 function CollectionData:initCollectHero(data) if data == nil then return end if EDITOR_MODE then Logger.logHighlight("更新英雄图鉴数据") Logger.printTable(data) end self:initAllDataClass() self.datas[GConst.CollectionConst.TYPE.HERO] = data self.dataCollects[GConst.CollectionConst.TYPE.HERO]:init(data) self:setDirty(GConst.CollectionConst.TYPE.HERO) end -- 初始化所有图鉴数据类 function CollectionData:initAllDataClass() if self.dataCollects == nil then self.dataCollects = {} self.dataCollects[GConst.CollectionConst.TYPE.HERO] = require "app/userdata/collection/collection_hero_entity":create() end if self.datas == nil then self.datas = {} end end function CollectionData:setDirty(type) if type == GConst.CollectionConst.TYPE.HERO then self.data.dirtyHero = not self.data.dirtyHero end end function CollectionData:isOpen(type) if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.COLLECT, true) then return false end if type and (not self.datas or not self.datas[type]) then return false end return true end function CollectionData:getCollectEntity(type) return self.dataCollects[type] end -- 是否有红点 function CollectionData:hasRedPoint(type) return self.dataCollects[type]:hasRedPoint() end -- 获取当前收集值 function CollectionData:getCurCollectPoint(type) return self.dataCollects[type]:getCurCollectPoint() end -- 获取当前已领取奖励图鉴等级 function CollectionData:getCurCollectLevel(type) return self.dataCollects[type]:getCurCollectLevel() end -- 获取总收集值 function CollectionData:getTotalCollectPoint(type) return self.dataCollects[type]:getTotalCollectPoint() end -- 获取收集目标列表 function CollectionData:getCollectList(type) return self.dataCollects[type]:getCollectList() end -- 获取收集奖励列表 function CollectionData:getRewardList(type) return self.dataCollects[type]:getRewardList() end -- 获取当前所在档位id function CollectionData:getCurTargetId(type) return self.dataCollects[type]:getCurTargetId() end -- 获取奖励档位收集进度 function CollectionData:getRewardTargetProgress(type, id) return self.dataCollects[type]:getRewardTargetProgress(id) end -- 获取当前可领奖or正在进行中的目标 function CollectionData:getCanGetOrCollectingTargetId(type) return self.dataCollects[type]:getCanGetOrCollectingTargetId() end -- 获取收集目标点数 function CollectionData:getTargetPoint(type, id) return self.dataCollects[type]:getTargetPoint(id) end -- 获取基于目标收集点数的当前收集值 function CollectionData:getTargetOwnedPoint(type, id) return self.dataCollects[type]:getTargetOwnedPoint(id) end -- 获取可领取收集值 function CollectionData:getCanCollectPoint(type, id) return self.dataCollects[type]:getCanCollectPoint(id) end -- 奖励是否已领取 function CollectionData:isRewardReceived(type, id) return self.dataCollects[type]:isRewardReceived(id) end -- 是否满足奖励领取条件 function CollectionData:isMeetTargetPoint(type, id) return self.dataCollects[type]:isMeetTargetPoint(id) end -- 事件 ----------------------------------------------------------------------------------------------- -- 领取收集点数成功 function CollectionData:onGetedPointSuccess(type, heroId, point) self.dataCollects[type]:onGetedPointSuccess(heroId, point) self:setDirty(type) end -- 领取图鉴奖励成功 function CollectionData:onGetedPointRewardSuccess(type) self.dataCollects[type]:onGetedPointRewardSuccess() self:setDirty(type) end return CollectionData