This commit is contained in:
puxuan 2025-07-03 20:56:40 +08:00
parent f5ce465420
commit e7314d9bba
2 changed files with 176 additions and 155 deletions

View File

@ -1,11 +1,11 @@
local Component = require (GConst.TYPEOF_LUA_CLASS.LUA_COMPONENT)
local Component = require (GConst.TYPEOF_LUA_CLASS.LUA_COMPONENT)
local CurrencyBar = class("CurrencyBar", Component)
CurrencyBar.cellWidth = 162
CurrencyBar.cellHeight = 40
local OFFSET_X = -20
local OFFSET_Y = -40
local OFFSET_Y = -110
function CurrencyBar:init()
self.currVisible = true

View File

@ -12,42 +12,42 @@ local BOX_ICON = {
}
function MainComp:init()
self.uiMap = self:getBaseObject():genAllChildren()
local uiMap = self:getBaseObject():genAllChildren()
self.chapterImg = self.uiMap["main_comp.img"]
self.chapterNameTx = self.uiMap["main_comp.name_tx"]
self.chapterWavetx = self.uiMap["main_comp.record_tx"]
self.leftArrow = self.uiMap["main_comp.left_arrow"]
local leftArrowBtn = self.uiMap["main_comp.left_arrow.btn"]
self.chapterImg = uiMap["main_comp.img"]
self.chapterNameTx = uiMap["main_comp.name_tx"]
self.chapterWavetx = uiMap["main_comp.record_tx"]
self.leftArrow = uiMap["main_comp.middle_bg.left_arrow"]
local leftArrowBtn = uiMap["main_comp.middle_bg.left_arrow.btn"]
leftArrowBtn:addClickListener(function()
if DataManager.ChapterData:goLastChapter() then
self:refresh()
end
end)
self.rightArrow = self.uiMap["main_comp.right_arrow"]
local rightArrowBtn = self.uiMap["main_comp.right_arrow.btn"]
self.rightArrow = uiMap["main_comp.middle_bg.right_arrow"]
local rightArrowBtn = uiMap["main_comp.middle_bg.right_arrow.btn"]
rightArrowBtn:addClickListener(function()
if DataManager.ChapterData:goNextChapter() then
self:refresh()
end
end)
self.uiMap["main_comp.effect_node.ui_spine_obj"]:playAnim("idle", true, false)
uiMap["main_comp.effect_node.ui_spine_obj"]:playAnim("idle", true, false)
self.chapterBg = self.uiMap["main_comp.bg"]
self.chapterBg = uiMap["main_comp.bg"]
self.chapterBg:setAnchoredPositionX(-720)
self.bossSmoke = self.uiMap["main_comp.boss_smoke"]
self.bossSmoke = uiMap["main_comp.boss_smoke"]
self.bossSmoke:setAnchoredPositionX(10000)
self.smokeNodeTop = self.uiMap["main_comp.smoke_node_1"]
self.monsterNodeTop = self.uiMap["main_comp.monster_node_1"]
self.bossNode = self.uiMap["main_comp.boss_node"]
self.smokeNodeTop = uiMap["main_comp.smoke_node_1"]
self.monsterNodeTop = uiMap["main_comp.monster_node_1"]
self.bossNode = uiMap["main_comp.boss_node"]
self.bossNode:setActive(false)
self.bossSpine = self.uiMap["main_comp.boss_node.boss"]
self.smokeNodeDown = self.uiMap["main_comp.smoke_node_2"]
self.monsterNodeDown = self.uiMap["main_comp.monster_node_2"]
self.dialogueTx = self.uiMap["main_comp.dialogue_node.bg.text"]
self.dialogueBg = self.uiMap["main_comp.dialogue_node.bg"]
self.dialogueNode = self.uiMap["main_comp.dialogue_node"]
self.bossSpine = uiMap["main_comp.boss_node.boss"]
self.smokeNodeDown = uiMap["main_comp.smoke_node_2"]
self.monsterNodeDown = uiMap["main_comp.monster_node_2"]
self.dialogueTx = uiMap["main_comp.dialogue_node.bg.text"]
self.dialogueBg = uiMap["main_comp.dialogue_node.bg"]
self.dialogueNode = uiMap["main_comp.dialogue_node"]
self.dialogueNode:setAnchoredPositionX(0)
self.monsterSpineTopPool = {}
self.monsterSpineDownPool = {}
@ -57,21 +57,34 @@ function MainComp:init()
self.monsterSmokePool = {}
self.startMonsterAction = true
self.fightBtn = self.uiMap["main_comp.fight_btn"]
self.fightBtn = uiMap["main_comp.fight_btn"]
-- 体力消耗
self.fightCost = self.uiMap["main_comp.fight_btn.cost"]
self.costTxDesc = self.uiMap["main_comp.fight_btn.cost.tx_desc"]
self.costTxCost = self.uiMap["main_comp.fight_btn.cost.tx_cost"]
self.fightCost = uiMap["main_comp.fight_btn.cost"]
self.costTxCost = uiMap["main_comp.fight_btn.cost.tx_cost"]
-- 按钮文本
self.txFight = self.uiMap["main_comp.fight_btn.tx_desc"]
self.txFight = uiMap["main_comp.fight_btn.tx_desc"]
self.fightBtn:addClickListener(function ()
ModuleManager.ChapterManager:startFight()
end)
self.uiMap["main_comp.arena_btn"]:addClickListener(function()
self.chapterMiddleBg = uiMap["main_comp.middle_bg"]
self.chapterTx = uiMap["main_comp.middle_bg.chapter_tx"]
self.chapterMaxTx = uiMap["main_comp.middle_bg.max_tx"]
self.chapterInfoBtn = uiMap["main_comp.middle_bg.info_btn"]
self.chapterBoxBtn = uiMap["main_comp.middle_bg.box_btn"]
self.chapterPageBtns = {}
self.chapterPageBtnCheckImgs = {}
self.chapterPageBtnDescTxs = {}
for i = 1, 5 do
self.chapterPageBtns[i] = uiMap["main_comp.middle_bg.page_btn_" .. i]
self.chapterPageBtnCheckImgs[i] = uiMap["main_comp.middle_bg.page_btn_" .. i .. ".check_img"]
self.chapterPageBtnDescTxs[i] = uiMap["main_comp.middle_bg.page_btn_" .. i .. ".desc_tx"]
end
uiMap["main_comp.arena_btn"]:addClickListener(function()
ModuleManager.ArenaManager:reqArenaInfo(true)
end)
self.uiMap["main_comp.daily_challenge_btn"]:addClickListener(function()
uiMap["main_comp.daily_challenge_btn"]:addClickListener(function()
ModuleManager.DailyChallengeManager:showDailyChallengeUI()
end)
end
@ -83,6 +96,67 @@ end
function MainComp:refreshChapter(force)
local chapterId = DataManager.ChapterData:getChapterId()
if self.currChapterId ~= chapterId or force then
self:refreshChapterInfo()
self:refreshFightBtn()
self:doBossAction()
end
self:doChapterMove()
self:doMonsterAction()
end
function MainComp:onOpen()
self.startMonsterAction = true
if self.bossNode then
self.bossNode:setAnchoredPositionX(0)
end
-- if self.bossShadow then
-- self.bossShadow:setAnchoredPositionX(0)
-- end
if self.dialogueNode then
self.dialogueNode:setAnchoredPositionX(0)
end
end
function MainComp:onClose()
if self.chapterMoveSeq then
self.chapterMoveSeq:Kill()
self.chapterMoveSeq = nil
end
if self.chapterMonsterGenerateSeq then
self.chapterMonsterGenerateSeq:Kill()
self.chapterMonsterGenerateSeq = nil
end
self.currChapterId = nil
self.isTopTurn = nil
self.startMonsterAction = false
GFunc.killDOTween(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
self.monsterSpineTopPool = {}
self.monsterSpineDownPool = {}
self.monsterSpineTopList = {}
self.monsterSpineDownList = {}
-- self.monsterShadowPool = {}
self.monsterSmokePool = {}
self.monsterNodeTop:removeAllChildren()
self.monsterNodeDown:removeAllChildren()
-- self.shadowNode:removeAllChildren()
self.smokeNodeTop:removeAllChildren()
self.smokeNodeDown:removeAllChildren()
end
function MainComp:refreshFightBtn()
-- 体力消耗
local cost = DataManager.ChapterData:getFightCost()
self.fightCost:setActive(true)
self.txFight:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
self.costTxCost:setText(GFunc.getRewardNum(cost))
end
function MainComp:refreshChapterInfo()
local chapterId = DataManager.ChapterData:getChapterId()
end
function MainComp:refreshChapterInfo2()
local chapterId = DataManager.ChapterData:getChapterId()
if DataManager.ChapterData:getIsFirstChapter(chapterId) then -- 第一章不需要左箭头
self.leftArrow:setVisible(false)
self.rightArrow:setVisible(DataManager.ChapterData:getMaxChapterId() >= 1)
@ -118,28 +192,28 @@ function MainComp:refreshChapter(force)
end
self.chapterWavetx:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.ChapterData:getChapterMaxWave()))
local slider = self.uiMap["main_comp.progress_bg.slider"]
local slider = uiMap["main_comp.progress_bg.slider"]
if not self.boxObjs then
self.boxObjs = {}
for i = 1, 3 do
self.boxObjs[i] = {
box = self.uiMap["main_comp.progress_bg.box_" .. i],
desc = self.uiMap["main_comp.progress_bg.box_desc_" .. i],
spineObj = self.uiMap["main_comp.progress_bg.spine_node.ui_spine_obj_" .. i],
boxIcon = self.uiMap["main_comp.progress_bg.box_" .. i .. ".box_icon"]
box = uiMap["main_comp.progress_bg.box_" .. i],
desc = uiMap["main_comp.progress_bg.box_desc_" .. i],
spineObj = uiMap["main_comp.progress_bg.spine_node.ui_spine_obj_" .. i],
boxIcon = uiMap["main_comp.progress_bg.box_" .. i .. ".box_icon"]
}
end
end
local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId)
local mysteryBoxBg = self.uiMap["main_comp.img.bg"]
local mysteryBoxBg = uiMap["main_comp.img.bg"]
mysteryBoxBg:setVisible(mysteryBoxCount > 0)
local mysteryBoxIcon = self.uiMap["main_comp.img.mystery_box_icon"]
local mysteryBoxIcon = uiMap["main_comp.img.mystery_box_icon"]
mysteryBoxIcon:setVisible(mysteryBoxCount > 0)
if mysteryBoxCount > 0 then
local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId)
local desc = I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_2, gotCount, mysteryBoxCount)
self.uiMap["main_comp.img.mystery_box_icon.desc"]:setText(desc)
uiMap["main_comp.img.mystery_box_icon.desc"]:setText(desc)
end
local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId()
@ -207,59 +281,6 @@ function MainComp:refreshChapter(force)
end
end
end
self:refreshFightBtn()
self:doBossAction()
end
self:doChapterMove()
self:doMonsterAction()
end
function MainComp:onOpen()
self.startMonsterAction = true
if self.bossNode then
self.bossNode:setAnchoredPositionX(0)
end
-- if self.bossShadow then
-- self.bossShadow:setAnchoredPositionX(0)
-- end
if self.dialogueNode then
self.dialogueNode:setAnchoredPositionX(0)
end
end
function MainComp:onClose()
if self.chapterMoveSeq then
self.chapterMoveSeq:Kill()
self.chapterMoveSeq = nil
end
if self.chapterMonsterGenerateSeq then
self.chapterMonsterGenerateSeq:Kill()
self.chapterMonsterGenerateSeq = nil
end
self.currChapterId = nil
self.isTopTurn = nil
self.startMonsterAction = false
GFunc.killDOTween(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
self.monsterSpineTopPool = {}
self.monsterSpineDownPool = {}
self.monsterSpineTopList = {}
self.monsterSpineDownList = {}
-- self.monsterShadowPool = {}
self.monsterSmokePool = {}
self.monsterNodeTop:removeAllChildren()
self.monsterNodeDown:removeAllChildren()
-- self.shadowNode:removeAllChildren()
self.smokeNodeTop:removeAllChildren()
self.smokeNodeDown:removeAllChildren()
end
function MainComp:refreshFightBtn()
-- 体力消耗
local cost = DataManager.ChapterData:getFightCost()
self.fightCost:setActive(true)
self.costTxDesc:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
self.costTxCost:setText(GFunc.getRewardNum(cost))
end
-- region 动画