88 lines
2.9 KiB
Lua
88 lines
2.9 KiB
Lua
local BountyCell = class("BountyCell", BaseCell)
|
|
|
|
function BountyCell:init()
|
|
local uiMap = self:getUIMap()
|
|
self.sliderBg = uiMap["bounty_cell.slider_bg"]
|
|
self.slider = uiMap["bounty_cell.slider_bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
|
self.lvNode = uiMap["bounty_cell.level_bg"]
|
|
self.lvTx = uiMap["bounty_cell.level_bg.lv_tx"]
|
|
self.bg = uiMap["bounty_cell.bg"]
|
|
self.rewardCells = {}
|
|
for i = 1, 3 do
|
|
self.rewardCells[i] = uiMap["bounty_cell.rewards.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
|
|
end
|
|
self.bg:addClickListener(function()
|
|
if self.canClaim then
|
|
self.parentUI:onClaimAllRewards()
|
|
end
|
|
end)
|
|
end
|
|
|
|
function BountyCell:refresh(parentUI, dataKey, index, cfg)
|
|
self.parentUI = parentUI
|
|
self.data = DataManager[dataKey]
|
|
local signDay = self.data:getBountySignDay()
|
|
local maxDay = self.data:getBountyMaxDay()
|
|
|
|
self.canClaim = false
|
|
-- 刷新进度
|
|
local helf = self:getBaseObject():getSizeDeltaY() / 2
|
|
if index == 1 then
|
|
self.sliderBg:setAnchoredPositionY(-helf / 2)
|
|
self.sliderBg:setSizeDeltaY(helf)
|
|
elseif index == maxDay then
|
|
self.sliderBg:setAnchoredPositionY(helf / 2)
|
|
self.sliderBg:setSizeDeltaY(helf)
|
|
else
|
|
self.sliderBg:setAnchoredPositionY(0)
|
|
self.sliderBg:setSizeDeltaY(self:getBaseObject():getSizeDeltaY())
|
|
end
|
|
if signDay < index or signDay == 1 then
|
|
self.slider.value = 0
|
|
elseif signDay < maxDay and signDay == index then
|
|
self.slider.value = 0.5
|
|
else
|
|
self.slider.value = 1
|
|
end
|
|
|
|
self.lvNode:setSprite(parentUI:getBountyLvRes(signDay >= index))
|
|
self.lvTx:setText(index)
|
|
|
|
local isUnlockPro = self.data:isUnlockProReward()
|
|
local rewards = {cfg.reward[1], cfg.reward_pro[1], cfg.reward_pro[2]}
|
|
local rewardGear = {GConst.ActivityConst.REWARD_GEAR.COMMON, GConst.ActivityConst.REWARD_GEAR.PRO, GConst.ActivityConst.REWARD_GEAR.PRO}
|
|
local unlock = {true, isUnlockPro, isUnlockPro}
|
|
for i = 1, 3 do
|
|
local reward = rewards[i]
|
|
local canClaim = self.data:canClaimReward(rewardGear[i], cfg.id)
|
|
local got = self.data:isReceivedReward(rewardGear[i], cfg.id)
|
|
if reward then
|
|
self.rewardCells[i]:setActive(true)
|
|
self.rewardCells[i]:refreshByConfig(reward, got, got)
|
|
self.rewardCells[i]:showLock(not unlock[i])
|
|
if canClaim then
|
|
self.rewardCells[i]:showFrameAnimation()
|
|
self.canClaim = true
|
|
else
|
|
self.rewardCells[i]:hideFrameAnimation()
|
|
end
|
|
self.rewardCells[i]:addClickListener(function()
|
|
if canClaim then
|
|
self.parentUI:onClaimAllRewards()
|
|
else
|
|
ModuleManager.TipsManager:showRewardTips(reward.id, reward.type, self.rewardCells[i]:getBaseObject())
|
|
end
|
|
end)
|
|
if i == 3 then
|
|
self.rewardCells[2]:setAnchoredPositionX(93)
|
|
end
|
|
else
|
|
self.rewardCells[i]:setActive(false)
|
|
if i == 3 then
|
|
self.rewardCells[2]:setAnchoredPositionX(155)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
return BountyCell |