diff --git a/lua/app/module/battle/battle_manager.lua b/lua/app/module/battle/battle_manager.lua index b593a36f..080c39c3 100644 --- a/lua/app/module/battle/battle_manager.lua +++ b/lua/app/module/battle/battle_manager.lua @@ -15,8 +15,8 @@ function BattleManager:showPauseUI(battleType) UIManager:showUI("app/ui/battle/battle_pause_ui", {battleType = battleType}) end -function BattleManager:showBattleResultUI(rewards, combatReport, mysteryBoxIdx) - UIManager:showUI("app/ui/battle/battle_result_ui", {rewards = rewards, combatReport = combatReport, mysteryBoxIdx = mysteryBoxIdx}) +function BattleManager:showBattleResultUI(battleType, rewards, combatReport, mysteryBoxIdx) + UIManager:showUI("app/ui/battle/battle_result_ui", {battleType = battleType, rewards = rewards, combatReport = combatReport, mysteryBoxIdx = mysteryBoxIdx}) end function BattleManager:showBoxOpenUI(rewards, callback) diff --git a/lua/app/module/chapter/chapter_manager.lua b/lua/app/module/chapter/chapter_manager.lua index c15afee3..ecdbbae9 100644 --- a/lua/app/module/chapter/chapter_manager.lua +++ b/lua/app/module/chapter/chapter_manager.lua @@ -100,7 +100,7 @@ function ChapterManager:endFightFinish(result) end end - ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx) + ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.STAGE, newRewards, reqData.combatReport, mysteryBoxIdx) DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx) -- 处理金猪,要在章节更新之后 DataManager.GoldPigData:addGoldPigCount() diff --git a/lua/app/module/daily_challenge/daily_challenge_manager.lua b/lua/app/module/daily_challenge/daily_challenge_manager.lua index 69572a34..8507c751 100644 --- a/lua/app/module/daily_challenge/daily_challenge_manager.lua +++ b/lua/app/module/daily_challenge/daily_challenge_manager.lua @@ -99,7 +99,7 @@ function DailyChallengeManager:endChallengeFinish(result) if result.err_code == GConst.ERROR_STR.SUCCESS then local reqData = result.reqData local rewards = result.rewards - ModuleManager.BattleManager:showBattleResultUI(rewards, reqData.combatReport) + ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, rewards, reqData.combatReport) DataManager.DailyChallengeData:init(result.daily_challenge) ModuleManager.TaskManager:addFightTaskProgress(reqData) diff --git a/lua/app/ui/battle/battle_result_ui.lua b/lua/app/ui/battle/battle_result_ui.lua index 1c0260b6..75dccdb2 100644 --- a/lua/app/ui/battle/battle_result_ui.lua +++ b/lua/app/ui/battle/battle_result_ui.lua @@ -10,6 +10,7 @@ function BattleResultUI:ctor(params) self.rewards = params.rewards self.combatReport = params.combatReport self.mysteryBoxIdx = params.mysteryBoxIdx or 0 + self.battleType = params.battleType self.isTryShowGoldPig = false self.totalDmg = 0 if self.combatReport.atkReport then @@ -182,6 +183,9 @@ end function BattleResultUI:tryShowGoldPig() self.isTryShowGoldPig = true + if self.battleType ~= GConst.BattleConst.BATTLE_TYPE.STAGE then + return false + end if not DataManager.GoldPigData:getIsOpen() then return false end diff --git a/lua/app/ui/shop/box_open_ui.lua b/lua/app/ui/shop/box_open_ui.lua index 6628b2fa..a8b34207 100644 --- a/lua/app/ui/shop/box_open_ui.lua +++ b/lua/app/ui/shop/box_open_ui.lua @@ -1,30 +1,10 @@ local BoxOpenUI = class("BoxOpenUI", BaseUI) - -local SUMMON_ICON_NAME = { - [GConst.SummonConst.SUMMON_TYPE.LV_1] = "shop_chest_1", - [GConst.SummonConst.SUMMON_TYPE.LV_2] = "shop_chest_2", - [GConst.SummonConst.SUMMON_TYPE.LV_3] = "shop_chest_3" -} -local BOUNTY_ICON_NAME = { - [GConst.ItemConst.ITEM_ID_BOX_LV_1] = "bounty_chest_1", - [GConst.ItemConst.ITEM_ID_BOX_LV_2] = "bounty_chest_2", - [GConst.ItemConst.ITEM_ID_BOX_LV_3] = "bounty_chest_5", - [GConst.ItemConst.ITEM_ID_BOX_LV_4] = "bounty_chest_3", - [GConst.ItemConst.ITEM_ID_BOX_LV_5] = "bounty_chest_4", -} +local SPINE_OPEN_TIME = 1.4 function BoxOpenUI:ctor(params) self.params = params or {} -- 将信息传递给下一个界面 self.type = self.params and self.params.type - self.iconName = "shop_chest_1" -- 默认图标 - self.iconAtlas = GConst.ATLAS_PATH.SHOP - if self.type == GConst.ShopConst.BOX_REWARD_TYPE.SUMMON then - self.iconAtlas = GConst.ATLAS_PATH.SHOP - self.iconName = SUMMON_ICON_NAME[self.params.params or GConst.SummonConst.SUMMON_TYPE.LV_1] - elseif self.type == GConst.ShopConst.BOX_REWARD_TYPE.BOUNTY then - self.iconAtlas = GConst.ATLAS_PATH.BOUNTY - self.iconName = BOUNTY_ICON_NAME[self.params.params or GConst.ItemConst.ITEM_ID_BOX_KEY_LV_1] - end + self.index = self.params.params end function BoxOpenUI:isFullScreen() @@ -37,25 +17,32 @@ end function BoxOpenUI:onLoadRootComplete() self.uiMap = self.root:genAllChildren() - self.bg = self.uiMap["box_open_ui.bg"] - self.boxImg = self.uiMap["box_open_ui.box"] - self.openBtn = self.uiMap["box_open_ui.open_btn"] - self.btnText = self.uiMap["box_open_ui.open_btn.text"] - - self.boxImg:setSprite(self.iconAtlas, self.iconName) - self.btnText:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_7)) -- 立即打开 - - self.openBtn:addClickListener(function() - ModuleManager.ShopManager:showBoxRewardUI(self.params) - end) - + self.summonSpineList = {} + for i = 1, 3 do + table.insert(self.summonSpineList, self.uiMap["box_open_ui.ui_spine_obj_" .. i]) + self.summonSpineList[i]:setVisible(false) + end -- 奖励界面打开时 关闭此界面 self:addEventListener(EventManager.CUSTOM_EVENT.CLOSE_BOX_OPEN_UI, function() self:closeUI() end) - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_BOX_HERO_UI) + -- 播放spine表现 播放完毕后打开奖励UI + local spineObj + if self.type == GConst.ShopConst.BOX_REWARD_TYPE.SUMMON then + spineObj = self.summonSpineList[self.index] + elseif self.type == GConst.ShopConst.BOX_REWARD_TYPE.BOUNTY then + -- TODOJ + end + if not spineObj then + spineObj = self.summonSpineList[1] + end + spineObj:setVisible(true) + spineObj:playAnim("born", false, true) + self:performWithDelayGlobal(function() + ModuleManager.ShopManager:showBoxRewardUI(self.params) + end, SPINE_OPEN_TIME) end return BoxOpenUI \ No newline at end of file diff --git a/lua/app/ui/shop/box_reward_ui.lua b/lua/app/ui/shop/box_reward_ui.lua index 82c9e747..8ca6caf0 100644 --- a/lua/app/ui/shop/box_reward_ui.lua +++ b/lua/app/ui/shop/box_reward_ui.lua @@ -11,26 +11,27 @@ local QLT_DELAY_TIME = { } local FIRST_DELAY_TIME = 0 local FADE_TIME = 0.5 -local MAX_SCREEN_CELL_COUNT = 12 -- 同屏界面能展示的最大数量 +local MAX_SCREEN_CELL_COUNT = 8 -- 触发滑动的限制值 +local SCROLL_MOVE_TIME = 0.5 + +local REWARD_CELL_WIDTH = 160 +local REWARD_CELL_HEIGHT = 250 + +local BASE_CONTENT_HEIGHT = 600 + +local POSITION_X_DATA = { + [1] = {0}, + [2] = {-120, 120}, + [3] = {-200, 0, 200}, + [4] = {-240, -80, 80, 240} +} function BoxRewardUI:ctor(params) self.params = params or {} self.rewards = params.rewards or {} self.actionStatus = {} -- 表现状态 self.cellDelayTime = {} -- {idx,time} - -- if #self.params.rewards > MAX_SCREEN_CELL_COUNT then - -- self.showAction = true - -- self.turnIdx = MAX_SCREEN_CELL_COUNT // CELL_NUM - -- self.maxIdx = math.ceil(#self.params.rewards / CELL_NUM) - -- end - - -- 将超过界面展示范围外的cell默认打开 - if #self.params.rewards > MAX_SCREEN_CELL_COUNT then - for i = MAX_SCREEN_CELL_COUNT + 1, #self.params.rewards do - self.actionStatus[i] = true - end - end - + self.isPlayAni = true -- 前端用展示奖励 self.fragmentRewards = {} self.coinNum = 0 @@ -64,18 +65,6 @@ function BoxRewardUI:onLoadRootComplete() self.titleTx = self.uiMap["box_reward_ui.title.text"] self.titleTx:setText(I18N:getGlobalText(I18N.GlobalConst.SHOP_DESC_8)) -- 恭喜获得 - self.scrollRectObj = self.uiMap["box_reward_ui.scroll_rect"] - self.scrollRect = self.scrollRectObj:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) - self.scrollRect:addInitCallback(function() - return BOX_HERO_CELL - end) - self.scrollRect:addRefreshCallback(function(index, cell) - cell:refresh(self.fragmentRewards[index]) - self:playCellAction(cell, index) - end) - self.scrollRect:clearCells() - self.scrollRect:refillCells(#self.fragmentRewards) - self.coinNode = self.uiMap["box_reward_ui.coin_node"] self.coinIcon = self.uiMap["box_reward_ui.coin_node.coin"] self.coinTx = self.uiMap["box_reward_ui.coin_node.text"] @@ -89,9 +78,14 @@ function BoxRewardUI:onLoadRootComplete() self.closeTx = self.uiMap["box_reward_ui.close_tx"] self.closeTx:setText(I18N:getGlobalText(I18N.GlobalConst.CLICK_CLOSE_DESC)) + self:refreshCloseText() self.mask = self.uiMap["box_reward_ui.mask"] self.mask:addClickListener(function() + -- 动画期间不可关闭 + if self.isPlayAni then + return + end self:closeUI() -- 如果宝箱等级提升了 则要弹出宝箱等级提升UI if DataManager.SummonData:checkNeedPopBoxLvUpUI() then @@ -102,6 +96,79 @@ function BoxRewardUI:onLoadRootComplete() -- 关闭上一个界面 EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CLOSE_BOX_OPEN_UI) + + -- 因为特殊表现 用普通scrollRect处理 + self.scrollRectContent = self.uiMap["box_reward_ui.scroll_rect.viewport.content"] + self.scrollMask = self.uiMap["box_reward_ui.scroll_mask"] + self.scrollMask:setVisible(true) + self.baseCell = self.uiMap["box_reward_ui.scroll_rect.viewport.content.cell"] + self.baseCell:setVisible(false) + -- 已拥有的cell + self.rewardCells = self.rewardCells or {} + local contentTrans = self.scrollRectContent:getTransform() + local alreadyCellCount = contentTrans.childCount - 1 + if alreadyCellCount > 0 then + for i = 1, alreadyCellCount do + local prefab = contentTrans:GetChild(i).gameObject + local UIPrefabObject = require "app/bf/unity/uiprefab_object" + local prefabObject = UIPrefabObject:create() + prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) + prefabObject:initPrefabHelper() + table.insert(self.rewardCells, CellManager:addCellComp(prefabObject, BOX_HERO_CELL)) + end + end + local rewardCount = #self.fragmentRewards + local cellCount = #self.rewardCells + local needCreateCount = rewardCount - cellCount + -- 将cell扩充至与奖励等数量 + if needCreateCount > 0 then + for i = 1, needCreateCount do + local prefab = CS.UnityEngine.Object.Instantiate(self.baseCell:getGameObject()) + local UIPrefabObject = require "app/bf/unity/uiprefab_object" + local prefabObject = UIPrefabObject:create() + prefabObject:initWithPrefab(GConst.EMPTY_STRING, prefab) + prefabObject:initPrefabHelper() + prefabObject:setParent(self.scrollRectContent, false) + prefabObject:getTransform():SetAsLastSibling() + prefabObject:setVisible(true) + -- 设定位置 + local index = cellCount + i + local rowIdx = (index - 1) % CELL_NUM + 1 -- 横排位置 1-4 + local cowIdx = (index - 1) // CELL_NUM + 1 + if rewardCount <= CELL_NUM then -- 居中展示 + prefabObject:setAnchoredPosition(POSITION_X_DATA[rewardCount][rowIdx], 0) + else + prefabObject:setAnchoredPosition(POSITION_X_DATA[4][rowIdx], -(cowIdx - 1) * REWARD_CELL_HEIGHT) + end + table.insert(self.rewardCells, CellManager:addCellComp(prefabObject, BOX_HERO_CELL)) + end + end + -- 刷新 + cellCount = #self.rewardCells + for i = 1, cellCount do + if i <= rewardCount then + self.rewardCells[i]:setVisible(true) + self.rewardCells[i]:refresh(self.fragmentRewards[i]) + else + self.rewardCells[i]:setVisible(false) + end + end + self.maxCow = (rewardCount - 1) // CELL_NUM + 1 -- 最大行数 1-4 = 1, 5-8 = 2,... + self.maxScrollContentHeight = math.max(BASE_CONTENT_HEIGHT, self.maxCow * REWARD_CELL_HEIGHT) + self.scrollRectContent:setAnchoredPositionY(0) + self.scrollRectContent:setSizeDeltaY(self.maxScrollContentHeight) + + -- 如果超出屏蔽显示范围 初始化滑动数据 + if rewardCount > MAX_SCREEN_CELL_COUNT then + self.showAction = true + self.turnIdx = MAX_SCREEN_CELL_COUNT // CELL_NUM + self.maxIdx = math.ceil(rewardCount / CELL_NUM) + end + -- 播放表现 + for idx = 1, rewardCount do + local cell = self.rewardCells[idx] + self:playCellAction(cell, idx) + end end function BoxRewardUI:playCellAction(cell, idx) @@ -126,23 +193,43 @@ function BoxRewardUI:playCellAction(cell, idx) tween:SetEase(CS.DG.Tweening.Ease.InOutSine) seq:Append(tween) seq:AppendCallback(function() - self.actionStatus[idx] = true - -- self:turnToNext(idx) -- 去掉滑动 + if not self:isClosed() then + self.actionStatus[idx] = true + self:turnToNext(idx) + -- 最后一个表现完毕 + if idx == #self.fragmentRewards then + self.isPlayAni = false + self:refreshCloseText() + self.scrollMask:setVisible(false) + end + end end) end --- function BoxRewardUI:turnToNext(idx) --- if not self.showAction or idx ~= self.turnIdx * CELL_NUM then --- return --- end --- self:performWithDelayGlobal(function() --- self.scrollRect:moveToIndex((self.turnIdx - (MAX_SCREEN_CELL_COUNT // CELL_NUM))*CELL_NUM + 1) --- self.turnIdx = self.turnIdx + 1 --- if self.turnIdx >= self.maxIdx then --- self.showAction = false --- end --- end, 0.025) --- end +function BoxRewardUI:turnToNext(idx) + if self:isClosed() then + return + end + if not self.showAction or idx ~= self.turnIdx * CELL_NUM then + return + end + if self.contentSeq then + self.contentSeq:Kill() + self.contentSeq = nil + end + self.contentSeq = self.root:createBindTweenSequence() + self.contentSeq:Append( + self.scrollRectContent:getTransform():DOLocalMoveY(math.min(self.maxScrollContentHeight - BASE_CONTENT_HEIGHT, (self.turnIdx + 1) * REWARD_CELL_HEIGHT - BASE_CONTENT_HEIGHT), SCROLL_MOVE_TIME) + ) + self.contentSeq:AppendCallback( + function() + self.turnIdx = self.turnIdx + 1 + if self.turnIdx >= self.maxIdx then + self.showAction = false + end + end + ) +end function BoxRewardUI:getCellDelayTime(idx) if not self.cellDelayTime[idx] then @@ -163,4 +250,8 @@ function BoxRewardUI:getCellDelayTime(idx) return self.cellDelayTime[idx] end +function BoxRewardUI:refreshCloseText() + self.closeTx:setVisible(not self.isPlayAni) +end + return BoxRewardUI \ No newline at end of file