569 lines
19 KiB
Lua
Executable File
569 lines
19 KiB
Lua
Executable File
local SummonMainUI = class("SummonMainUI", BaseUI)
|
|
|
|
-- function SummonMainUI:getPreLoadList()
|
|
-- return {
|
|
-- [GConst.TYPEOF_UNITY_CLASS.GAME_OBJECT] = {
|
|
-- "assets/prefabs/effects/ui/vfx_b13_ui_chouka_bg_b02.prefab",
|
|
-- "assets/prefabs/effects/ui/vfx_b13_ui_chouka_bg_b03.prefab",
|
|
-- }
|
|
-- }
|
|
-- end
|
|
|
|
function SummonMainUI:ctor(params)
|
|
self.page = params.summonId or 1
|
|
end
|
|
|
|
function SummonMainUI:getPrefabPath()
|
|
return "assets/prefabs/ui/summon/summon_main_ui.prefab"
|
|
end
|
|
|
|
function SummonMainUI:getCurrencyParams()
|
|
local ItemConst = require "app/module/item/item_const"
|
|
local params = {}
|
|
params.showType = GConst.CURRENCY_TYPE.HORIZONTAL
|
|
if self.page == 1 then
|
|
params.itemIds = {
|
|
ItemConst.ITEM_ID_GOLD,
|
|
ItemConst.ITEM_ID_GEM,
|
|
ItemConst.ITEM_ID_SUMMON_1,
|
|
}
|
|
else
|
|
params.itemIds = {
|
|
ItemConst.ITEM_ID_GOLD,
|
|
ItemConst.ITEM_ID_GEM,
|
|
ItemConst.ITEM_ID_SUMMON_2,
|
|
}
|
|
end
|
|
return params
|
|
end
|
|
|
|
function SummonMainUI:onClose()
|
|
self.heroNode:removeAllChildren()
|
|
-- EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.MAIN_UI_CHECK_POP)
|
|
end
|
|
|
|
function SummonMainUI:onLoadRootComplete()
|
|
local uiMap = self.root:genAllChildren()
|
|
uiMap["summon_main_ui.bottom.close_btn"]:addClickListener(function()
|
|
self:closeUI()
|
|
end)
|
|
self.btnSummonFree = uiMap["summon_main_ui.node.btn_summon_free"]
|
|
self.btnSummonFreeTx = uiMap["summon_main_ui.node.btn_summon_free.text_free"]
|
|
self.btnSummonAd = uiMap["summon_main_ui.node.btn_summon_ad"]
|
|
self.btnSummonAdTx = uiMap["summon_main_ui.node.btn_summon_ad.desc_tx"]
|
|
--两个抽奖按钮
|
|
self.btnSummonOne = uiMap["summon_main_ui.node.btn_summon_one"]
|
|
self.txSummonOneName = uiMap["summon_main_ui.node.btn_summon_one.text"]
|
|
self.imgSummonOneIcon = uiMap["summon_main_ui.node.btn_summon_one.cost.img_icon_1"]
|
|
self.txNumOne = uiMap["summon_main_ui.node.btn_summon_one.cost.tx_num_one"]
|
|
|
|
self.btnSummonTen = uiMap["summon_main_ui.node.btn_summon_ten"]
|
|
self.txSummonTenName = uiMap["summon_main_ui.node.btn_summon_ten.text"]
|
|
self.imgSummonTenIcon = uiMap["summon_main_ui.node.btn_summon_ten.cost.img_icon_1"]
|
|
self.txNumTen = uiMap["summon_main_ui.node.btn_summon_ten.cost.tx_num_ten"]
|
|
|
|
self.txFreeTime = uiMap["summon_main_ui.node.tx_free_time"]
|
|
|
|
self.btnShop = uiMap["summon_main_ui.node.btn_shop"]
|
|
self.btnShopTx = uiMap["summon_main_ui.node.btn_shop.bg.tx_shop_num"]
|
|
-- self.btnWish = uiMap["summon_main_ui.node.btn_wish"] --心愿
|
|
-- self.btnWishTx = uiMap["summon_main_ui.node.btn_wish.tx_guarantee"] --心愿
|
|
-- self.btnWishIcon = uiMap["summon_main_ui.node.btn_wish.img_wish_icon"] --心愿
|
|
-- self.btnWishAddImg = uiMap["summon_main_ui.node.btn_wish.add_img"]
|
|
self.heroNode = uiMap["summon_main_ui.summon_node.hero_node"]
|
|
self.uiNode = uiMap["summon_main_ui.node"]
|
|
self.uiSpineObj = uiMap["summon_main_ui.summon_node.ui_spine_obj"]
|
|
self.uiSpineObj:playAnim("idle", true, true)
|
|
|
|
self.flyEndPos = GFunc.getTargetAnchoredPosition(self.btnShop, self.root)
|
|
self.flyImgs = {}
|
|
for i = 1, 4 do
|
|
self.flyImgs[i] = uiMap["summon_main_ui.fly_img_" .. i]
|
|
end
|
|
|
|
self.touchNode = uiMap["summon_main_ui.touch_node"]
|
|
self.touchNodeDescTx = uiMap["summon_main_ui.touch_node.continue"]
|
|
self.touchNodeDescTx:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_SKIP_DESC))
|
|
self.touchNode:setActive(false)
|
|
self.touchNodeDescTx:setActive(false)
|
|
self.touchNode:addClickListener(function()
|
|
if not self.canSkip1 then
|
|
return
|
|
end
|
|
self.showIdx = 999
|
|
end)
|
|
self.btnSummonFree:addClickListener(function()
|
|
self:onSummon(1)
|
|
end)
|
|
self.btnSummonOne:addClickListener(function()
|
|
self:onSummon(1)
|
|
end)
|
|
self.btnSummonTen:addClickListener(function()
|
|
self:onSummon(10)
|
|
end)
|
|
self.btnSummonAd:addClickListener(function()
|
|
SDKManager:showFullScreenAds(BIReport.ADS_CLICK_TYPE.SUMMON_AD, function()
|
|
self:onSummon(1, true)
|
|
end)
|
|
end)
|
|
|
|
self.vfxBg = uiMap["summon_main_ui.summon_node.vfx_c1_chouka_bg_01"]
|
|
self.vfxs = {}
|
|
self.vfx01s = {}
|
|
self.vfx02s = {}
|
|
for i = 1, 4 do
|
|
self.vfxs[i] = uiMap["summon_main_ui.summon_node.node_" .. i .. ".vfx_c1_chouka_0" .. i]
|
|
self.vfx01s[i] = uiMap["summon_main_ui.summon_node.vfx_c1_chouka_0" .. i .. "_1"]
|
|
self.vfx02s[i] = uiMap["summon_main_ui.summon_node.vfx_c1_chouka_0" .. i .. "_2"]
|
|
self.vfxs[i]:setActive(false)
|
|
self.vfx01s[i]:setActive(false)
|
|
self.vfx02s[i]:setActive(false)
|
|
end
|
|
|
|
uiMap["summon_main_ui.node.btn_info"]:addClickListener(function()
|
|
ModuleManager.SummonManager:showSummonOddsUI(self.page)
|
|
end)
|
|
self.txTitle = uiMap["summon_main_ui.node.tx_title"]
|
|
|
|
self.summonBg = uiMap['summon_main_ui.bg']
|
|
uiMap["summon_main_ui.node.btn_summon_one.text_one"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_ONE))
|
|
uiMap["summon_main_ui.node.btn_summon_ten.text_ten"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_TEN))
|
|
uiMap["summon_main_ui.node.btn_summon_free.text_free"]:setText(I18N:getGlobalText(I18N.GlobalConst.FREE_DESC_1))
|
|
uiMap["summon_main_ui.node.btn_summon_ad.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_DESC_1))
|
|
uiMap["summon_main_ui.node.btn_info.desc_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_FORCE_3))
|
|
uiMap["summon_main_ui.node.skip_node.text"]:setText(I18N:getGlobalText(I18N.GlobalConst.ACT_TURNTABLE_DESC_5))
|
|
self.descBg = uiMap["summon_main_ui.node.desc_bg"]
|
|
self.descTx = uiMap["summon_main_ui.node.desc_bg.desc_tx"]
|
|
self.skipNode = uiMap["summon_main_ui.node.skip_node"]
|
|
self.skipNodeCheck = uiMap["summon_main_ui.node.skip_node.check"]
|
|
self.skipNodeSelect = uiMap["summon_main_ui.node.skip_node.check.select"]
|
|
self.skipNodeTx = uiMap["summon_main_ui.node.skip_node.text"]
|
|
self.skipNode:addClickListener(function()
|
|
local isQuick = DataManager.SummonData:getSkipAniFlag()
|
|
DataManager.SummonData:setSkipAniFlag(not isQuick)
|
|
self.skipNodeSelect:setActive(not isQuick)
|
|
end)
|
|
local isQuick = DataManager.SummonData:getSkipAniFlag()
|
|
self.skipNodeSelect:setActive(isQuick)
|
|
GFunc.centerImgAndTx(self.skipNodeCheck, self.skipNodeTx, 5)
|
|
self.skipNode:setActive(false)
|
|
-- self.btnTxs = {
|
|
-- I18N:getGlobalText(I18N.GlobalConst.SUMMON_DESC_6),
|
|
-- I18N:getGlobalText(I18N.GlobalConst.SUMMON_DESC_7),
|
|
-- }
|
|
-- self.pageBtns = {}
|
|
-- self.pageBtnTxs = {}
|
|
-- for i = 1, 2 do
|
|
-- self.pageBtns[i] = uiMap['summon_main_ui.bottom.btn_'.. i]
|
|
-- self.pageBtnTxs[i] = uiMap['summon_main_ui.bottom.btn_'.. i ..'.tx_desc']
|
|
-- self.pageBtnTxs[i]:setText(self.btnTxs[i])
|
|
-- self.pageBtns[i]:addClickListener(function()
|
|
-- if self.page == i then
|
|
-- return
|
|
-- end
|
|
-- self.page = i
|
|
-- self:onRefresh()
|
|
-- UIManager:updateBarsState(self)
|
|
-- end)
|
|
-- end
|
|
|
|
-------------抽奖相关---------
|
|
self:addEventListener(EventManager.CUSTOM_EVENT.FORCE_SUMMON, function(result, newHero)
|
|
if not result then
|
|
self:enableTouch()
|
|
self.uiNode:setActive(true)
|
|
return
|
|
end
|
|
-- self:refreshWishBtn()
|
|
self:playSummonAni(result, newHero)
|
|
end)
|
|
self:addEventListener(EventManager.CUSTOM_EVENT.FORCE_SUMMON_WISH_CLAIM, function(result, newHero)
|
|
-- self:refreshWishBtn()
|
|
ModuleManager.SummonManager:showSummonRewardUI({
|
|
rewards = result.rewards,
|
|
isWish = true,
|
|
newHero = newHero,
|
|
page = self.page
|
|
})
|
|
end)
|
|
|
|
-- self:addEventListener(EventManager.CUSTOM_EVENT.FORCE_SUMMON_WISH_HERO_ID, function()
|
|
-- if self:isClosed() then
|
|
-- return
|
|
-- end
|
|
-- self:refreshWishBtn()
|
|
-- end)
|
|
|
|
-- self.btnWish:addClickListener(function()
|
|
-- if self.isUnlock then
|
|
-- local wishHeroId = DataManager.SummonData:getSummonWishHeroId(self.page)
|
|
-- local wishGuarantee = DataManager.SummonData:getSummonWishGuarantee2(self.page)
|
|
-- local wishCount = DataManager.SummonData:getSummonWishCount(self.page)
|
|
-- if wishCount >= wishGuarantee and wishHeroId ~= 0 then
|
|
-- --发送领取奖励的协议
|
|
-- ModuleManager.SummonManager:onSummonWishClaimReq(self.page)
|
|
-- else
|
|
-- --打开设置心愿界面
|
|
-- ModuleManager.SummonManager:showSummonWishUI(self.page)
|
|
-- end
|
|
-- else
|
|
-- GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.SUMMON_WISH_LOCK))
|
|
-- end
|
|
-- end)
|
|
self.btnShop:addClickListener(function()
|
|
ModuleManager.SummonManager:showSummonShopUI(1)
|
|
end)
|
|
self:bind(DataManager.SummonData, "isDirty", function()
|
|
self:onRefresh()
|
|
end)
|
|
-- self:bind(DataManager.ActTimeData, "isDirty", function()
|
|
-- self:onRefresh()
|
|
-- end)
|
|
|
|
self:scheduleGlobal(function()
|
|
self:updateTime()
|
|
end, 1)
|
|
self:updateTime()
|
|
|
|
self:refreshShopItem()
|
|
end
|
|
|
|
--每秒刷新单抽红点
|
|
function SummonMainUI:updateTime()
|
|
local isFree = DataManager.SummonData:hasSummonFree(self.page)
|
|
if self.isFree ~= isFree then
|
|
self.isFree = isFree
|
|
self:onRefresh()
|
|
end
|
|
if not self.isFree then
|
|
self.remain_time = Time:getTodaySurplusTime()
|
|
self.txFreeTime:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_FREE_TIME, Time:formatNumTime(self.remain_time)))
|
|
else
|
|
self.txFreeTime:setText("")
|
|
end
|
|
end
|
|
|
|
--刷新
|
|
function SummonMainUI:onRefresh()
|
|
self:refreshSkip()
|
|
self:refreshSummonBtn()
|
|
self:refreshSummonDesc()
|
|
-- self:refreshBtnRedPoint()
|
|
-- self:refreshPageBtn()
|
|
self:updateTime()
|
|
end
|
|
|
|
function SummonMainUI:refreshSkip()
|
|
if not self.canSkip1 then
|
|
local totalCount = DataManager.SummonData:getSummonCount(self.page)
|
|
self.canSkip1 = totalCount >= GFunc.getConstIntValue("summon_skip_1")
|
|
end
|
|
if not self.canSkip2 then
|
|
local totalCount = DataManager.SummonData:getSummonCount(self.page)
|
|
self.canSkip2 = totalCount >= GFunc.getConstIntValue("summon_skip_2")
|
|
end
|
|
|
|
self.touchNodeDescTx:setActive(self.canSkip1)
|
|
self.skipNode:setActive(self.canSkip2)
|
|
end
|
|
|
|
-- function SummonMainUI:refreshPageBtn()
|
|
-- for i = 1, 2 do
|
|
-- if self.page == i then
|
|
-- self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_btn_" .. i .."_1")
|
|
-- else
|
|
-- self.pageBtns[i]:setSprite(GConst.ATLAS_PATH.UI_ACT_COMMON, "act_common_btn_" .. i .."_2")
|
|
-- end
|
|
-- end
|
|
-- end
|
|
|
|
--刷新抽奖按钮
|
|
function SummonMainUI:refreshSummonBtn()
|
|
local freeCount = DataManager.SummonData:getSummonFreeCount(self.page)
|
|
local adCount = DataManager.SummonData:getSummonAdCount(self.page)
|
|
self.btnSummonAd:setActive(adCount > 0)
|
|
self.btnSummonFree:setActive(freeCount > 0)
|
|
self.btnSummonOne:setActive(freeCount <= 0)
|
|
|
|
local itemCost = DataManager.SummonData:getSummonItemCost(self.page)
|
|
local costId = itemCost.id
|
|
local hadNum = DataManager.BagData.ItemData:getItemNumById(costId)
|
|
if freeCount <= 0 then
|
|
if hadNum >= 1 then
|
|
self.txNumOne:setText(1)
|
|
self.btnSummonOne:addRedPoint(124, 32, 1)
|
|
self.imgSummonOneIcon:setSprite(ModuleManager.ItemManager:getItemIcon(costId))
|
|
else
|
|
self.btnSummonOne:removeRedPoint()
|
|
local cost = DataManager.SummonData:getSummonGemCost(self.page)
|
|
if cost and hadNum == 0 and GFunc.checkCost(GConst.ItemConst.ITEM_ID_GEM, cost.num, false) then
|
|
self.txNumOne:setText(cost.num)
|
|
self.imgSummonOneIcon:setSprite(ModuleManager.ItemManager:getItemIcon(GConst.ItemConst.ITEM_ID_GEM))
|
|
-- obj = DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GEM)
|
|
else
|
|
self.txNumOne:setText("<color=#EC3636>1</color>")
|
|
self.imgSummonOneIcon:setSprite(ModuleManager.ItemManager:getItemIcon(costId))
|
|
end
|
|
end
|
|
end
|
|
|
|
if hadNum >= 10 then
|
|
self.txNumTen:setText(10)
|
|
self.imgSummonTenIcon:setSprite(ModuleManager.ItemManager:getItemIcon(costId))
|
|
self.btnSummonTen:addRedPoint(124, 32, 1)
|
|
else
|
|
self.btnSummonTen:removeRedPoint()
|
|
local cost = DataManager.SummonData:getSummonGemCost(self.page)
|
|
if cost and hadNum == 0 and GFunc.checkCost(GConst.ItemConst.ITEM_ID_GEM, cost.num * 10, false) then
|
|
self.txNumTen:setText(cost.num * 10)
|
|
self.imgSummonTenIcon:setSprite(ModuleManager.ItemManager:getItemIcon(GConst.ItemConst.ITEM_ID_GEM))
|
|
-- obj = DataManager.BagData.ItemData:getItemById(GConst.ItemConst.ITEM_ID_GEM)
|
|
else
|
|
self.txNumTen:setText("<color=#EC3636>10</color>")
|
|
self.imgSummonTenIcon:setSprite(ModuleManager.ItemManager:getItemIcon(costId))
|
|
end
|
|
end
|
|
end
|
|
|
|
function SummonMainUI:refreshSummonDesc()
|
|
local guarantee1 = DataManager.SummonData:getSummonConfig(self.page).guarantee1
|
|
if not guarantee1 then
|
|
self.descBg:setActive(false)
|
|
else
|
|
self.descBg:setActive(true)
|
|
local count = guarantee1 - DataManager.SummonData:getSummonTriggerCount(self.page)
|
|
self.descTx:setText(I18N:getGlobalText(I18N.GlobalConst.SUMMON_FORCE_4, count))
|
|
end
|
|
end
|
|
--刷新心愿按钮
|
|
-- function SummonMainUI:refreshWishBtn()
|
|
-- local love = DataManager.SummonData:getSummonWishConfig(self.page)
|
|
-- if not love then
|
|
-- self.btnWish:setActive(false)
|
|
-- return
|
|
-- end
|
|
-- self.btnWish:setActive(true)
|
|
-- local summonCount = DataManager.SummonData:getSummonCount(self.page)
|
|
-- local unlockCount = DataManager.SummonData:getSummonWishUnlock(self.page)
|
|
-- self.isUnlock = summonCount >= unlockCount
|
|
-- local wishCount = DataManager.SummonData:getSummonWishCount(self.page)
|
|
-- local needCount = DataManager.SummonData:getSummonWishGuarantee2(self.page)
|
|
-- self.btnWishTx:setText(wishCount .. "/" .. needCount)
|
|
|
|
-- local wishHeroId = DataManager.SummonData:getSummonWishHeroId(self.page)
|
|
-- local cfg = DataManager.HeroData:getHeroConfig(wishHeroId)
|
|
-- if cfg then
|
|
-- self.btnWishIcon:setSprite(GFunc.getHeroIcon(cfg.icon))
|
|
-- self.btnWish:setSprite(GConst.ATLAS_PATH.ICON_ITEM, GConst.FRAME_QLT[cfg.qlt])
|
|
-- self.btnWishAddImg:setActive(false)
|
|
-- else
|
|
-- self.btnWishIcon:setSprite(GConst.ATLAS_PATH.COMMON, "common_alpha")
|
|
-- self.btnWishAddImg:setActive(true)
|
|
-- end
|
|
-- end
|
|
|
|
function SummonMainUI:refreshShopItem()
|
|
self.btnShopTx:setText(DataManager.BagData.ItemData:getItemNumById(GConst.ItemConst.ITEM_ID_SUMMON_SHOP_GOLD_COMMON))
|
|
end
|
|
|
|
--检查单抽红点
|
|
function SummonMainUI:refreshBtnRedPoint()
|
|
if DataManager.SummonData:hasSummonFree(self.page) then
|
|
self.btnSummonFree:addRedPoint(124, 33, 1)
|
|
else
|
|
self.btnSummonFree:removeRedPoint()
|
|
end
|
|
end
|
|
|
|
function SummonMainUI:summon(count, summonType)
|
|
if not DataManager.SummonData:getSkipAniFlag() then
|
|
AudioManager:playEffect(AudioManager.EFFECT_ID.UI_SUMMON_START)
|
|
end
|
|
self.touchNodeDescTx:setActive(false)
|
|
self:disableTouch()
|
|
self.uiNode:setActive(false)
|
|
ModuleManager.SummonManager:onForceSummonReq(count, summonType, self.page)
|
|
end
|
|
|
|
function SummonMainUI:onSummon(count, isAd)
|
|
self.heroNode:removeAllChildren()
|
|
if isAd then
|
|
self:summon(count, 1)
|
|
else
|
|
local freeCount = DataManager.SummonData:getSummonFreeCount(self.page)
|
|
if freeCount > 0 and count == 1 then
|
|
self:summon(count, 2)
|
|
return
|
|
end
|
|
local costs = DataManager.SummonData:getSummonCosts(self.page, count)
|
|
local hasGemCost = false
|
|
for i, cost in ipairs(costs) do
|
|
if cost.id == GConst.ItemConst.ITEM_ID_GEM then
|
|
hasGemCost = true
|
|
end
|
|
end
|
|
if hasGemCost then
|
|
local params = {}
|
|
local itemCost = DataManager.SummonData:getSummonItemCost(self.page)
|
|
local costId = itemCost.id
|
|
local costNum = (count - DataManager.BagData.ItemData:getItemNumById(costId))
|
|
local gemCost = DataManager.SummonData:getSummonGemCost(self.page)
|
|
local costGemNum = gemCost.num * costNum
|
|
params.content = I18N:getGlobalText(I18N.GlobalConst.ITEM_NOT_ENOUGH_DESC, costGemNum, GFunc.getRewardName(GConst.REWARD_TYPE.ITEM, costId), costNum)
|
|
params.boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL
|
|
params.showToday = GConst.MESSAGE_BOX_SHOW_TODAY.SUMMON_FORCE
|
|
params.okFunc = function()
|
|
for i, cost in ipairs(costs) do
|
|
if not GFunc.checkCost(cost.id, GFunc.getRewardNum(cost), true) then
|
|
return
|
|
end
|
|
end
|
|
|
|
self:summon(count, 0)
|
|
end
|
|
GFunc.showMessageBox(params)
|
|
return
|
|
else
|
|
for i, cost in ipairs(costs) do
|
|
if not GFunc.checkCost(cost.id, GFunc.getRewardNum(cost), true) then
|
|
return
|
|
end
|
|
end
|
|
end
|
|
self:summon(count, 0)
|
|
end
|
|
end
|
|
|
|
function SummonMainUI:playSummonAni(result, newHero)
|
|
self.uiSpineObj:setActive(true)
|
|
self.uiSpineObj:playAnimComplete("open", false, true, function()
|
|
self.uiSpineObj:setActive(false)
|
|
self:onSummonRsp(result, newHero)
|
|
end)
|
|
end
|
|
|
|
function SummonMainUI:onSummonEnd()
|
|
self:enableTouch()
|
|
self.uiNode:setActive(true)
|
|
self.heroNode:removeAllChildren()
|
|
self.uiSpineObj:setActive(true)
|
|
self.uiSpineObj:playAnim("idle", true, true)
|
|
self:refreshSkip()
|
|
ModuleManager.SummonManager:showSummonRewardUI({
|
|
rewards = self.summonResult,
|
|
callback = function(count, isAd)
|
|
self:onSummon(count, isAd)
|
|
end,
|
|
closeCallBack =function ()
|
|
self:fly()
|
|
end,
|
|
newHero = self.newHero,
|
|
page = self.page
|
|
})
|
|
end
|
|
|
|
function SummonMainUI:onSummonRsp(result, newHero)
|
|
self:refreshSummonBtn()
|
|
if not result.rewards or not result.rewards[1] then
|
|
self:enableTouch()
|
|
self.uiNode:setActive(true)
|
|
return
|
|
end
|
|
self.newHero = newHero
|
|
self.summonResult = {}
|
|
local qlt = 3
|
|
for _, v in ipairs(result.rewards) do
|
|
local itemType = ModuleManager.ItemManager:getItemType(v.item.id)
|
|
if itemType == GConst.ItemConst.ITEM_TYPE.HERO_FRAGMENT then
|
|
local id = v.item.id
|
|
local q = DataManager.HeroData:getHeroQlt(id)
|
|
qlt = math.max(qlt, q)
|
|
table.insert(self.summonResult, v)
|
|
end
|
|
end
|
|
if self.aniSeq then
|
|
self.aniSeq:Kill()
|
|
self.aniSeq = nil
|
|
end
|
|
|
|
for i = 1, 4 do
|
|
self.vfxs[i]:setActive(false)
|
|
self.vfx01s[i]:setActive(false)
|
|
self.vfx02s[i]:setActive(false)
|
|
end
|
|
if DataManager.SummonData:getSkipAniFlag() then
|
|
self:onSummonEnd()
|
|
return
|
|
end
|
|
qlt = qlt - 2
|
|
self.aniSeq = self.root:createBindTweenSequence()
|
|
if self.vfxs[qlt] then
|
|
self.vfxs[qlt]:setActive(true)
|
|
end
|
|
self.aniSeq:AppendInterval(1.5)
|
|
self.aniSeq:AppendCallback(function()
|
|
self.touchNodeDescTx:setActive(self.canSkip1)
|
|
self.showIdx = 1
|
|
self:showHero()
|
|
end)
|
|
end
|
|
|
|
function SummonMainUI:showHero()
|
|
for i = 1, 4 do
|
|
self.vfxs[i]:setActive(false)
|
|
self.vfx01s[i]:setActive(false)
|
|
self.vfx02s[i]:setActive(false)
|
|
end
|
|
if not self.summonResult[self.showIdx] then
|
|
self:onSummonEnd()
|
|
return
|
|
end
|
|
local id = self.summonResult[self.showIdx].item.id
|
|
local cfg = DataManager.HeroData:getHeroConfig(id)
|
|
local qlt = cfg.qlt - 2
|
|
self.heroNode:removeAllChildren()
|
|
SpineManager:loadHeroAsync(cfg.model_id, self.heroNode, function(spineObject)
|
|
spineObject:setActive(false)
|
|
spineObject:playAnimation("idle", true)
|
|
spineObject:setLocalScale(0.7, 0.7, 0.7)
|
|
AudioManager:playEffect(AudioManager.EFFECT_ID["UI_SUMMON_QLT_" .. cfg.qlt])
|
|
self.vfxBg:setActive(true)
|
|
if self.vfx01s[qlt] then
|
|
self.vfx01s[qlt]:setActive(true)
|
|
end
|
|
if self.vfx02s[qlt] then
|
|
self.vfx02s[qlt]:setActive(true)
|
|
end
|
|
self:performWithDelayGlobal(function()
|
|
spineObject:setActive(true)
|
|
end, 0.25)
|
|
self:performWithDelayGlobal(function()
|
|
self.showIdx = self.showIdx + 1
|
|
self:showHero()
|
|
end, 1)
|
|
end)
|
|
end
|
|
|
|
function SummonMainUI:disableTouch()
|
|
self.touchNode:setActive(true)
|
|
end
|
|
|
|
function SummonMainUI:enableTouch()
|
|
self.touchNode:setActive(false)
|
|
end
|
|
|
|
function SummonMainUI:fly()
|
|
for i = 1, 4 do
|
|
self.flyImgs[i]:setSprite(GFunc.getIconRes(GConst.ItemConst.ITEM_ID_SUMMON_SHOP_GOLD_COMMON))
|
|
local posX, posY = GFunc.randomPos(i, {x = 0, y= 0})
|
|
GFunc.imgFly(self.flyImgs[i], {x = posX, y = posY}, self.flyEndPos, function ()
|
|
if i == 4 then
|
|
GFunc.doScaleFlyImg(self.btnShop)
|
|
self:refreshShopItem()
|
|
end
|
|
end)
|
|
end
|
|
end
|
|
|
|
return SummonMainUI
|