121 lines
3.6 KiB
Lua
121 lines
3.6 KiB
Lua
local BountyRewardCell = class("BountyRewardCell", BaseCell)
|
|
|
|
function BountyRewardCell:init()
|
|
local uiMap = self:getUIMap()
|
|
self.bg = uiMap["bounty_reward_cell.bg"]
|
|
self.icon = uiMap["bounty_reward_cell.icon"]
|
|
self.numTx = uiMap["bounty_reward_cell.num"]
|
|
self.check = uiMap["bounty_reward_cell.check"]
|
|
self.fragment = uiMap["bounty_reward_cell.fragment"]
|
|
self.light = uiMap["bounty_reward_cell.light"]
|
|
self.lock = uiMap["bounty_reward_cell.lock"]
|
|
self.matchImg = uiMap["bounty_reward_cell.match_img"]
|
|
self.sImg = uiMap["bounty_reward_cell.s"]
|
|
self.skin = uiMap["bounty_reward_cell.skin"]
|
|
self.skinQlt = uiMap["bounty_reward_cell.skin.img_qlt"]
|
|
|
|
self:hideLight()
|
|
self.baseObject:addClickListener(function()
|
|
if self.clickCallback then
|
|
self.clickCallback()
|
|
elseif self.rewardId ~= nil then
|
|
ModuleManager.TipsManager:showRewardTips(self.rewardId, self.rewardType, self.baseObject)
|
|
end
|
|
end)
|
|
end
|
|
|
|
function BountyRewardCell:refresh(reward, isPro, isLock, showCheck)
|
|
self:showCheck(showCheck)
|
|
if isPro then
|
|
self.bg:setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_board_2")
|
|
else
|
|
self.bg:setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_board_1")
|
|
end
|
|
if isLock then
|
|
self.lock:setVisible(true)
|
|
else
|
|
self.lock:setVisible(false)
|
|
end
|
|
if reward.type == GConst.REWARD_TYPE.ITEM then
|
|
self:_refreshItem(reward)
|
|
self.rewardId = reward.id
|
|
self.rewardType = reward.type
|
|
else
|
|
self.rewardId = nil
|
|
end
|
|
end
|
|
|
|
function BountyRewardCell:_refreshItem(item)
|
|
local info = ConfigManager:getConfig("item")[item.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
self.numTx:setText(item.count or item.num)
|
|
if info.type == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then
|
|
self.skin:setVisible(false)
|
|
local heroInfo = ConfigManager:getConfig("hero")[info.parameter]
|
|
if heroInfo then
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, heroInfo.icon)
|
|
self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[heroInfo.position])
|
|
self.matchImg:setVisible(true)
|
|
self.sImg:setVisible(heroInfo.qlt >= 4)
|
|
else
|
|
self.icon:setSprite(GConst.ATLAS_PATH.COMMON, "common_alpha")
|
|
self.matchImg:setVisible(false)
|
|
self.sImg:setVisible(false)
|
|
end
|
|
self.fragment:setVisible(true)
|
|
elseif info.type == GConst.ItemConst.ITEM_TYPE.SKIN then
|
|
-- 皮肤道具
|
|
self.skin:setVisible(true)
|
|
self.matchImg:setVisible(false)
|
|
self.fragment:setVisible(false)
|
|
local skinInfo = ConfigManager:getConfig("skin")[info.parameter]
|
|
if skinInfo then
|
|
self.skin:setVisible(true)
|
|
self.sImg:setVisible(skinInfo.qlt >= 4)
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_HERO, skinInfo.icon)
|
|
self.skin:setSprite(GConst.ATLAS_PATH.ICON_HERO, "frame_dec_" .. skinInfo.qlt)
|
|
self.skinQlt:setSprite(GConst.ATLAS_PATH.HERO, "hero_skin_" .. skinInfo.qlt)
|
|
else
|
|
self.icon:setSprite(GConst.ATLAS_PATH.COMMON, "common_alpha")
|
|
self.sImg:setVisible(false)
|
|
end
|
|
else
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon)
|
|
self.fragment:setVisible(false)
|
|
self.matchImg:setVisible(false)
|
|
self.sImg:setVisible(false)
|
|
self.skin:setVisible(false)
|
|
end
|
|
end
|
|
|
|
function BountyRewardCell:showCheck(show)
|
|
self.check:setVisible(show == true)
|
|
end
|
|
|
|
function BountyRewardCell:setVisible(visible)
|
|
self.baseObject:setActive(visible)
|
|
end
|
|
|
|
function BountyRewardCell:setAnchoredPositionX(x)
|
|
self.baseObject:setAnchoredPositionX(x)
|
|
end
|
|
|
|
function BountyRewardCell:setTouchEnable(enable)
|
|
self.baseObject:setTouchEnable(enable)
|
|
end
|
|
|
|
function BountyRewardCell:addClickListener(callback)
|
|
self.clickCallback = callback
|
|
end
|
|
|
|
function BountyRewardCell:showLight()
|
|
self.light:setVisible(true)
|
|
end
|
|
|
|
function BountyRewardCell:hideLight()
|
|
self.light:setVisible(false)
|
|
end
|
|
|
|
return BountyRewardCell |