diff --git a/lua/app/ui/currency_bar/currency_bar.lua b/lua/app/ui/currency_bar/currency_bar.lua index b8bf6080..0f8dc74d 100644 --- a/lua/app/ui/currency_bar/currency_bar.lua +++ b/lua/app/ui/currency_bar/currency_bar.lua @@ -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 diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index e76b7a7d..57f16782 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -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,131 +96,7 @@ end function MainComp:refreshChapter(force) local chapterId = DataManager.ChapterData:getChapterId() if self.currChapterId ~= chapterId or force then - if DataManager.ChapterData:getIsFirstChapter(chapterId) then -- 第一章不需要左箭头 - self.leftArrow:setVisible(false) - self.rightArrow:setVisible(DataManager.ChapterData:getMaxChapterId() >= 1) - elseif chapterId == DataManager.ChapterData:getMaxChapterId() + 1 then -- 只能看打的最远的关卡 - self.leftArrow:setVisible(true) - self.rightArrow:setVisible(false) - else - self.leftArrow:setVisible(true) - self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId)) - end - - self.currChapterId = chapterId - local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] - local chapterI18NInfo = I18N:getConfig("chapter")[chapterId] - if chapterInfo then - local monsterIdList = chapterInfo.monster_id - if monsterIdList then - local bossId = monsterIdList[1] - if bossId then - local monsterCfg = ConfigManager:getConfig("monster_base") - local monsterInfo = monsterCfg[bossId] - if monsterInfo then - -- self.dialogueBg:setAnchoredPositionY(monsterInfo.blood * monsterInfo.ui/10 + 20) - end - end - end - -- main_bg_1 - -- self.chapterBg:setTexture(string.format(CHAPTER_PATH, chapterInfo.scenes_a)) end - self.chapterBg:setTexture(string.format(CHAPTER_PATH, "main_bg_1")) - end - if chapterI18NInfo then - self.chapterNameTx:setText(chapterI18NInfo.name) - end - self.chapterWavetx:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.ChapterData:getChapterMaxWave())) - - local slider = self.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"] - } - end - end - - local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId) - local mysteryBoxBg = self.uiMap["main_comp.img.bg"] - mysteryBoxBg:setVisible(mysteryBoxCount > 0) - local mysteryBoxIcon = self.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) - end - - local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() - if rewardChapterId > chapterId then - rewardChapterId = chapterId - end - - local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId) - local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId) - local unitValue = 1 / boxCount - local sliderValue = 0 - local lastValue = 0 - for i = 1, boxCount do - if curMaxWave < lastValue then - break - end - local maxWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, i) - local wave = math.min(curMaxWave, maxWave) - sliderValue = sliderValue + unitValue * (wave - lastValue) / (maxWave - lastValue) - lastValue = maxWave - end - slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = sliderValue - - for index, objs in ipairs(self.boxObjs) do - local show = boxCount >= index - objs.box:setActive(show) - objs.desc:setActive(show) - objs.spineObj:setVisible(false) - if show then - local needWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) - local x = 370 * (index / boxCount) - local rewards = DataManager.ChapterData:getChapterBoxRewards(rewardChapterId, index) - local num = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) - local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(rewardChapterId, index) - local icon = BOX_ICON[1] - if rewardGot then - icon = BOX_ICON[2] - end - objs.box:addClickListener(function() - if needWave <= curMaxWave and not rewardGot then - objs.spineObj:setVisible(true) - objs.spineObj:playAnimComplete("open", false, false, function() - ModuleManager.ChapterManager:openBox(rewardChapterId, index) - end) - else - ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box) - end - end) - objs.boxIcon:setSprite(GConst.ATLAS_PATH.COMMON, icon) - objs.box:setAnchoredPositionX(x) - if needWave <= curMaxWave and not rewardGot then - objs.spineObj:setVisible(true) - objs.spineObj:playAnim("idle", true, false) - objs.spineObj:setAnchoredPositionX(x) - objs.boxIcon:setVisible(false) - else - objs.spineObj:setVisible(false) - objs.boxIcon:setVisible(true) - end - objs.desc:setAnchoredPositionX(x) - if boxCount == index then - objs.desc:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_DESC_1, rewardChapterId)) - else - objs.desc:setText(num) - end - end - end - + self:refreshChapterInfo() self:refreshFightBtn() self:doBossAction() end @@ -258,10 +147,142 @@ function MainComp:refreshFightBtn() -- 体力消耗 local cost = DataManager.ChapterData:getFightCost() self.fightCost:setActive(true) - self.costTxDesc:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) + 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) + elseif chapterId == DataManager.ChapterData:getMaxChapterId() + 1 then -- 只能看打的最远的关卡 + self.leftArrow:setVisible(true) + self.rightArrow:setVisible(false) + else + self.leftArrow:setVisible(true) + self.rightArrow:setVisible(not DataManager.ChapterData:isFinalChapter(chapterId)) + end + + self.currChapterId = chapterId + local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] + local chapterI18NInfo = I18N:getConfig("chapter")[chapterId] + if chapterInfo then + local monsterIdList = chapterInfo.monster_id + if monsterIdList then + local bossId = monsterIdList[1] + if bossId then + local monsterCfg = ConfigManager:getConfig("monster_base") + local monsterInfo = monsterCfg[bossId] + if monsterInfo then + -- self.dialogueBg:setAnchoredPositionY(monsterInfo.blood * monsterInfo.ui/10 + 20) + end + end + end + -- main_bg_1 + -- self.chapterBg:setTexture(string.format(CHAPTER_PATH, chapterInfo.scenes_a)) end + self.chapterBg:setTexture(string.format(CHAPTER_PATH, "main_bg_1")) + end + if chapterI18NInfo then + self.chapterNameTx:setText(chapterI18NInfo.name) + end + self.chapterWavetx:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.ChapterData:getChapterMaxWave())) + + local slider = uiMap["main_comp.progress_bg.slider"] + if not self.boxObjs then + self.boxObjs = {} + for i = 1, 3 do + self.boxObjs[i] = { + 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 = uiMap["main_comp.img.bg"] + mysteryBoxBg:setVisible(mysteryBoxCount > 0) + 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) + uiMap["main_comp.img.mystery_box_icon.desc"]:setText(desc) + end + + local rewardChapterId = DataManager.ChapterData:getIsHaveRewardsMinId() + if rewardChapterId > chapterId then + rewardChapterId = chapterId + end + + local curMaxWave = DataManager.ChapterData:getChapterMaxWave(rewardChapterId) + local boxCount = DataManager.ChapterData:getChapterBoxCount(rewardChapterId) + local unitValue = 1 / boxCount + local sliderValue = 0 + local lastValue = 0 + for i = 1, boxCount do + if curMaxWave < lastValue then + break + end + local maxWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, i) + local wave = math.min(curMaxWave, maxWave) + sliderValue = sliderValue + unitValue * (wave - lastValue) / (maxWave - lastValue) + lastValue = maxWave + end + slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = sliderValue + + for index, objs in ipairs(self.boxObjs) do + local show = boxCount >= index + objs.box:setActive(show) + objs.desc:setActive(show) + objs.spineObj:setVisible(false) + if show then + local needWave = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) + local x = 370 * (index / boxCount) + local rewards = DataManager.ChapterData:getChapterBoxRewards(rewardChapterId, index) + local num = DataManager.ChapterData:getChapterBoxNum(rewardChapterId, index) + local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(rewardChapterId, index) + local icon = BOX_ICON[1] + if rewardGot then + icon = BOX_ICON[2] + end + objs.box:addClickListener(function() + if needWave <= curMaxWave and not rewardGot then + objs.spineObj:setVisible(true) + objs.spineObj:playAnimComplete("open", false, false, function() + ModuleManager.ChapterManager:openBox(rewardChapterId, index) + end) + else + ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box) + end + end) + objs.boxIcon:setSprite(GConst.ATLAS_PATH.COMMON, icon) + objs.box:setAnchoredPositionX(x) + if needWave <= curMaxWave and not rewardGot then + objs.spineObj:setVisible(true) + objs.spineObj:playAnim("idle", true, false) + objs.spineObj:setAnchoredPositionX(x) + objs.boxIcon:setVisible(false) + else + objs.spineObj:setVisible(false) + objs.boxIcon:setVisible(true) + end + objs.desc:setAnchoredPositionX(x) + if boxCount == index then + objs.desc:setText(I18N:getGlobalText(I18N.GlobalConst.MAIN_DESC_1, rewardChapterId)) + else + objs.desc:setText(num) + end + end + end +end + -- region 动画 function MainComp:doChapterMove() if self.chapterMoveSeq then