每日挑战
This commit is contained in:
parent
8eccf012ba
commit
9830ac3cbd
@ -8,6 +8,7 @@ function DataManager:init()
|
|||||||
self:initManager("GameSettingData", "app/userdata/game_setting/game_setting_data")
|
self:initManager("GameSettingData", "app/userdata/game_setting/game_setting_data")
|
||||||
self:initManager("PlayerData", "app/userdata/player/player_data")
|
self:initManager("PlayerData", "app/userdata/player/player_data")
|
||||||
self:initManager("ChapterData", "app/userdata/chapter/chapter_data")
|
self:initManager("ChapterData", "app/userdata/chapter/chapter_data")
|
||||||
|
self:initManager("DailyChallengeData", "app/userdata/daily_challenge/daily_challenge_data")
|
||||||
self:initManager("HeroData", "app/userdata/hero/hero_data")
|
self:initManager("HeroData", "app/userdata/hero/hero_data")
|
||||||
self:initManager("BagData", "app/userdata/bag/bag_data")
|
self:initManager("BagData", "app/userdata/bag/bag_data")
|
||||||
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
self:initManager("BattleData", "app/userdata/battle/battle_data")
|
||||||
@ -83,6 +84,7 @@ function DataManager:clear()
|
|||||||
self.cdCallBack = {}
|
self.cdCallBack = {}
|
||||||
self.PlayerData:clear()
|
self.PlayerData:clear()
|
||||||
self.ChapterData:clear()
|
self.ChapterData:clear()
|
||||||
|
self.DailyChallengeData:clear()
|
||||||
self.HeroData:clear()
|
self.HeroData:clear()
|
||||||
self.BagData:clear()
|
self.BagData:clear()
|
||||||
self.FormationData:clear()
|
self.FormationData:clear()
|
||||||
@ -115,6 +117,7 @@ function DataManager:initWithServerData(data)
|
|||||||
self.todayFirstLogin = data.today_first_login
|
self.todayFirstLogin = data.today_first_login
|
||||||
self.PlayerData:init(data)
|
self.PlayerData:init(data)
|
||||||
self.ChapterData:init(data.chapter)
|
self.ChapterData:init(data.chapter)
|
||||||
|
self.DailyChallengeData:init(data.daily_challenge)
|
||||||
self.HeroData:init(data.bag.heroes)
|
self.HeroData:init(data.bag.heroes)
|
||||||
self.BagData:init(data.bag)
|
self.BagData:init(data.bag)
|
||||||
self.FormationData:init(data.fight_info)
|
self.FormationData:init(data.fight_info)
|
||||||
|
|||||||
@ -23,6 +23,8 @@ local MODULE_PATHS = {
|
|||||||
HeroManager = "app/module/hero/hero_manager",
|
HeroManager = "app/module/hero/hero_manager",
|
||||||
-- 主线关卡
|
-- 主线关卡
|
||||||
ChapterManager = "app/module/chapter/chapter_manager",
|
ChapterManager = "app/module/chapter/chapter_manager",
|
||||||
|
-- 每日挑战
|
||||||
|
DailyChallengeManager = "app/module/daily_challenge/daily_challenge",
|
||||||
-- 挂机
|
-- 挂机
|
||||||
IdleManager = "app/module/idle/idle_manager",
|
IdleManager = "app/module/idle/idle_manager",
|
||||||
-- 七天乐
|
-- 七天乐
|
||||||
@ -60,7 +62,8 @@ ModuleManager.MODULE_KEY = {
|
|||||||
IDLE_DROP = "idle_drop",
|
IDLE_DROP = "idle_drop",
|
||||||
MALL = "mall", -- 商城
|
MALL = "mall", -- 商城
|
||||||
MALL_DAILY = "mall_daily", -- 每日商城
|
MALL_DAILY = "mall_daily", -- 每日商城
|
||||||
FUND = "act_level_gift" -- 成长基金
|
FUND = "act_level_gift", -- 成长基金
|
||||||
|
DAILY_CHALLENGE = "daily_challenge", -- 每日挑战
|
||||||
}
|
}
|
||||||
|
|
||||||
local _moduleMgrs = {}
|
local _moduleMgrs = {}
|
||||||
|
|||||||
8
lua/app/module/daily_challenge.meta
Normal file
8
lua/app/module/daily_challenge.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 435eab567f894094e81a6a21e2d27c81
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
27
lua/app/module/daily_challenge/daily_challenge_manager.lua
Normal file
27
lua/app/module/daily_challenge/daily_challenge_manager.lua
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
local DailyChallengeManager = class("DailyChallengeManager", BaseModule)
|
||||||
|
|
||||||
|
function DailyChallengeManager:init()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 开始挑战
|
||||||
|
function DailyChallengeManager:startChallenge()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 挑战结束
|
||||||
|
function DailyChallengeManager:endChallenge()
|
||||||
|
-- 挑战完成固定会给战斗奖励
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取波次(战斗)奖励
|
||||||
|
function DailyChallengeManager:getWaveReward()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取任务(箱子)奖励
|
||||||
|
function DailyChallengeManager:getTaskReward(taskId)
|
||||||
|
-- 跨天通关时,不算完成第二天的任务
|
||||||
|
end
|
||||||
|
|
||||||
|
return DailyChallengeManager
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: b274d9b19c46e4e45833236e6f87983b
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -13,6 +13,8 @@ MainCityConst.BOTTOM_CLOSE_ICON = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MainCityConst.BOTTOM_MODULE_KEY = {
|
MainCityConst.BOTTOM_MODULE_KEY = {
|
||||||
|
DAILY_CHALLENGE = 1,
|
||||||
|
CHAPTER = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
MainCityConst.LEFT_SIDE_BARS = {
|
MainCityConst.LEFT_SIDE_BARS = {
|
||||||
|
|||||||
157
lua/app/ui/main_city/component/chapter_comp.lua
Normal file
157
lua/app/ui/main_city/component/chapter_comp.lua
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
local ChapterComp = class("ChapterComp", LuaComponent)
|
||||||
|
local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
|
||||||
|
|
||||||
|
local BOX_ICON = {
|
||||||
|
"common_chest_1",
|
||||||
|
"common_chest_4"
|
||||||
|
}
|
||||||
|
|
||||||
|
function ChapterComp:init()
|
||||||
|
self.uiMap = self:getBaseObject():genAllChildren()
|
||||||
|
self:initChapter()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChapterComp:initChapter()
|
||||||
|
self.chapterImg = self.uiMap["chapter.img"]
|
||||||
|
self.chapterNameTx = self.uiMap["chapter.name_tx"]
|
||||||
|
self.chapterWavetx = self.uiMap["chapter.record_tx"]
|
||||||
|
self.leftArrow = self.uiMap["chapter.left_arrow"]
|
||||||
|
local leftArrowBtn = self.uiMap["chapter.left_arrow.btn"]
|
||||||
|
leftArrowBtn:addClickListener(function()
|
||||||
|
if DataManager.ChapterData:goLastChapter() then
|
||||||
|
self:refresh()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
self.rightArrow = self.uiMap["chapter.right_arrow"]
|
||||||
|
local rightArrowBtn = self.uiMap["chapter.right_arrow.btn"]
|
||||||
|
rightArrowBtn:addClickListener(function()
|
||||||
|
if DataManager.ChapterData:goNextChapter() then
|
||||||
|
self:refresh()
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.uiMap["chapter.effect_node.ui_spine_obj"]:playAnim("idle", true, false)
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChapterComp:refresh()
|
||||||
|
self:refreshChapter()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ChapterComp: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
|
||||||
|
self.chapterImg:setTexture(string.format(CHAPTER_PATH, chapterInfo.icon))
|
||||||
|
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["chapter.progress_bg.slider"]
|
||||||
|
if not self.boxObjs then
|
||||||
|
self.boxObjs = {}
|
||||||
|
for i = 1, 3 do
|
||||||
|
self.boxObjs[i] = {
|
||||||
|
box = self.uiMap["chapter.progress_bg.box_" .. i],
|
||||||
|
desc = self.uiMap["chapter.progress_bg.box_desc_" .. i],
|
||||||
|
spineObj = self.uiMap["chapter.progress_bg.spine_node.ui_spine_obj_" .. i],
|
||||||
|
boxIcon = self.uiMap["chapter.progress_bg.box_" .. i .. ".box_icon"]
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId)
|
||||||
|
local mysteryBoxIcon = self.uiMap["chapter.img.mystery_box_icon"]
|
||||||
|
mysteryBoxIcon:setVisible(mysteryBoxCount > 0)
|
||||||
|
if mysteryBoxCount > 0 then
|
||||||
|
local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId)
|
||||||
|
self.uiMap["chapter.img.mystery_box_icon.desc"]:setText(gotCount .. "/" .. mysteryBoxCount)
|
||||||
|
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", true, false, function()
|
||||||
|
objs.spineObj:setVisible(false)
|
||||||
|
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.root:refreshFightBtn()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return ChapterComp
|
||||||
10
lua/app/ui/main_city/component/chapter_comp.lua.meta
Normal file
10
lua/app/ui/main_city/component/chapter_comp.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 86d90ec67bf352c4d916945ae3b6a5da
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
10
lua/app/ui/main_city/component/daily_challenge_comp.lua
Normal file
10
lua/app/ui/main_city/component/daily_challenge_comp.lua
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
local DailyChallengeComp = class("DailyChallengeComp", LuaComponent)
|
||||||
|
|
||||||
|
function DailyChallengeComp:ctor()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeComp:init()
|
||||||
|
self.uiMap = self:getBaseObject():genAllChildren()
|
||||||
|
end
|
||||||
|
|
||||||
|
return DailyChallengeComp
|
||||||
10
lua/app/ui/main_city/component/daily_challenge_comp.lua.meta
Normal file
10
lua/app/ui/main_city/component/daily_challenge_comp.lua.meta
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 78833330e8bfc1f418a078dbd9058f86
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
@ -1,41 +1,157 @@
|
|||||||
local MainComp = class("MainComp", LuaComponent)
|
local MainComp = class("MainComp", LuaComponent)
|
||||||
local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
|
local CHAPTER_COMP = "app/ui/main_city/component/chapter_comp"
|
||||||
|
local DAILY_CHALLENGE_COMP = "app/ui/main_city/component/daily_challenge_comp"
|
||||||
|
|
||||||
local BOX_ICON = {
|
local MODULE_DATA = {
|
||||||
"common_chest_1",
|
[1] = {
|
||||||
"common_chest_4"
|
["type"] = GConst.MainCityConst.BOTTOM_MODULE_KEY.DAILY_CHALLENGE,
|
||||||
|
["title"] = "每日挑战",-- 标题
|
||||||
|
["atlas"] = GConst.ATLAS_PATH.ICON_ITEM,-- 图集路径
|
||||||
|
["icon"] = "1",-- 图片名
|
||||||
|
["numFunc"] = function()-- 挑战按钮显示数值
|
||||||
|
return nil
|
||||||
|
end,
|
||||||
|
["clickFunc"] = function()-- 点击回调
|
||||||
|
Logger.logHighlight("点击每日挑战")
|
||||||
|
end
|
||||||
|
},
|
||||||
|
[2] = {
|
||||||
|
["type"] = GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER,
|
||||||
|
["title"] = "主线章节",
|
||||||
|
["atlas"] = GConst.ATLAS_PATH.ICON_ITEM,
|
||||||
|
["icon"] = "2",
|
||||||
|
["numFunc"] = function()
|
||||||
|
return DataManager.ChapterData:getFightCost()
|
||||||
|
end,
|
||||||
|
["clickFunc"] = function()
|
||||||
|
ModuleManager.ChapterManager:startFight()
|
||||||
|
end
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function MainComp:init()
|
function MainComp:init()
|
||||||
self.uiMap = self:getBaseObject():genAllChildren()
|
self.uiMap = self:getBaseObject():genAllChildren()
|
||||||
self:initChapter()
|
|
||||||
|
self.curModuleType = GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER
|
||||||
|
|
||||||
self:initStageFormation()
|
self:initStageFormation()
|
||||||
|
self:refreshBtns()
|
||||||
|
self:refreshModuleComp()
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:initChapter()
|
function MainComp:refreshModuleComp()
|
||||||
self.chapterImg = self.uiMap["main_comp.chapter.img"]
|
if not self.chapterComp then
|
||||||
self.chapterNameTx = self.uiMap["main_comp.chapter.name_tx"]
|
-- 章节
|
||||||
self.chapterWavetx = self.uiMap["main_comp.chapter.record_tx"]
|
local chapterComp = self.uiMap["main_comp.chapter_comp"]
|
||||||
self.leftArrow = self.uiMap["main_comp.chapter.left_arrow"]
|
chapterComp:initPrefabHelper()
|
||||||
local leftArrowBtn = self.uiMap["main_comp.chapter.left_arrow.btn"]
|
chapterComp:genAllChildren()
|
||||||
leftArrowBtn:addClickListener(function()
|
self.chapterComp = chapterComp:addLuaComponent(CHAPTER_COMP)
|
||||||
if DataManager.ChapterData:goLastChapter() then
|
self.chapterComp.root = self
|
||||||
self:refresh()
|
end
|
||||||
end
|
|
||||||
end)
|
|
||||||
self.rightArrow = self.uiMap["main_comp.chapter.right_arrow"]
|
|
||||||
local rightArrowBtn = self.uiMap["main_comp.chapter.right_arrow.btn"]
|
|
||||||
rightArrowBtn:addClickListener(function()
|
|
||||||
if DataManager.ChapterData:goNextChapter() then
|
|
||||||
self:refresh()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
local fightBtn = self.uiMap["main_comp.fight_btn"]
|
|
||||||
fightBtn:addClickListener(function()
|
|
||||||
self:onFightBtnClick()
|
|
||||||
end)
|
|
||||||
|
|
||||||
self.uiMap["main_comp.chapter.effect_node.ui_spine_obj"]:playAnim("idle", true, false)
|
if not self.dailyChallengeComp then
|
||||||
|
-- 每日挑战
|
||||||
|
local dailyChallengeComp = self.uiMap["main_comp.daily_challenge_comp"]
|
||||||
|
dailyChallengeComp:initPrefabHelper()
|
||||||
|
dailyChallengeComp:genAllChildren()
|
||||||
|
dailyChallengeComp:setActive(false)
|
||||||
|
self.dailyChallengeComp = dailyChallengeComp:addLuaComponent(DAILY_CHALLENGE_COMP)
|
||||||
|
self.dailyChallengeComp.root = self
|
||||||
|
end
|
||||||
|
|
||||||
|
self.chapterComp:getBaseObject():setActive(false)
|
||||||
|
self.dailyChallengeComp:getBaseObject():setActive(false)
|
||||||
|
if self.curModuleType == GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER then
|
||||||
|
self.chapterComp:getBaseObject():setActive(true)
|
||||||
|
elseif self.curModuleType == GConst.MainCityConst.BOTTOM_MODULE_KEY.DAILY_CHALLENGE then
|
||||||
|
self.dailyChallengeComp:getBaseObject():setActive(true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:refreshBtns()
|
||||||
|
self:refreshFightBtn()
|
||||||
|
self:refreshLeftBtn()
|
||||||
|
self:refreshRightBtn()
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:refreshFightBtn()
|
||||||
|
local module = nil
|
||||||
|
for type, data in pairs(MODULE_DATA) do
|
||||||
|
if self.curModuleType == type then
|
||||||
|
module = data
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if not module then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
||||||
|
local cost = module["numFunc"]()
|
||||||
|
if cost then
|
||||||
|
self.uiMap["main_comp.fight_btn.desc_2"]:setText(GFunc.getRewardNum(cost))
|
||||||
|
else
|
||||||
|
self.uiMap["main_comp.fight_btn.desc_2"]:setText("0")
|
||||||
|
end
|
||||||
|
|
||||||
|
self.uiMap["main_comp.fight_btn"]:addClickListener(module["clickFunc"])
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:refreshLeftBtn()
|
||||||
|
local module = MODULE_DATA[self:getCurLeftModuleIdx()]
|
||||||
|
if module == nil then
|
||||||
|
self.uiMap["main_comp.left_btn"]:setActive(false)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.uiMap["main_comp.left_btn"]:setActive(true)
|
||||||
|
self.uiMap["main_comp.left_btn.desc"]:setText(module["title"])
|
||||||
|
self.uiMap["main_comp.left_btn.icon"]:setSprite(module["atlas"],module["icon"])
|
||||||
|
self.uiMap["main_comp.left_btn"]:addClickListener(function()
|
||||||
|
self.curModuleType = module["type"]
|
||||||
|
self:refreshBtns()
|
||||||
|
self:refreshModuleComp()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:refreshRightBtn()
|
||||||
|
local module = MODULE_DATA[self:getCurRightModuleIdx()]
|
||||||
|
if module == nil then
|
||||||
|
self.uiMap["main_comp.right_btn"]:setActive(false)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
self.uiMap["main_comp.right_btn"]:setActive(true)
|
||||||
|
self.uiMap["main_comp.right_btn.desc"]:setText(module["title"])
|
||||||
|
self.uiMap["main_comp.right_btn.icon"]:setSprite(module["atlas"],module["icon"])
|
||||||
|
self.uiMap["main_comp.right_btn"]:addClickListener(function()
|
||||||
|
self.curModuleType = module["type"]
|
||||||
|
self:refreshBtns()
|
||||||
|
self:refreshModuleComp()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:getCurLeftModuleIdx()
|
||||||
|
for idx, data in pairs(MODULE_DATA) do
|
||||||
|
if self.curModuleType == data["type"] then
|
||||||
|
if idx == 1 then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return idx - 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:getCurRightModuleIdx()
|
||||||
|
for idx, data in pairs(MODULE_DATA) do
|
||||||
|
if self.curModuleType == data["type"] then
|
||||||
|
if idx == #MODULE_DATA then
|
||||||
|
return nil
|
||||||
|
else
|
||||||
|
return idx + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:initStageFormation()
|
function MainComp:initStageFormation()
|
||||||
@ -49,135 +165,11 @@ function MainComp:initStageFormation()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:refresh()
|
function MainComp:refresh()
|
||||||
self:refreshChapter()
|
|
||||||
self:refreshStageFormaion()
|
self:refreshStageFormaion()
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:onFightBtnClick()
|
|
||||||
ModuleManager.ChapterManager:startFight()
|
|
||||||
end
|
|
||||||
|
|
||||||
function MainComp:refreshChapter(force)
|
function MainComp:refreshChapter(force)
|
||||||
local chapterId = DataManager.ChapterData:getChapterId()
|
self.chapterComp:refreshChapter(force)
|
||||||
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
|
|
||||||
self.chapterImg:setTexture(string.format(CHAPTER_PATH, chapterInfo.icon))
|
|
||||||
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.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],
|
|
||||||
spineObj = self.uiMap["main_comp.chapter.progress_bg.spine_node.ui_spine_obj_" .. i],
|
|
||||||
boxIcon = self.uiMap["main_comp.chapter.progress_bg.box_" .. i .. ".box_icon"]
|
|
||||||
}
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
local mysteryBoxCount = DataManager.ChapterData:getChapterMysteryBoxRewardCount(chapterId)
|
|
||||||
local mysteryBoxIcon = self.uiMap["main_comp.chapter.img.mystery_box_icon"]
|
|
||||||
mysteryBoxIcon:setVisible(mysteryBoxCount > 0)
|
|
||||||
if mysteryBoxCount > 0 then
|
|
||||||
local gotCount = DataManager.ChapterData:getChapterMysteryBoxGotCount(chapterId)
|
|
||||||
self.uiMap["main_comp.chapter.img.mystery_box_icon.desc"]:setText(gotCount .. "/" .. mysteryBoxCount)
|
|
||||||
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", true, false, function()
|
|
||||||
objs.spineObj:setVisible(false)
|
|
||||||
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.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
|
||||||
local cost = DataManager.ChapterData:getFightCost()
|
|
||||||
if cost then
|
|
||||||
self.uiMap["main_comp.fight_btn.desc_2"]:setText(GFunc.getRewardNum(cost))
|
|
||||||
else
|
|
||||||
self.uiMap["main_comp.fight_btn.desc_2"]:setText("0")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function MainComp:refreshStageFormaion()
|
function MainComp:refreshStageFormaion()
|
||||||
|
|||||||
8
lua/app/userdata/daily_challenge.meta
Normal file
8
lua/app/userdata/daily_challenge.meta
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: bb475e2297dca58498f1e412443a2899
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
67
lua/app/userdata/daily_challenge/daily_challenge_data.lua
Normal file
67
lua/app/userdata/daily_challenge/daily_challenge_data.lua
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
local DailyChallengeData = class("DailyChallengeData", BaseData)
|
||||||
|
|
||||||
|
function DailyChallengeData:init(data)
|
||||||
|
-- 服务器的初始数据
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeData:clear()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeData:isOpen()
|
||||||
|
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DAILY_CHALLENGE, true)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 是否满足挑战条件
|
||||||
|
function DailyChallengeData:isMeetChallenge()
|
||||||
|
return self:isOpen() and self:isEnoughChallengeTime() and self:isEnoughHp()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 次数是否足够
|
||||||
|
function DailyChallengeData:isEnoughChallengeTime()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 体力是否足够
|
||||||
|
function DailyChallengeData:isEnoughHp()
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取今日挑战场景配置
|
||||||
|
function DailyChallengeData:getTodayConfig()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取今日挑战任务和奖励
|
||||||
|
function DailyChallengeData:getTodayTaskAndReward()
|
||||||
|
-- 三个任务需要区分类型,如:
|
||||||
|
-- 第一个:通关
|
||||||
|
-- 第二个:用xxx通关
|
||||||
|
-- 第三个:x回合杀怪、x颜色英雄技能释放几次
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取今日通关次数
|
||||||
|
function DailyChallengeData:getTodayPassNum()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取今日增益、负面buff
|
||||||
|
function DailyChallengeData:getTodayBuff()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取今日剩余时间
|
||||||
|
function DailyChallengeData:getTodaySurplusTime()
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 获取boss配置数据
|
||||||
|
function DailyChallengeData:getBossData(bossId)
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 任务是否完成
|
||||||
|
function DailyChallengeData:isTaskFinish(taskId)
|
||||||
|
-- body
|
||||||
|
end
|
||||||
|
|
||||||
|
return DailyChallengeData
|
||||||
@ -0,0 +1,10 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 8a47285265cc9b64798079b605d13684
|
||||||
|
ScriptedImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
|
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
||||||
Loading…
x
Reference in New Issue
Block a user