c1_lua/lua/app/ui/summon/cell/summon_reward_cell.lua
2025-11-17 15:54:49 +08:00

80 lines
2.8 KiB
Lua
Executable File

local UIPrefabObject = require "app/bf/unity/uiprefab_object"
local SummonRewardCell = class("SummonRewardCell", BaseCell)
function SummonRewardCell:init()
local uiMap = self:getUIMap()
self.animator = self.baseObject:getComponent(GConst.TYPEOF_UNITY_CLASS.ANIMATOR)
self.imgIcon = uiMap["summon_reward_cell.bg1.img_icon"]
self.txName = uiMap["summon_reward_cell.bg1.tx_name"]
self.txCount = uiMap["summon_reward_cell.bg1.tx_count"]
self.bg = uiMap["summon_reward_cell.bg"]
self.bg1 = uiMap["summon_reward_cell.bg1"]
self.matchImg = uiMap["summon_reward_cell.bg1.match_img"]
self.heroDec = uiMap["summon_reward_cell.bg1.dec"]
self.effectQlts = {}
self.effectQlts[3] = uiMap["summon_reward_cell.bg1.vfx_b13_chouka_lan_b01"]
self.effectQlts[4] = uiMap["summon_reward_cell.bg1.vfx_b13_chouka_zi_b01"]
self.effectQlts[5] = uiMap["summon_reward_cell.bg1.vfx_b13_chouka_cheng_b01"]
end
function SummonRewardCell:getEffectQlts()
return self.effectQlts
end
function SummonRewardCell:refresh(reward, index, parentUI)
self.patentUI = parentUI
if self.effectQlts[5] then
self.effectQlts[5]:setActive(false)
end
self.effectQlts[5]:setActive(false)
self.effectQlts[4]:setActive(false)
self.effectQlts[3]:setActive(false)
local cfg = DataManager.HeroData:getHeroConfig(reward.item.id)
if not cfg then
return
end
self.imgIcon:setSprite(GConst.ATLAS_PATH.ICON_HERO_SUMMON, tostring(cfg.icon))
self.bg:setSprite(GConst.ATLAS_PATH.ICON_HERO_SUMMON, "summon_card_b_" .. cfg.qlt)
self.bg1:setSprite(GConst.ATLAS_PATH.UI_SUMMON, "summon_card_" .. cfg.qlt)
self.heroDec:setSprite(GConst.ATLAS_PATH.ICON_HERO_SUMMON, "summon_card_mark_" .. cfg.qlt)
self.matchImg:setSprite(GConst.ATLAS_PATH.ICON_HERO, GConst.HeroConst.MATCH_ICON_NAME[cfg.position])
self.txName:setText(ModuleManager.HeroManager:getHeroName(reward.item.id))
-- self.txCount:setText("x" .. reward.item.count)
self:getBaseObject():setActive(true)
self.animator:SetTrigger("t_open")
self.baseObject:performWithDelayGlobal(function()
self:playEffect(cfg.qlt)
end, 0.3)
end
function SummonRewardCell:playEffect(qlt)
if qlt == 6 and self.effectQlts[6] == nil then
local tranInfo = self.imgIcon:getComponent(GConst.TYPEOF_UNITY_CLASS.TRANSFORM).parent
if tranInfo then
local infoBase = UIPrefabObject:create()
infoBase:initWithPrefab(GConst.EMPTY_STRING, tranInfo)
infoBase:initPrefabHelper()
EffectManager:loadUIEffectAsync("assets/prefabs/effects/ui/vfx_b13_chouka_hong_b01.prefab", self.patentUI, infoBase, 0,
function(obj)
if self.effectQlts[6] then
self.effectQlts[6]:destroy()
self.effectQlts[6] = nil
end
self.effectQlts[6] = obj
end)
end
else
local effect = self.effectQlts[qlt]
if effect then
effect:setActive(true)
effect:play()
end
end
-- effect:performDurationDelay(function()
-- effect:setActive(false)
-- end)
end
return SummonRewardCell