local BountyCell = class("BountyCell", BaseCell) local BOUNTY_REWARD_CELL = "app/ui/bounty/cell/bounty_reward_cell" function BountyCell:init() local uiMap = self:getUIMap() self.uiMap = uiMap uiMap["cell.bg.bounty_reward_cell_1"]:setAnchoredPositionX(-GConst.UI_SCREEN_WIDTH/4) self.bountyRewardCell1 = uiMap["cell.bg.bounty_reward_cell_1"]:addLuaComponent(BOUNTY_REWARD_CELL) uiMap["cell.bg.bounty_reward_cell_2"]:setAnchoredPositionX(GConst.UI_SCREEN_WIDTH/4) self.bountyRewardCell2 = uiMap["cell.bg.bounty_reward_cell_2"]:addLuaComponent(BOUNTY_REWARD_CELL) self.maskImg = uiMap["cell.mask_img"] self.lvBg = uiMap["cell.bg.lv_bg"] self.lvTx = uiMap["cell.bg.lv_bg.lv_tx"] self.progressBg = uiMap["cell.bg.progress_bg"] self.progressComp = uiMap["cell.bg.progress_bg.progress"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER) self.bountyRewardCell1:addClickListener(function() if self.idx == nil then return end local iCslaimed = DataManager.BountyData:getLevelState(self.idx) local lv = DataManager.BountyData:getLevel() if not iCslaimed and lv >= self.idx then ModuleManager.BountyManager:claimReward(self.idx, false) else local bountyInfo = DataManager.BountyData:getSeasonInfoByLevel(self.idx) ModuleManager.TipsManager:showRewardTips(bountyInfo.reward.id, bountyInfo.reward.type, self.bountyRewardCell1:getBaseObject()) end end) self.bountyRewardCell2:addClickListener(function() if self.idx == nil then return end local isBought = DataManager.BountyData:getBought() local iCslaimed = DataManager.BountyData:getProLevelState(self.idx) local lv = DataManager.BountyData:getLevel() if isBought and not iCslaimed and lv >= self.idx then ModuleManager.BountyManager:claimReward(self.idx, true) else local bountyInfo = DataManager.BountyData:getSeasonInfoByLevel(self.idx) ModuleManager.TipsManager:showRewardTips(bountyInfo.reward_pro.id, bountyInfo.reward_pro.type, self.bountyRewardCell2:getBaseObject()) end end) end function BountyCell:refresh(idx, isFinalCell) self.idx = idx local bountyInfo = DataManager.BountyData:getSeasonInfoByLevel(idx) local lv = DataManager.BountyData:getLevel() local state = DataManager.BountyData:getLevelState(idx) local proState = DataManager.BountyData:getProLevelState(idx) local isBought = DataManager.BountyData:getBought() self.lvTx:setText(GFunc.intToString(idx)) self.bountyRewardCell1:refresh(bountyInfo.reward, false, false, state) self.bountyRewardCell2:refresh(bountyInfo.reward_pro, true, not isBought, proState) if lv >= idx then self.maskImg:setVisible(false) self.lvBg:setImageGray(false) if lv == idx then self.progressComp.value = 0 else self.progressComp.value = 1 end if state then -- 已经领过了 self.bountyRewardCell1:hideLight() else self.bountyRewardCell1:showLight() end if isBought and not proState then self.bountyRewardCell2:showLight() else self.bountyRewardCell2:hideLight() end else self.lvBg:setImageGray(true) self.maskImg:setVisible(true) self.progressComp.value = 0 self.bountyRewardCell1:hideLight() self.bountyRewardCell2:hideLight() end if isFinalCell then self.progressBg:setVisible(false) else self.progressBg:setVisible(true) end end function BountyCell:setVisible(visible) self.baseObject:setVisible(visible) end return BountyCell