64 lines
2.5 KiB
Lua
64 lines
2.5 KiB
Lua
local CollectionRewardCell = class("CollectionRewardCell", BaseCell)
|
|
|
|
function CollectionRewardCell:init()
|
|
local uiMap = self:getUIMap()
|
|
|
|
self.imgProg = uiMap["collection_reward_cell.progress.img_prog"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER)
|
|
self.txValue = uiMap["collection_reward_cell.progress.tx_value"]
|
|
self.txDesc = uiMap["collection_reward_cell.reward_info.tx_desc"]
|
|
self.maskReward = uiMap["collection_reward_cell.reward_info.mask"]
|
|
self.tagProg = uiMap["collection_reward_cell.cur_prog"]
|
|
self.imgTag = uiMap["collection_reward_cell.cur_prog.img_icon"]
|
|
self.txTag = uiMap["collection_reward_cell.cur_prog.tx_value"]
|
|
self.rewards = {}
|
|
for i = 1, 4 do
|
|
table.insert(self.rewards, uiMap["collect_reward_cell.reward_info.rewards.reward_cell_" .. i]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.REWARD_CELL))
|
|
end
|
|
end
|
|
|
|
function CollectionRewardCell:refresh(collectionType, id)
|
|
local curPoint = DataManager.CollectionData:getCurCollectPoint()
|
|
local rewardList = DataManager.CollectionData:getRewardList()[id]
|
|
self.txValue:setText(rewardList.point)
|
|
self.txTag:setText(curPoint)
|
|
|
|
local prog = DataManager.CollectionData:getRewardTargetProgress(id)
|
|
if DataManager.CollectionData:getCurTargetId() == id then
|
|
self.imgProg.value = prog
|
|
self.tagProg:setVisible(true)
|
|
-- 高度超框处理
|
|
local rootHeight = self.baseObject:fastGetSizeDeltaY()
|
|
local posY = rootHeight * prog
|
|
|
|
if id == 1 or id == #DataManager.CollectionData:getRewardList() then
|
|
local tagHeight = self.tagProg:fastGetSizeDeltaY()
|
|
if posY < tagHeight / 2 then
|
|
posY = tagHeight / 2
|
|
end
|
|
end
|
|
self.tagProg:setAnchoredPositionY(posY)
|
|
else
|
|
self.imgProg.value = prog
|
|
self.tagProg:setVisible(false)
|
|
end
|
|
|
|
if DataManager.CollectionData:isRewardReceived(id) then
|
|
self.maskReward:setVisible(false)
|
|
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.COLLECTION_DESC_5))
|
|
else
|
|
self.maskReward:setVisible(true)
|
|
self.txDesc:setText(I18N:getGlobalText(I18N.GlobalConst.COLLECTION_DESC_6))
|
|
end
|
|
for idx, reward in pairs(self.rewards) do
|
|
if rewardList.reward[idx] then
|
|
reward:setVisible(true)
|
|
reward:refreshByConfig(rewardList.reward[idx])
|
|
else
|
|
reward:setVisible(false)
|
|
end
|
|
end
|
|
|
|
GFunc.centerImgAndTx(self.imgTag, self.txTag, 5)
|
|
end
|
|
|
|
return CollectionRewardCell |