76 lines
2.8 KiB
Lua
76 lines
2.8 KiB
Lua
local BountyCell = class("BountyCell", BaseCell)
|
|
|
|
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(GConst.TYPEOF_LUA_CLASS.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(GConst.TYPEOF_LUA_CLASS.BOUNTY_REWARD_CELL)
|
|
self.lvBg = uiMap["cell.bg.lv_bg"]
|
|
self.lvTx = uiMap["cell.bg.lv_bg.lv_tx"]
|
|
|
|
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)
|
|
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.lvBg:setImageGray(false)
|
|
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.bountyRewardCell1:hideLight()
|
|
self.bountyRewardCell2:hideLight()
|
|
end
|
|
end
|
|
|
|
function BountyCell:setVisible(visible)
|
|
self.baseObject:setVisible(visible)
|
|
end
|
|
|
|
return BountyCell |