Merge branch 'dev' of git.juzugame.com:b6-client/b6-lua into dev

This commit is contained in:
chenxi 2023-04-12 18:31:33 +08:00
commit 31bdd83dae
4 changed files with 120 additions and 3 deletions

View File

@ -11,6 +11,8 @@ local localization_global =
["BTN_TEXT_CANCEL"] = "取消", ["BTN_TEXT_CANCEL"] = "取消",
["BTN_TEXT_OK"] = "确定", ["BTN_TEXT_OK"] = "确定",
["BATTLE_DESC_1"] = "是否退出战斗", ["BATTLE_DESC_1"] = "是否退出战斗",
["START_DESC"] = "开始",
} }
return localization_global return localization_global

View File

@ -2,7 +2,7 @@ local BattleController = require "app/module/battle/controller/battle_controller
local BattleControllerStage = class("BattleControllerStage", BattleController) local BattleControllerStage = class("BattleControllerStage", BattleController)
function BattleController:getChapterId() function BattleController:getChapterId()
return 1 -- 临时 return DataManager.ChapterData:getChapterId()
end end
function BattleControllerStage:getInitBoard() function BattleControllerStage:getInitBoard()

View File

@ -1,6 +1,11 @@
local MainComp = class("MainComp", LuaComponent) local MainComp = class("MainComp", LuaComponent)
local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png" local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
local BOX_ICON = {
"common_chest_1",
"common_chest_2"
}
function MainComp:init() function MainComp:init()
self.uiMap = self:getBaseObject():genAllChildren() self.uiMap = self:getBaseObject():genAllChildren()
self:initChapter() self:initChapter()
@ -56,9 +61,9 @@ function MainComp:onFightBtnClick()
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE) ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.STAGE)
end end
function MainComp:refreshChapter() function MainComp:refreshChapter(force)
local chapterId = DataManager.ChapterData:getChapterId() local chapterId = DataManager.ChapterData:getChapterId()
if self.currChapterId ~= chapterId then if self.currChapterId ~= chapterId or force then
self.currChapterId = chapterId self.currChapterId = chapterId
local chapterInfo = ConfigManager:getConfig("chapter")[chapterId] local chapterInfo = ConfigManager:getConfig("chapter")[chapterId]
local chapterI18NInfo = I18N:getConfig("chapter")[chapterId] local chapterI18NInfo = I18N:getConfig("chapter")[chapterId]
@ -68,6 +73,45 @@ function MainComp:refreshChapter()
if chapterI18NInfo then if chapterI18NInfo then
self.chapterNameTx:setText(chapterI18NInfo.name) self.chapterNameTx:setText(chapterI18NInfo.name)
end end
local slider = self.uiMap["main_comp.chapter.progress_bg.slider"]
if not self.boxObjs then
self.boxObjs = {}
for i = 1, 3 do
self.boxObjs[i] = {
box = self.uiMap["main_comp.chapter.progress_bg.box_" .. i],
desc = self.uiMap["main_comp.chapter.progress_bg.box_desc_" .. i]
}
end
end
local boxCount = DataManager.ChapterData:getChapterBoxCount()
slider:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = DataManager.ChapterData:getChapterMaxWave() / boxCount
for index, objs in ipairs(self.boxObjs) do
local show = boxCount >= index
objs.box:setActive(show)
objs.desc:setActive(show)
if show then
local x = 370 * (index / boxCount)
local rewards = DataManager.ChapterData:getChapterBoxByIndex(nil, index)
local num = DataManager.ChapterData:getChapterBoxNum(nil, index)
local rewardGot = DataManager.ChapterData:getChapterBoxRewardGot(nil, index)
local icon = BOX_ICON[1]
if rewardGot then
icon = BOX_ICON[2]
end
objs.box:addClickListener(function()
ModuleManager.TipsManager:showRewardsTips(rewards, nil, objs.box)
end)
objs.box:setSprite(GConst.ATLAS_PATH.COMMON, icon)
objs.box:setAnchoredPositionX(x)
objs.desc:setAnchoredPositionX(x)
objs.desc:setText(num)
end
end
self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
self.uiMap["main_comp.fight_btn.desc_2"]:setText(DataManager.ChapterData:getFightCost())
end end
end end

View File

@ -6,16 +6,22 @@ function ChapterData:ctor()
self.data.chapterId = MIN_CHAPTER_ID self.data.chapterId = MIN_CHAPTER_ID
self.data.maxChapterId = 0 self.data.maxChapterId = 0
self.data.isDirty = false self.data.isDirty = false
self.data.chapterBoxInfo = {}
self.data.chapterFightInfo = {}
end end
function ChapterData:clear() function ChapterData:clear()
self.data.chapterId = MIN_CHAPTER_ID self.data.chapterId = MIN_CHAPTER_ID
self.data.maxChapterId = 0 self.data.maxChapterId = 0
self.data.chapterBoxInfo = {}
self.data.chapterFightInfo = {}
end end
function ChapterData:init(data) function ChapterData:init(data)
self.data.chapterId = data and data.chapterId or MIN_CHAPTER_ID self.data.chapterId = data and data.chapterId or MIN_CHAPTER_ID
self.data.maxChapterId = data and data.maxChapterId or self.data.chapterId - 1 self.data.maxChapterId = data and data.maxChapterId or self.data.chapterId - 1
-- self.data.chapterBoxInfo = {}
-- self.data.chapterFightInfo = {}
end end
function ChapterData:getChapterId() function ChapterData:getChapterId()
@ -59,4 +65,69 @@ function ChapterData:getChapterCfg()
return self.chapterCfg return self.chapterCfg
end end
function ChapterData:getChapterBoxCount(chapterId)
chapterId = chapterId or self:getChapterId()
local cfg = self:getChapterCfg()[chapterId]
if cfg and cfg.box_num then
return #cfg.box_num
end
return 1
end
function ChapterData:getChapterBoxNum(chapterId, index)
chapterId = chapterId or self:getChapterId()
local cfg = self:getChapterCfg()[chapterId]
if cfg and cfg.box_num then
return cfg.box_num[index]
end
end
function ChapterData:getChapterBoxByIndex(chapterId, index)
chapterId = chapterId or self:getChapterId()
if not self:getChapterBoxNum(chapterId, index) then
return
end
local cfg = self:getChapterCfg()[chapterId]
if cfg then
return cfg["box_reward_" .. index]
end
end
function ChapterData:getChapterBoxRewardGot(chapterId, index)
chapterId = tostring(chapterId or self:getChapterId())
local list = self.data.chapterBoxInfo[chapterId]
if not list then
return false
end
for _, idx in ipairs(list) do
if idx == index then
return true
end
end
return false
end
function ChapterData:getChapterMaxWave(chapterId)
chapterId = tostring(chapterId or self:getChapterId())
if self.data.chapterFightInfo[chapterId] then
return self.data.chapterFightInfo[chapterId].maxWave
end
return 0
end
function ChapterData:getFightCost(chapterId)
chapterId = chapterId or self:getChapterId()
local cfg = self:getChapterCfg()[chapterId]
if cfg and cfg.cost then
return cfg.cost.num
end
return 0
end
return ChapterData return ChapterData