183 lines
5.0 KiB
Lua
183 lines
5.0 KiB
Lua
---@class RewardCell : BaseCell
|
|
local RewardCell = class("RewardCell", BaseCell)
|
|
|
|
function RewardCell:init()
|
|
local uiMap = self:getUIMap()
|
|
self.icon = uiMap["reward_cell.bg.icon"]
|
|
self.frameBg = uiMap["reward_cell.bg.frame_bg"]
|
|
self.partBg = uiMap["reward_cell.bg.part_bg"]
|
|
self.frame = uiMap["reward_cell.bg.frame"]
|
|
self.mask = uiMap["reward_cell.bg.mask"]
|
|
self.check = uiMap["reward_cell.bg.check"]
|
|
self.partIcon = uiMap["reward_cell.bg.part_bg.icon"]
|
|
self.numTx = uiMap["reward_cell.bg.num_tx"]
|
|
|
|
self:hideFrameAnimation()
|
|
end
|
|
|
|
function RewardCell:refresh(reward)
|
|
self:showMask(false, false)
|
|
-- self:showLock(false)
|
|
local id
|
|
if reward.type == GConst.REWARD_TYPE.ITEM then
|
|
self:_refreshItem(reward.item)
|
|
id = reward.item.id
|
|
elseif reward.type == GConst.REWARD_TYPE.EQUIP then
|
|
self:_refreshEquip(reward.equip)
|
|
id = reward.equip.id
|
|
elseif reward.type == GConst.REWARD_TYPE.LEGACY then
|
|
self:_refreshLegacy(reward.legacy)
|
|
id = reward.legacy.id
|
|
end
|
|
|
|
if id then
|
|
self:addClickListener(function()
|
|
ModuleManager.TipsManager:showRewardTips(id, reward.type, self.baseObject)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function RewardCell:refreshByConfig(reward, mask, check)
|
|
self:showMask(mask, check)
|
|
-- self:showCheck(false)
|
|
-- self:showLock(false)
|
|
local id
|
|
if reward.type == GConst.REWARD_TYPE.ITEM then
|
|
self:_refreshItem(reward)
|
|
id = reward.id
|
|
elseif reward.type == GConst.REWARD_TYPE.EQUIP then
|
|
self:_refreshEquip(reward)
|
|
id = reward.id
|
|
elseif reward.type == GConst.REWARD_TYPE.LEGACY then
|
|
self:_refreshLegacy(reward)
|
|
id = reward.id
|
|
end
|
|
|
|
if id then
|
|
self:addClickListener(function()
|
|
ModuleManager.TipsManager:showRewardTips(id, reward.type, self.baseObject)
|
|
end)
|
|
end
|
|
end
|
|
|
|
function RewardCell:_refreshItem(item)
|
|
local info = ConfigManager:getConfig("item")[item.cfg_id or item.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
|
|
self.partBg:setVisible(false)
|
|
self.numTx:setVisible(true)
|
|
self.frameBg:setSprite(GConst.ATLAS_PATH.ICON_ITEM, "frame_0")
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_ITEM, info.icon)
|
|
if info.type == 6 then
|
|
self.numTx:setText(BigNumOpt.bigNum2Num(item.count))
|
|
else
|
|
self.numTx:setText(BigNumOpt.bigNum2Str(item.count))
|
|
end
|
|
end
|
|
|
|
function RewardCell:_refreshEquip(equip)
|
|
local info = ConfigManager:getConfig("equip")[equip.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
|
|
self.partBg:setVisible(true)
|
|
self.numTx:setVisible(true)
|
|
self.frameBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "frame_" .. info.qlt)
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, tostring(info.icon))
|
|
self.partBg:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "type_" .. info.qlt)
|
|
self.partIcon:setSprite(GConst.ATLAS_PATH.ICON_EQUIP, "e" .. info.part)
|
|
if type(equip.count) == "table" then
|
|
self.numTx:setText(BigNumOpt.bigNum2Str(equip.count))
|
|
else
|
|
self.numTx:setText(equip.count)
|
|
end
|
|
end
|
|
|
|
function RewardCell:showNumTx(str)
|
|
self.numTx:setText(str)
|
|
end
|
|
|
|
function RewardCell:_refreshLegacy(legacy)
|
|
local info = ConfigManager:getConfig("legacy")[legacy.id]
|
|
if info == nil then
|
|
return
|
|
end
|
|
|
|
self.partBg:setVisible(false)
|
|
self.numTx:setVisible(true)
|
|
self.frameBg:setSprite(GConst.ATLAS_PATH.ICON_LEGACY, "frame_" .. info.qlt)
|
|
self.icon:setSprite(GConst.ATLAS_PATH.ICON_LEGACY, tostring(info.icon))
|
|
if type(legacy.count) == "table" then
|
|
self.numTx:setText(BigNumOpt.bigNum2Str(legacy.count))
|
|
else
|
|
self.numTx:setText(legacy.count)
|
|
end
|
|
end
|
|
|
|
function RewardCell:showNumTx(value)
|
|
self.numTx:setText(value)
|
|
end
|
|
|
|
function RewardCell:showMask(show, syncCheck)
|
|
self.mask:setVisible(show == true)
|
|
self:showCheck(syncCheck)
|
|
end
|
|
|
|
function RewardCell:showFrameAnimation(rewardType)
|
|
self.frame:setVisible(true)
|
|
self.frame:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = true
|
|
if rewardType == GConst.REWARD_TYPE.EQUIP then
|
|
if self.frameAniType ~= rewardType then
|
|
-- CS.UnityEngine.Animator.StringToHash("frame_reward_equip") 结果是-540830890
|
|
-- self.frame:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR):Play(-540830890, -1, 0)
|
|
self.frameAniType = rewardType
|
|
end
|
|
else
|
|
if self.frameAniType ~= GConst.REWARD_TYPE.ITEM then
|
|
-- CS.UnityEngine.Animator.StringToHash("frame_reward") 结果是997722489
|
|
-- self.frame:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR):Play(997722489, -1, 0)
|
|
self.frameAniType = GConst.REWARD_TYPE.ITEM
|
|
end
|
|
end
|
|
end
|
|
|
|
function RewardCell:hideFrameAnimation()
|
|
self.frame:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR).enabled = false
|
|
self.frame:setVisible(false)
|
|
end
|
|
|
|
function RewardCell:hideCountTx()
|
|
end
|
|
|
|
function RewardCell:showCheck(show)
|
|
self.check:setVisible(show == true)
|
|
end
|
|
|
|
function RewardCell:showLock(show)
|
|
self.lock:setVisible(show == true)
|
|
end
|
|
|
|
function RewardCell:setVisible(visible)
|
|
self.baseObject:setActive(visible)
|
|
end
|
|
|
|
function RewardCell:setAnchoredPositionX(x)
|
|
self.baseObject:setAnchoredPositionX(x)
|
|
end
|
|
|
|
function RewardCell:setTouchEnable(enable)
|
|
self.baseObject:setTouchEnable(enable)
|
|
end
|
|
|
|
function RewardCell:addClickListener(func)
|
|
self.baseObject:addClickListener(func)
|
|
end
|
|
|
|
function RewardCell:setLocalScale(x, y, z)
|
|
self.baseObject:setLocalScale(x, y, z)
|
|
end
|
|
|
|
return RewardCell |