主界面
This commit is contained in:
parent
a2d6fcc50e
commit
4725d4ac06
@ -1,236 +1,240 @@
|
|||||||
local DailyChallengeManager = class("DailyChallengeManager", BaseModule)
|
local DailyChallengeManager = class("DailyChallengeManager", BaseModule)
|
||||||
|
|
||||||
function DailyChallengeManager:init()
|
function DailyChallengeManager:init()
|
||||||
self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(idx)
|
self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_CITY_PAGE, function(idx)
|
||||||
DataManager.DailyChallengeData:setShowingMainComp(idx == GConst.MainCityConst.BOTTOM_PAGE.MAIN)
|
DataManager.DailyChallengeData:setShowingMainComp(idx == GConst.MainCityConst.BOTTOM_PAGE.MAIN)
|
||||||
end)
|
end)
|
||||||
self:addEventListener(EventManager.CUSTOM_EVENT.UI_CLOSE, function(index)
|
self:addEventListener(EventManager.CUSTOM_EVENT.UI_CLOSE, function(index)
|
||||||
if index == UIManager.UI_PATH.MAINCITY_UI then
|
if index == UIManager.UI_PATH.MAINCITY_UI then
|
||||||
DataManager.DailyChallengeData:setShowingMainComp(false)
|
DataManager.DailyChallengeData:setShowingMainComp(false)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function DailyChallengeManager:showDailyChallengeUI()
|
||||||
|
UIManager:showUI("app/ui/battle/daily_challenge_ui")
|
||||||
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:showBattleBuffUI()
|
function DailyChallengeManager:showBattleBuffUI()
|
||||||
UIManager:showUI("app/ui/battle/battle_daily_challenge_buff_ui")
|
UIManager:showUI("app/ui/battle/battle_daily_challenge_buff_ui")
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:showBattleTaskUI()
|
function DailyChallengeManager:showBattleTaskUI()
|
||||||
UIManager:showUI("app/ui/daily_challenge/daily_challenge_task_ui")
|
UIManager:showUI("app/ui/daily_challenge/daily_challenge_task_ui")
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:getBuffDesc(id)
|
function DailyChallengeManager:getBuffDesc(id)
|
||||||
local desc = I18N:getText("buff_daily_challenge", id, "desc")
|
local desc = I18N:getText("buff_daily_challenge", id, "desc")
|
||||||
return desc
|
return desc
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:checkDayChange()
|
function DailyChallengeManager:checkDayChange()
|
||||||
if not DataManager.DailyChallengeData:getIfCanReset() then
|
if not DataManager.DailyChallengeData:getIfCanReset() then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if not DataManager.DailyChallengeData:isShowingMainComp() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if not DataManager.DailyChallengeData:isShowingMainComp() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 跨天了,请求新数据
|
-- 跨天了,请求新数据
|
||||||
self:performWithDelayGlobal(function()
|
self:performWithDelayGlobal(function()
|
||||||
self:onResetState()
|
self:onResetState()
|
||||||
end, math.random())
|
end, math.random())
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 开始挑战
|
-- 开始挑战
|
||||||
function DailyChallengeManager:startChallenge()
|
function DailyChallengeManager:startChallenge()
|
||||||
-- 判断次数
|
-- 判断次数
|
||||||
if not DataManager.DailyChallengeData:isEnoughChallengeTime() then
|
if not DataManager.DailyChallengeData:isEnoughChallengeTime() then
|
||||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 判断体力
|
-- 判断体力
|
||||||
if not DataManager.DailyChallengeData:isEnoughHp() then
|
if not DataManager.DailyChallengeData:isEnoughHp() then
|
||||||
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
|
||||||
ModuleManager.CommerceManager:showBuyVitUI()
|
ModuleManager.CommerceManager:showBuyVitUI()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 检查阵容
|
-- 检查阵容
|
||||||
if not DataManager.FormationData:formationIsFull(GConst.BattleConst.FORMATION_TYPE.STAGE) then
|
if not DataManager.FormationData:formationIsFull(GConst.BattleConst.FORMATION_TYPE.STAGE) then
|
||||||
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8))
|
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.BATTLE_DESC_8))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
if not DataManager.DailyChallengeData:isMeetChallenge() then
|
if not DataManager.DailyChallengeData:isMeetChallenge() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local parmas = {}
|
local parmas = {}
|
||||||
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE)
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:rspStartChallenge(result)
|
function DailyChallengeManager:rspStartChallenge(result)
|
||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
DataManager.DailyChallengeData:onFightCountReduce()
|
DataManager.DailyChallengeData:onFightCountReduce()
|
||||||
DataManager.DailyChallengeData:setFixedChapterId(result.today_fixed_chapter_id)
|
DataManager.DailyChallengeData:setFixedChapterId(result.today_fixed_chapter_id)
|
||||||
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE)
|
ModuleManager.BattleManager:playBattle(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 挑战结束
|
-- 挑战结束
|
||||||
function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgress, heroInfo, taskCurProgress)
|
function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgress, heroInfo, taskCurProgress)
|
||||||
local parmas = {
|
local parmas = {
|
||||||
win = combatReport.victory,
|
win = combatReport.victory,
|
||||||
chapter_id = chapterId,
|
chapter_id = chapterId,
|
||||||
hero_info = heroInfo,
|
hero_info = heroInfo,
|
||||||
task_stat = taskProgress,
|
task_stat = taskProgress,
|
||||||
combatReport = combatReport,
|
combatReport = combatReport,
|
||||||
taskCurProgress = taskCurProgress
|
taskCurProgress = taskCurProgress
|
||||||
}
|
}
|
||||||
|
|
||||||
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeSettlementReq, parmas, {}, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END)
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeSettlementReq, parmas, {}, self.endChallengeFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_END)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:endChallengeFinish(result)
|
function DailyChallengeManager:endChallengeFinish(result)
|
||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
if not result.reqData then
|
if not result.reqData then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local reqData = result.reqData
|
local reqData = result.reqData
|
||||||
local rewards = result.rewards
|
local rewards = result.rewards
|
||||||
ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, rewards, reqData.combatReport)
|
ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DAILY_CHALLENGE, rewards, reqData.combatReport)
|
||||||
DataManager.DailyChallengeData:init(result.daily_challenge)
|
DataManager.DailyChallengeData:init(result.daily_challenge)
|
||||||
ModuleManager.TaskManager:addFightTaskProgress(reqData.task_stat)
|
ModuleManager.TaskManager:addFightTaskProgress(reqData.task_stat)
|
||||||
|
|
||||||
-- bi日志上报任务完成情况
|
-- bi日志上报任务完成情况
|
||||||
local taskProgress = reqData.taskCurProgress or {}
|
local taskProgress = reqData.taskCurProgress or {}
|
||||||
local completedCount = 0
|
local completedCount = 0
|
||||||
local taskInfo = {}
|
local taskInfo = {}
|
||||||
local tasks = DataManager.DailyChallengeData:getTasks()
|
local tasks = DataManager.DailyChallengeData:getTasks()
|
||||||
for index, info in ipairs(tasks) do
|
for index, info in ipairs(tasks) do
|
||||||
local id = info.task_id
|
local id = info.task_id
|
||||||
local idStr = tostring(id)
|
local idStr = tostring(id)
|
||||||
taskInfo[idStr] = GFunc.getTable(info)
|
taskInfo[idStr] = GFunc.getTable(info)
|
||||||
taskInfo[idStr].curProgress = 0
|
taskInfo[idStr].curProgress = 0
|
||||||
local progress = taskProgress[id]
|
local progress = taskProgress[id]
|
||||||
if progress then
|
if progress then
|
||||||
if type(progress) == "table" then
|
if type(progress) == "table" then
|
||||||
taskInfo[idStr].curProgress = progress[info.param] or 0
|
taskInfo[idStr].curProgress = progress[info.param] or 0
|
||||||
else
|
else
|
||||||
taskInfo[idStr].curProgress = progress
|
taskInfo[idStr].curProgress = progress
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if info.claimed or DataManager.DailyChallengeData:canClaimTask(index) then
|
if info.claimed or DataManager.DailyChallengeData:canClaimTask(index) then
|
||||||
completedCount = completedCount + 1
|
completedCount = completedCount + 1
|
||||||
if taskInfo[idStr].curProgress < (taskInfo[idStr].progress or 0) then
|
if taskInfo[idStr].curProgress < (taskInfo[idStr].progress or 0) then
|
||||||
taskInfo[idStr].curProgress = taskInfo[idStr].progress or 0
|
taskInfo[idStr].curProgress = taskInfo[idStr].progress or 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
BIReport:postDailyChallengeTaskState(completedCount, taskInfo)
|
BIReport:postDailyChallengeTaskState(completedCount, taskInfo)
|
||||||
|
|
||||||
if result.reqData.win then
|
if result.reqData.win then
|
||||||
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_DAILY_CHALLENGE_SUCCESS)
|
ModuleManager.TaskManager:addTaskProgress(GConst.TaskConst.TASK_TYPE.X_DAILY_CHALLENGE_SUCCESS)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:onResetState()
|
function DailyChallengeManager:onResetState()
|
||||||
if not DataManager.DailyChallengeData:isOpen() then
|
if not DataManager.DailyChallengeData:isOpen() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if DataManager.DailyChallengeData:getIsInReset() then
|
if DataManager.DailyChallengeData:getIsInReset() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
DataManager.DailyChallengeData:setInReset(true)
|
DataManager.DailyChallengeData:setInReset(true)
|
||||||
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, {}, {}, self.rspResetState, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET)
|
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, {}, {}, self.rspResetState, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:rspResetState(result)
|
function DailyChallengeManager:rspResetState(result)
|
||||||
DataManager.DailyChallengeData:setInReset(false)
|
DataManager.DailyChallengeData:setInReset(false)
|
||||||
DataManager.DailyChallengeData:init(result.daily_challenge)
|
DataManager.DailyChallengeData:init(result.daily_challenge)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- 获取任务(箱子)奖励
|
-- 获取任务(箱子)奖励
|
||||||
function DailyChallengeManager:getTaskReward(idx)
|
function DailyChallengeManager:getTaskReward(idx)
|
||||||
self.getRewardTaskIdx = idx
|
self.getRewardTaskIdx = idx
|
||||||
local parmas = {
|
local parmas = {
|
||||||
idx = idx,
|
idx = idx,
|
||||||
}
|
}
|
||||||
self:sendMessage(ProtoMsgType.FromMsgEnum.DailyChallengeTaskAwardReq, parmas, {}, self.getTaskRewardFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_TASK_REWARD)
|
self:sendMessage(ProtoMsgType.FromMsgEnum.DailyChallengeTaskAwardReq, parmas, {}, self.getTaskRewardFinish, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_TASK_REWARD)
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:getTaskRewardFinish(result)
|
function DailyChallengeManager:getTaskRewardFinish(result)
|
||||||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||||||
GFunc.showRewardBox(result.rewards)
|
GFunc.showRewardBox(result.rewards)
|
||||||
DataManager.DailyChallengeData:onGetedTaskReward(self.getRewardTaskIdx)
|
DataManager.DailyChallengeData:onGetedTaskReward(self.getRewardTaskIdx)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:dealTaskProgress(battleController)
|
function DailyChallengeManager:dealTaskProgress(battleController)
|
||||||
local teamEntity = battleController.battleData:getAtkTeam()
|
local teamEntity = battleController.battleData:getAtkTeam()
|
||||||
local members = teamEntity:getAllMembers()
|
local members = teamEntity:getAllMembers()
|
||||||
local heroInfo = {}
|
local heroInfo = {}
|
||||||
for k, v in pairs(members) do
|
for k, v in pairs(members) do
|
||||||
heroInfo[v:getId()] = {
|
heroInfo[v:getId()] = {
|
||||||
skill_cast = v:getActiveSkillReleaseCount(),
|
skill_cast = v:getActiveSkillReleaseCount(),
|
||||||
Damage = v:getDamageCount(),
|
Damage = v:getDamageCount(),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local comboOver10Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.COMBO_OVER_10]
|
local comboOver10Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.COMBO_OVER_10]
|
||||||
local linkCountOver8Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.LINK_COUNT_OVER_8]
|
local linkCountOver8Count = battleController.taskProgress[GConst.BattleConst.BATTLE_TASK_FIELD.LINK_COUNT_OVER_8]
|
||||||
|
|
||||||
local skillCountMap = {}
|
local skillCountMap = {}
|
||||||
local damageMatchTypeMap = {}
|
local damageMatchTypeMap = {}
|
||||||
local damageHeroMap = {}
|
local damageHeroMap = {}
|
||||||
local totalDmg = 0
|
local totalDmg = 0
|
||||||
for heroId, info in pairs(heroInfo) do
|
for heroId, info in pairs(heroInfo) do
|
||||||
local entity = DataManager.HeroData:getHeroById(heroId)
|
local entity = DataManager.HeroData:getHeroById(heroId)
|
||||||
if entity then
|
if entity then
|
||||||
skillCountMap[entity:getMatchType()] = info.skill_cast
|
skillCountMap[entity:getMatchType()] = info.skill_cast
|
||||||
damageMatchTypeMap[entity:getMatchType()] = info.Damage
|
damageMatchTypeMap[entity:getMatchType()] = info.Damage
|
||||||
damageHeroMap[heroId] = info.Damage
|
damageHeroMap[heroId] = info.Damage
|
||||||
totalDmg = totalDmg + info.Damage
|
totalDmg = totalDmg + info.Damage
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if totalDmg <= 0 then
|
if totalDmg <= 0 then
|
||||||
totalDmg = 1
|
totalDmg = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
for matchType, damage in pairs(damageMatchTypeMap) do
|
for matchType, damage in pairs(damageMatchTypeMap) do
|
||||||
damageMatchTypeMap[matchType] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001)
|
damageMatchTypeMap[matchType] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001)
|
||||||
end
|
end
|
||||||
|
|
||||||
for heroId, damage in pairs(damageHeroMap) do
|
for heroId, damage in pairs(damageHeroMap) do
|
||||||
damageHeroMap[heroId] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001)
|
damageHeroMap[heroId] = math.floor(damage / totalDmg * GConst.BattleConst.DEFAULT_FACTOR + 0.000001)
|
||||||
end
|
end
|
||||||
|
|
||||||
local taskProgress = {
|
local taskProgress = {
|
||||||
[3] = comboOver10Count,
|
[3] = comboOver10Count,
|
||||||
[4] = linkCountOver8Count,
|
[4] = linkCountOver8Count,
|
||||||
[5] = skillCountMap,
|
[5] = skillCountMap,
|
||||||
[7] = damageHeroMap,
|
[7] = damageHeroMap,
|
||||||
[8] = damageMatchTypeMap
|
[8] = damageMatchTypeMap
|
||||||
}
|
}
|
||||||
return taskProgress
|
return taskProgress
|
||||||
end
|
end
|
||||||
|
|
||||||
function DailyChallengeManager:getCurTaskProgress(battleController)
|
function DailyChallengeManager:getCurTaskProgress(battleController)
|
||||||
local taskCurProgress ={}
|
local taskCurProgress ={}
|
||||||
local taskProgress = self:dealTaskProgress(battleController)
|
local taskProgress = self:dealTaskProgress(battleController)
|
||||||
local tasks = DataManager.DailyChallengeData:getTasks()
|
local tasks = DataManager.DailyChallengeData:getTasks()
|
||||||
for index, info in ipairs(tasks) do
|
for index, info in ipairs(tasks) do
|
||||||
local id = info.task_id
|
local id = info.task_id
|
||||||
local progress = taskProgress[id]
|
local progress = taskProgress[id]
|
||||||
if progress then
|
if progress then
|
||||||
if type(progress) == "table" then
|
if type(progress) == "table" then
|
||||||
taskCurProgress[id] = progress[info.param] or 0
|
taskCurProgress[id] = progress[info.param] or 0
|
||||||
else
|
else
|
||||||
taskCurProgress[id] = progress
|
taskCurProgress[id] = progress
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return taskCurProgress
|
return taskCurProgress
|
||||||
end
|
end
|
||||||
|
|
||||||
return DailyChallengeManager
|
return DailyChallengeManager
|
||||||
@ -16,19 +16,6 @@ MainCityConst.BOTTOM_ICON = {
|
|||||||
MainCityConst.BOTTOM_CLOSE_ICON = {
|
MainCityConst.BOTTOM_CLOSE_ICON = {
|
||||||
}
|
}
|
||||||
|
|
||||||
-- main界面模块
|
|
||||||
MainCityConst.MAIN_MODULE = {
|
|
||||||
-- 左侧模块,负数,绝对值升序
|
|
||||||
ARENA = -1,
|
|
||||||
DAILY_CHALLENGE = -2,
|
|
||||||
|
|
||||||
-- 主模块
|
|
||||||
CHAPTER = 0,
|
|
||||||
|
|
||||||
-- 右侧模块,正数,绝对值升序
|
|
||||||
DUNGEON = 1,
|
|
||||||
}
|
|
||||||
|
|
||||||
MainCityConst.LEFT_SIDE_BARS = {
|
MainCityConst.LEFT_SIDE_BARS = {
|
||||||
"app/ui/main_city/cell/side_bar_idle_cell",
|
"app/ui/main_city/cell/side_bar_idle_cell",
|
||||||
"app/ui/main_city/cell/side_bar_growth_fund_cell",
|
"app/ui/main_city/cell/side_bar_growth_fund_cell",
|
||||||
|
|||||||
@ -99,16 +99,4 @@ function MaincityManager:isActivSideBarModule(moduleKey)
|
|||||||
return mainUI:isActivSideBarModule(moduleKey)
|
return mainUI:isActivSideBarModule(moduleKey)
|
||||||
end
|
end
|
||||||
|
|
||||||
function MaincityManager:setCurModule(moduleKey)
|
|
||||||
self.curModule = moduleKey
|
|
||||||
end
|
|
||||||
|
|
||||||
function MaincityManager:getCurModule()
|
|
||||||
if not self.curModule then
|
|
||||||
-- 默认进主线章节
|
|
||||||
return GConst.MainCityConst.MAIN_MODULE.CHAPTER
|
|
||||||
end
|
|
||||||
return self.curModule
|
|
||||||
end
|
|
||||||
|
|
||||||
return MaincityManager
|
return MaincityManager
|
||||||
159
lua/app/ui/daily_challenge/daily_challenge_ui.lua
Normal file
159
lua/app/ui/daily_challenge/daily_challenge_ui.lua
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
local DailyChallengeUI = class("DailyChallengeUI", BaseUI)
|
||||||
|
|
||||||
|
function DailyChallengeUI:getIsOpen()
|
||||||
|
return DataManager.DailyChallengeData:isOpen()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:getEntranceName()
|
||||||
|
return I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:getShowEntranceRedPoint()
|
||||||
|
return DataManager.DailyChallengeData:isMeetChallenge()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:onClickFight()
|
||||||
|
ModuleManager.DailyChallengeManager:startChallenge()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:ctor()
|
||||||
|
ModuleManager.DailyChallengeManager:checkDayChange()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:onLoadRootComplete()
|
||||||
|
local uiMap = self.root:genAllChildren()
|
||||||
|
|
||||||
|
uiMap["daily_challenge_ui.title.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE))
|
||||||
|
uiMap["daily_challenge_ui.record_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.DailyChallengeData:getMaxWave()))
|
||||||
|
|
||||||
|
self.tasks = GFunc.getTable()
|
||||||
|
table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task1"])
|
||||||
|
table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task2"])
|
||||||
|
table.insert(self.tasks, uiMap["daily_challenge_ui.challenge.task.icon_task3"])
|
||||||
|
|
||||||
|
self.buffObj = uiMap["daily_challenge_ui.challenge.buffs.buff.btn_buff"]
|
||||||
|
self.debuffObj = uiMap["daily_challenge_ui.challenge.buffs.debuff.btn_debuff"]
|
||||||
|
self.bossSpine = uiMap["daily_challenge_ui.challenge.spine_node"]
|
||||||
|
self.countdownTx = uiMap["daily_challenge_ui.challenge.info.countdown.time_tx"]
|
||||||
|
|
||||||
|
self.fightBtn = uiMap["daily_challenge_ui.fight_btn"]
|
||||||
|
-- 体力消耗
|
||||||
|
self.fightCost = uiMap["daily_challenge_ui.fight_btn.cost"]
|
||||||
|
self.costTxDesc = uiMap["daily_challenge_ui.fight_btn.cost.tx_desc"]
|
||||||
|
self.costTxCost = uiMap["daily_challenge_ui.fight_btn.cost.tx_cost"]
|
||||||
|
-- 剩余次数
|
||||||
|
self.countTxNum = uiMap["daily_challenge_ui.fight_btn.tx_count"]
|
||||||
|
-- 按钮文本
|
||||||
|
self.txFight = uiMap["daily_challenge_ui.fight_btn.tx_desc"]
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function DailyChallengeUI:updateTime()
|
||||||
|
ModuleManager.DailyChallengeManager:checkDayChange()
|
||||||
|
local remainTime = Time:getTodaySurplusTime()
|
||||||
|
self.countdownTx:setText(GFunc.getTimeStrWithHMS(remainTime))
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:onRefresh()
|
||||||
|
self:refreshTask()
|
||||||
|
self:refreshBuff()
|
||||||
|
self:refreshBoss()
|
||||||
|
self:updateTime()
|
||||||
|
self:refreshFightBtn()
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:refreshTask()
|
||||||
|
local tasksData = DataManager.DailyChallengeData:getTasks()
|
||||||
|
for i = 1, #self.tasks do
|
||||||
|
local taskObj = self.tasks[i]
|
||||||
|
if DataManager.DailyChallengeData:canClaimTask(i) then
|
||||||
|
-- 任务奖励可领取
|
||||||
|
taskObj:addRedPoint(30, 30, 0.6)
|
||||||
|
taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1")
|
||||||
|
else
|
||||||
|
-- 任务奖励不可领取
|
||||||
|
taskObj:removeRedPoint()
|
||||||
|
if not DataManager.DailyChallengeData:isTaskFinish(i) then
|
||||||
|
taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1")
|
||||||
|
else
|
||||||
|
taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_2")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
taskObj:addClickListener(function()
|
||||||
|
if DataManager.DailyChallengeData:canClaimTask(i) then
|
||||||
|
ModuleManager.DailyChallengeManager:getTaskReward(i)
|
||||||
|
else
|
||||||
|
local rewards = DataManager.DailyChallengeData:getTaskRewards(tasksData[i].task_id)
|
||||||
|
local desc = DataManager.DailyChallengeData:getTaskDesc(tasksData[i].task_id)
|
||||||
|
ModuleManager.TipsManager:showRewardsTips(rewards, desc, taskObj, nil, nil, false, ModuleManager.TipsManager.REWARDS_TIPS_TYPE.TASK)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:refreshBuff()
|
||||||
|
local buffIds = DataManager.DailyChallengeData:getTodayBuffIds()
|
||||||
|
self.buffObj:addClickListener(function()
|
||||||
|
ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[1]), self.buffObj)
|
||||||
|
end)
|
||||||
|
|
||||||
|
self.debuffObj:addClickListener(function()
|
||||||
|
ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[2]), self.debuffObj)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function DailyChallengeUI:refreshBoss()
|
||||||
|
local curBossInfo = DataManager.DailyChallengeData:getFinalBossInfo()
|
||||||
|
if not curBossInfo then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.curModelId == curBossInfo.model_id then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.spineBoss then
|
||||||
|
self.spineBoss:destroy()
|
||||||
|
self.spineBoss = nil
|
||||||
|
self.curModelId = nil
|
||||||
|
end
|
||||||
|
self.curModelId = curBossInfo.model_id
|
||||||
|
SpineManager:loadHeroAsync(self.curModelId, self.bossSpine, function(spineObject)
|
||||||
|
self.spineBoss = spineObject
|
||||||
|
self.spineBoss:setDefaultMix(0)
|
||||||
|
self.spineBoss:setLocalScale(curBossInfo.model_ui, curBossInfo.model_ui, curBossInfo.model_ui)
|
||||||
|
self.spineBoss:playAnimation(GConst.BattleConst.SPINE_ANIMATION_NAME.IDLE, true, false)
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function MainComp:refreshFightBtn()
|
||||||
|
local isShowFight = false
|
||||||
|
|
||||||
|
-- 体力消耗
|
||||||
|
local cost = DataManager.DailyChallengeData:getChallengeHpCost()
|
||||||
|
if cost then
|
||||||
|
isShowFight = true
|
||||||
|
self.fightCost:setActive(true)
|
||||||
|
self.costTxDesc:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC))
|
||||||
|
self.costTxCost:setText(GFunc.getRewardNum(cost))
|
||||||
|
else
|
||||||
|
self.fightCost:setActive(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 剩余次数
|
||||||
|
local remainCount = DataManager.DailyChallengeData:getTodayRemainLimitCount()
|
||||||
|
if remainCount >= 0 then
|
||||||
|
isShowFight = true
|
||||||
|
self.countTxNum:setActive(true)
|
||||||
|
self.countTxNum:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, remainCount))
|
||||||
|
else
|
||||||
|
self.countTxNum:setActive(false)
|
||||||
|
end
|
||||||
|
|
||||||
|
if isShowFight then
|
||||||
|
self.fightBtn:setActive(true)
|
||||||
|
self.fightBtn:addClickListener(moduleCell.onClickFight)
|
||||||
|
else
|
||||||
|
self.fightBtn:setActive(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return DailyChallengeUI
|
||||||
@ -1,711 +0,0 @@
|
|||||||
local ChapterCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell"
|
|
||||||
local ChapterComp = class("ChapterComp", ChapterCompBaseCell)
|
|
||||||
|
|
||||||
local UISpineObject = require "app/bf/unity/ui_spine_object"
|
|
||||||
|
|
||||||
-- local CHAPTER_PATH = "assets/arts/textures/background/chapter/%s.png"
|
|
||||||
local HERO_SPINE_ASSET_PATH = "assets/arts/spines/characters/%s/%s_skeletondata.asset"
|
|
||||||
local CHAPTER_PATH = "assets/arts/textures/background/main/%s.png"
|
|
||||||
|
|
||||||
local BOX_ICON = {
|
|
||||||
"common_chest_1",
|
|
||||||
"common_chest_4"
|
|
||||||
}
|
|
||||||
|
|
||||||
function ChapterComp:getIsOpen()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:getEntranceName()
|
|
||||||
return I18N:getGlobalText(I18N.GlobalConst.MAIN_CHAPTER)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:isShowTopNode()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:isShowSideBar()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:isShowBounty()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:isShowHeroFormation()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:getFightHpCost()
|
|
||||||
return DataManager.ChapterData:getFightCost()
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:onClickFight()
|
|
||||||
ModuleManager.ChapterManager:startFight()
|
|
||||||
end
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
self.chapterBg = self.uiMap["chapter_comp.bg"]
|
|
||||||
self.chapterBg:setAnchoredPositionX(-720)
|
|
||||||
self.bossSmoke = self.uiMap["chapter_comp.boss_smoke"]
|
|
||||||
self.bossSmoke:setAnchoredPositionX(10000)
|
|
||||||
self.smokeNodeTop = self.uiMap["chapter_comp.smoke_node_1"]
|
|
||||||
self.monsterNodeTop = self.uiMap["chapter_comp.monster_node_1"]
|
|
||||||
self.bossNode = self.uiMap["chapter_comp.boss_node"]
|
|
||||||
self.bossNode:setActive(false)
|
|
||||||
self.bossSpine = self.uiMap["chapter_comp.boss_node.boss"]
|
|
||||||
self.smokeNodeDown = self.uiMap["chapter_comp.smoke_node_2"]
|
|
||||||
self.monsterNodeDown = self.uiMap["chapter_comp.monster_node_2"]
|
|
||||||
self.dialogueTx = self.uiMap["chapter_comp.dialogue_node.bg.text"]
|
|
||||||
self.dialogueBg = self.uiMap["chapter_comp.dialogue_node.bg"]
|
|
||||||
self.dialogueNode = self.uiMap["chapter_comp.dialogue_node"]
|
|
||||||
self.dialogueNode:setAnchoredPositionX(0)
|
|
||||||
self.monsterSpineTopPool = {}
|
|
||||||
self.monsterSpineDownPool = {}
|
|
||||||
self.monsterSpineTopList = {}
|
|
||||||
self.monsterSpineDownList = {}
|
|
||||||
-- self.monsterShadowPool = {}
|
|
||||||
self.monsterSmokePool = {}
|
|
||||||
self.startMonsterAction = true
|
|
||||||
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
|
|
||||||
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["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 mysteryBoxBg = self.uiMap["chapter_comp.img.bg"]
|
|
||||||
mysteryBoxBg:setVisible(mysteryBoxCount > 0)
|
|
||||||
local mysteryBoxIcon = self.uiMap["chapter.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["chapter.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:refreshFightBtn()
|
|
||||||
self:doBossAction()
|
|
||||||
end
|
|
||||||
self:doChapterMove()
|
|
||||||
self:doMonsterAction()
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp: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 ChapterComp: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
|
|
||||||
|
|
||||||
-- region 动画
|
|
||||||
function ChapterComp:doChapterMove()
|
|
||||||
if self.chapterMoveSeq then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.chapterBg:setAnchoredPositionX(-720)
|
|
||||||
self.chapterMoveSeq = self.chapterBg:createBindTweenSequence()
|
|
||||||
local moveTween = self.chapterBg:getTransform():DOAnchorPosX(720, 20):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
self.chapterMoveSeq:Append(moveTween)
|
|
||||||
self.chapterMoveSeq:AppendCallback(function()
|
|
||||||
self.chapterBg:setAnchoredPositionX(-720)
|
|
||||||
end)
|
|
||||||
self.chapterMoveSeq:SetLoops(-1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:doBossAction()
|
|
||||||
if self.currChapterId == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local chapterInfo = ConfigManager:getConfig("chapter")[self.currChapterId]
|
|
||||||
if chapterInfo == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local monsterIdList = chapterInfo.monster_id
|
|
||||||
monsterIdList = {20001, 10001, 10002}
|
|
||||||
if monsterIdList == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.chapterMonsterShowList = monsterIdList
|
|
||||||
if self.chapterBossId == nil then -- 还没显示boss模型
|
|
||||||
self.chapterBossId = self.chapterMonsterShowList[1]
|
|
||||||
local chapterBossId = self.chapterBossId
|
|
||||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
|
||||||
local monsterInfo = monsterCfg[self.chapterBossId]
|
|
||||||
if monsterInfo then
|
|
||||||
local modelId = monsterInfo.model_id
|
|
||||||
local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId)
|
|
||||||
self.bossNode:setActive(false)
|
|
||||||
local scale = monsterInfo.ui or 1
|
|
||||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
|
||||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
|
||||||
-- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
|
||||||
-- self.bossShadow:setAnchoredPosition(10000, shadowOffset)
|
|
||||||
self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
|
||||||
self.bossSmoke:setAnchoredPositionX(10000)
|
|
||||||
self.bossSpine:loadAssetAsync(modelId, function()
|
|
||||||
if chapterBossId == self.chapterBossId then
|
|
||||||
self.bossNode:setActive(true)
|
|
||||||
self.bossSpine:setLocalScale(-scale, scale, scale)
|
|
||||||
self.bossSpine:playAnim("move", true, true, true)
|
|
||||||
-- self.bossShadow:setAnchoredPositionX(0)
|
|
||||||
self.bossSmoke:playAnim("idle", true, true, true)
|
|
||||||
self.bossSmoke:setAnchoredPositionX(0)
|
|
||||||
else -- 加载完成后,已经切换到其他boss了
|
|
||||||
self:doChangeBossAction()
|
|
||||||
end
|
|
||||||
end, path)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local chapterBossId = self.chapterMonsterShowList[1]
|
|
||||||
if self.chapterBossId ~= chapterBossId then
|
|
||||||
self.chapterBossId = chapterBossId
|
|
||||||
self:doChangeBossAction()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- 切换boss
|
|
||||||
function ChapterComp:doChangeBossAction()
|
|
||||||
local chapterBossId = self.chapterBossId
|
|
||||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
|
||||||
local monsterInfo = monsterCfg[self.chapterBossId]
|
|
||||||
if monsterInfo then
|
|
||||||
local modelId = monsterInfo.model_id
|
|
||||||
local path = string.format(HERO_SPINE_ASSET_PATH, modelId, modelId)
|
|
||||||
self.bossNode:setActive(false)
|
|
||||||
local scale = monsterInfo.ui or 1
|
|
||||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
|
||||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
|
||||||
-- self.bossShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
|
||||||
-- self.bossShadow:setAnchoredPosition(10000, shadowOffset)
|
|
||||||
self.bossSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
|
||||||
self.bossSmoke:setAnchoredPositionX(10000)
|
|
||||||
self.bossSpine:loadAssetAsync(modelId, function()
|
|
||||||
if chapterBossId == self.chapterBossId then
|
|
||||||
self.bossNode:setActive(true)
|
|
||||||
self.bossSpine:setLocalScale(-scale, scale, scale)
|
|
||||||
self.bossSpine:playAnim("move", true, true, true)
|
|
||||||
-- self.bossShadow:setAnchoredPositionX(0)
|
|
||||||
self.bossSmoke:playAnim("idle", true, true, true)
|
|
||||||
self.bossSmoke:setAnchoredPositionX(0)
|
|
||||||
else -- 加载完成后,已经切换到其他boss了
|
|
||||||
self:doChangeBossAction()
|
|
||||||
end
|
|
||||||
end, path)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:doMonsterAction()
|
|
||||||
if self.chapterMonsterGenerateSeq then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self.chapterMonsterGenerateSeq = DOTweenManager:createSeqWithIntId()
|
|
||||||
local interval = GFunc.getConstValue("chapter_idel_monster_x") / 1000
|
|
||||||
interval = 2
|
|
||||||
self.chapterMonsterGenerateSeq:AppendCallback(function()
|
|
||||||
self:generateChapterMonsters()
|
|
||||||
end)
|
|
||||||
self.chapterMonsterGenerateSeq:AppendInterval(interval)
|
|
||||||
self.chapterMonsterGenerateSeq:SetLoops(-1)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:generateChapterMonsters()
|
|
||||||
local monsterId
|
|
||||||
if #self.chapterMonsterShowList <= 2 then
|
|
||||||
monsterId = self.chapterMonsterShowList[2]
|
|
||||||
else
|
|
||||||
monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)]
|
|
||||||
end
|
|
||||||
if monsterId == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
|
||||||
local monsterInfo = monsterCfg[monsterId]
|
|
||||||
if monsterInfo == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.isTopTurn == nil then
|
|
||||||
self.isTopTurn = math.random(1, 100) > 50
|
|
||||||
end
|
|
||||||
local modelId = monsterInfo.model_id
|
|
||||||
local pool
|
|
||||||
local list
|
|
||||||
local parent
|
|
||||||
local posY
|
|
||||||
if self.isTopTurn then -- 刷上面
|
|
||||||
pool = self.monsterSpineTopPool[modelId]
|
|
||||||
list = self.monsterSpineTopList
|
|
||||||
parent = self.monsterNodeTop
|
|
||||||
posY = math.random(1, 300)
|
|
||||||
else -- 刷下面
|
|
||||||
pool = self.monsterSpineDownPool[modelId]
|
|
||||||
list = self.monsterSpineDownList
|
|
||||||
parent = self.monsterNodeDown
|
|
||||||
posY = -math.random(1, 240)
|
|
||||||
end
|
|
||||||
self.isTopTurn = not self.isTopTurn
|
|
||||||
if pool and #pool > 0 then
|
|
||||||
local spine = table.remove(pool)
|
|
||||||
table.insert(list, spine)
|
|
||||||
spine:setActive(true)
|
|
||||||
self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
|
||||||
else
|
|
||||||
SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine)
|
|
||||||
if not self.startMonsterAction then
|
|
||||||
spine:destroy()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
table.insert(list, spine)
|
|
||||||
local scale = monsterInfo.ui or 1
|
|
||||||
spine:setLocalScale(-scale, scale, scale)
|
|
||||||
self:doMonsterMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:doMonsterMove(modelId, spine, posY, monsterInfo, isTopTurn)
|
|
||||||
spine:playAnim("move", true, true, true)
|
|
||||||
local posX = GConst.UI_SCREEN_WIDTH / 2 + 100
|
|
||||||
local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300
|
|
||||||
spine:setAnchoredPosition(posX, posY)
|
|
||||||
local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
|
||||||
if self.chapterMonsterSpeed == nil then
|
|
||||||
-- self.chapterMonsterSpeed = GFunc.getConstValue("chapter_idel_monstermove")
|
|
||||||
self.chapterMonsterSpeed = 150
|
|
||||||
end
|
|
||||||
local distance = posX - targetPosX
|
|
||||||
local moveTime = distance / self.chapterMonsterSpeed
|
|
||||||
local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
seq:Append(moveTween)
|
|
||||||
|
|
||||||
-- local monsterShadow = self:getMonsterShadow()
|
|
||||||
local scale = monsterInfo.ui or 1
|
|
||||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
|
||||||
-- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
|
||||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
|
||||||
-- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset)
|
|
||||||
-- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
-- seq:Join(moveTween2)
|
|
||||||
|
|
||||||
local monsterSmoke = self:getMonsterSmoke(isTopTurn)
|
|
||||||
monsterSmoke:setAnchoredPosition(posX, posY)
|
|
||||||
monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
|
||||||
monsterSmoke:playAnim("idle", true, true, true)
|
|
||||||
local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
seq:Join(moveTween3)
|
|
||||||
|
|
||||||
seq:AppendCallback(function()
|
|
||||||
spine:setActive(false)
|
|
||||||
-- monsterShadow:setAnchoredPositionX(10000)
|
|
||||||
-- table.insert(self.monsterShadowPool, monsterShadow)
|
|
||||||
monsterSmoke:setAnchoredPositionX(10000)
|
|
||||||
table.insert(self.monsterSmokePool, monsterSmoke)
|
|
||||||
if isTopTurn then
|
|
||||||
local pool = self.monsterSpineTopPool[modelId]
|
|
||||||
if pool == nil then
|
|
||||||
pool = {}
|
|
||||||
self.monsterSpineTopPool[modelId] = pool
|
|
||||||
end
|
|
||||||
table.insert(pool, spine)
|
|
||||||
for k, v in ipairs(self.monsterSpineTopList) do
|
|
||||||
if v == spine then
|
|
||||||
table.remove(self.monsterSpineTopList, k)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local pool = self.monsterSpineDownPool[modelId]
|
|
||||||
if pool == nil then
|
|
||||||
pool = {}
|
|
||||||
self.monsterSpineDownPool[modelId] = pool
|
|
||||||
end
|
|
||||||
table.insert(pool, spine)
|
|
||||||
for k, v in ipairs(self.monsterSpineDownList) do
|
|
||||||
if v == spine then
|
|
||||||
table.remove(self.monsterSpineDownList, k)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:enterChapterBattle()
|
|
||||||
-- boss等一会再跑
|
|
||||||
local bossWaitTime = GFunc.getConstValue("chapter_fight_bosswait") / 1000
|
|
||||||
local bossSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
|
||||||
bossSeq:AppendInterval(bossWaitTime)
|
|
||||||
local bossSpeed = GFunc.getConstValue("chapter_fight_bossmove")
|
|
||||||
local distance = GConst.UI_SCREEN_WIDTH/2 + 100
|
|
||||||
local moveTime = distance / bossSpeed
|
|
||||||
local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 300
|
|
||||||
local moveTween = self.bossNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
bossSeq:Append(moveTween)
|
|
||||||
local moveTween2 = self.dialogueNode:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
bossSeq:Join(moveTween2)
|
|
||||||
-- local moveTween3 = self.bossShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
-- bossSeq:Join(moveTween3)
|
|
||||||
|
|
||||||
|
|
||||||
-- 出来一批小怪从右边跑向左边
|
|
||||||
local monsterCount = GFunc.getConstIntValue("chapter_fight_monster_num")
|
|
||||||
self.chapterFightMonsterCount = monsterCount
|
|
||||||
local wave = 5
|
|
||||||
local monsterCountPerWave = math.ceil(monsterCount / wave)
|
|
||||||
-- 分批处理
|
|
||||||
local monsterSeq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
|
||||||
for i = 1, wave do
|
|
||||||
monsterSeq:AppendCallback(function ()
|
|
||||||
if monsterCountPerWave > monsterCount then
|
|
||||||
monsterCountPerWave = monsterCount
|
|
||||||
end
|
|
||||||
monsterCount = monsterCount - monsterCountPerWave
|
|
||||||
for j = 1, monsterCountPerWave do
|
|
||||||
self:generateChapterFightMonsters()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
monsterSeq:AppendInterval(0.03)
|
|
||||||
end
|
|
||||||
return GFunc.getConstValue("chapter_fight_wait") / 1000
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:generateChapterFightMonsters()
|
|
||||||
local monsterId
|
|
||||||
if #self.chapterMonsterShowList <= 2 then
|
|
||||||
monsterId = self.chapterMonsterShowList[2]
|
|
||||||
else
|
|
||||||
monsterId = self.chapterMonsterShowList[math.random(2, #self.chapterMonsterShowList)]
|
|
||||||
end
|
|
||||||
if monsterId == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local monsterCfg = ConfigManager:getConfig("monster_base")
|
|
||||||
local monsterInfo = monsterCfg[monsterId]
|
|
||||||
if monsterInfo == nil then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local modelId = monsterInfo.model_id
|
|
||||||
local pool
|
|
||||||
local list
|
|
||||||
local parent
|
|
||||||
local posY
|
|
||||||
if self.isTopTurn then -- 刷上面
|
|
||||||
pool = self.monsterSpineTopPool[modelId]
|
|
||||||
list = self.monsterSpineTopList
|
|
||||||
parent = self.monsterNodeTop
|
|
||||||
posY = math.random(1, 300)
|
|
||||||
else -- 刷下面
|
|
||||||
pool = self.monsterSpineDownPool[modelId]
|
|
||||||
list = self.monsterSpineDownList
|
|
||||||
parent = self.monsterNodeDown
|
|
||||||
posY = -math.random(1, 240)
|
|
||||||
end
|
|
||||||
self.isTopTurn = not self.isTopTurn
|
|
||||||
if pool and #pool > 0 then
|
|
||||||
local spine = table.remove(pool)
|
|
||||||
table.insert(list, spine)
|
|
||||||
spine:setActive(true)
|
|
||||||
self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
|
||||||
else
|
|
||||||
SpineManager:loadUIHeroSpineWidgetAsync(modelId, parent, function(spine)
|
|
||||||
if not self.startMonsterAction then
|
|
||||||
spine:destroy()
|
|
||||||
return
|
|
||||||
end
|
|
||||||
table.insert(list, spine)
|
|
||||||
local scale = monsterInfo.ui or 1
|
|
||||||
spine:setLocalScale(-scale, scale, scale)
|
|
||||||
self:doMonsterFightMove(modelId, spine, posY, monsterInfo, not self.isTopTurn)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:doMonsterFightMove(modelId, spine, posY, monsterInfo, isTopTurn)
|
|
||||||
spine:playAnim("move", true, true, true)
|
|
||||||
local posX = GConst.UI_SCREEN_WIDTH / 2 + math.random(100, math.floor(GConst.UI_SCREEN_WIDTH*2/3))
|
|
||||||
spine:setAnchoredPosition(posX, posY)
|
|
||||||
local seq = DOTweenManager:createSeqWithIntId(GConst.DOTWEEN_IDS.CHAPTER_MONSTER)
|
|
||||||
if self.chapterMonsterFightSpeed == nil then
|
|
||||||
-- self.chapterMonsterFightSpeed = GFunc.getConstValue("chapter_fight_monstermove")
|
|
||||||
self.chapterMonsterFightSpeed = 880
|
|
||||||
end
|
|
||||||
local distance = posX + GConst.UI_SCREEN_WIDTH/2 + 100
|
|
||||||
local moveTime = distance / self.chapterMonsterFightSpeed
|
|
||||||
local targetPosX = -GConst.UI_SCREEN_WIDTH / 2 - 100
|
|
||||||
local moveTween = spine:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
seq:Append(moveTween)
|
|
||||||
|
|
||||||
-- local monsterShadow = self:getMonsterShadow()
|
|
||||||
local scale = monsterInfo.ui or 1
|
|
||||||
local shadowScale = (monsterInfo.shadow or 1) * scale
|
|
||||||
-- monsterShadow:setLocalScale(shadowScale, shadowScale, shadowScale)
|
|
||||||
-- local shadowOffset = (monsterInfo.shadow_offset or 0) * scale
|
|
||||||
-- monsterShadow:setAnchoredPosition(posX, posY + shadowOffset)
|
|
||||||
-- local moveTween2 = monsterShadow:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
-- seq:Join(moveTween2)
|
|
||||||
|
|
||||||
local monsterSmoke = self:getMonsterSmoke(isTopTurn)
|
|
||||||
monsterSmoke:setAnchoredPosition(posX, posY)
|
|
||||||
monsterSmoke:setLocalScale(-shadowScale, shadowScale, shadowScale)
|
|
||||||
monsterSmoke:playAnim("idle", true, true, true)
|
|
||||||
local moveTween3 = monsterSmoke:getTransform():DOAnchorPosX(targetPosX, moveTime):SetEase(CS.DG.Tweening.Ease.Linear)
|
|
||||||
seq:Join(moveTween3)
|
|
||||||
|
|
||||||
seq:AppendCallback(function()
|
|
||||||
spine:setActive(false)
|
|
||||||
-- monsterShadow:setAnchoredPositionX(10000)
|
|
||||||
-- table.insert(self.monsterShadowPool, monsterShadow)
|
|
||||||
monsterSmoke:setAnchoredPositionX(10000)
|
|
||||||
table.insert(self.monsterSmokePool, monsterSmoke)
|
|
||||||
if isTopTurn then
|
|
||||||
local pool = self.monsterSpineTopPool[modelId]
|
|
||||||
if pool == nil then
|
|
||||||
pool = {}
|
|
||||||
self.monsterSpineTopPool[modelId] = pool
|
|
||||||
end
|
|
||||||
table.insert(pool, spine)
|
|
||||||
for k, v in ipairs(self.monsterSpineTopList) do
|
|
||||||
if v == spine then
|
|
||||||
table.remove(self.monsterSpineTopList, k)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local pool = self.monsterSpineDownPool[modelId]
|
|
||||||
if pool == nil then
|
|
||||||
pool = {}
|
|
||||||
self.monsterSpineDownPool[modelId] = pool
|
|
||||||
end
|
|
||||||
table.insert(pool, spine)
|
|
||||||
for k, v in ipairs(self.monsterSpineDownList) do
|
|
||||||
if v == spine then
|
|
||||||
table.remove(self.monsterSpineDownList, k)
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
if self.chapterFightMonsterCount then
|
|
||||||
self.chapterFightMonsterCount = self.chapterFightMonsterCount - 1
|
|
||||||
if self.chapterFightMonsterCount == 0 then -- 最后一个怪物生成完毕后,重新排一下序
|
|
||||||
self:sortChapterFightMonstersOrder()
|
|
||||||
self:sortChapterFightMonstersOrder()
|
|
||||||
self:sortChapterFightMonstersOrder()
|
|
||||||
self:sortChapterFightMonstersOrder()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:sortChapterFightMonstersOrder()
|
|
||||||
self:sortChildrenOrder(self.monsterNodeTop)
|
|
||||||
self:sortChildrenOrder(self.monsterNodeDown)
|
|
||||||
self:sortChildrenOrder(self.smokeNodeTop)
|
|
||||||
self:sortChildrenOrder(self.smokeNodeDown)
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:sortChildrenOrder(parent)
|
|
||||||
local children = parent:getChildList()
|
|
||||||
if children and #children > 0 then
|
|
||||||
table.sort(children, function(a, b)
|
|
||||||
return a:getAnchoredPositionY() > b:getAnchoredPositionY()
|
|
||||||
end)
|
|
||||||
|
|
||||||
for i = #children, 1, -1 do
|
|
||||||
children[i]:getTransform():SetSiblingIndex(i - 1)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function ChapterComp:getMonsterSmoke(isTop)
|
|
||||||
local monsterSmoke
|
|
||||||
if #self.monsterSmokePool > 0 then
|
|
||||||
monsterSmoke = table.remove(self.monsterSmokePool)
|
|
||||||
monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false)
|
|
||||||
else
|
|
||||||
local shadowObj = CS.UnityEngine.Object.Instantiate(self.bossSmoke:getGameObject())
|
|
||||||
monsterSmoke = UISpineObject:create()
|
|
||||||
monsterSmoke:initWithPrefab(GConst.EMPTY_STRING, shadowObj)
|
|
||||||
monsterSmoke:getAnimationState()
|
|
||||||
monsterSmoke:setParent(isTop and self.smokeNodeTop or self.smokeNodeDown, false)
|
|
||||||
end
|
|
||||||
return monsterSmoke
|
|
||||||
end
|
|
||||||
-- endregion
|
|
||||||
|
|
||||||
return ChapterComp
|
|
||||||
@ -1,10 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 86d90ec67bf352c4d916945ae3b6a5da
|
|
||||||
ScriptedImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 2
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}
|
|
||||||
@ -1,152 +0,0 @@
|
|||||||
local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell"
|
|
||||||
local DailyChallengeComp = class("DailyChallengeComp", MainCompBaseCell)
|
|
||||||
|
|
||||||
function DailyChallengeComp:getIsOpen()
|
|
||||||
return DataManager.DailyChallengeData:isOpen()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:getEntranceName()
|
|
||||||
return I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE)
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:getShowEntranceRedPoint()
|
|
||||||
return DataManager.DailyChallengeData:isMeetChallenge()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:isShowTopNode()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:isShowSideBar()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:isShowHeroFormation()
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:getFightHpCost()
|
|
||||||
return DataManager.DailyChallengeData:getChallengeHpCost()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:getFightTodayRemainCount()
|
|
||||||
return DataManager.DailyChallengeData:getTodayRemainLimitCount()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:onClickFight()
|
|
||||||
ModuleManager.DailyChallengeManager:startChallenge()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:ctor()
|
|
||||||
ModuleManager.DailyChallengeManager:checkDayChange()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:init()
|
|
||||||
self.uiMap = self:getBaseObject():genAllChildren()
|
|
||||||
self:refreshShow()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:refreshShow()
|
|
||||||
if not DataManager.DailyChallengeData:isOpen() then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
self:refreshTxt()
|
|
||||||
self:refreshTask()
|
|
||||||
self:refreshBuff()
|
|
||||||
self:refreshBoss()
|
|
||||||
self:refreshCountdown()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:refreshTxt()
|
|
||||||
self.uiMap["daily_challenge_comp.title.title_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE))
|
|
||||||
self.uiMap["daily_challenge_comp.record_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.CHAPTER_DESC_1, DataManager.DailyChallengeData:getMaxWave()))
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:refreshTask()
|
|
||||||
if self.tasks == nil or #self.tasks < 3 then
|
|
||||||
self.tasks = GFunc.getTable()
|
|
||||||
table.insert(self.tasks, self.uiMap["daily_challenge_comp.challenge.task.icon_task1"])
|
|
||||||
table.insert(self.tasks, self.uiMap["daily_challenge_comp.challenge.task.icon_task2"])
|
|
||||||
table.insert(self.tasks, self.uiMap["daily_challenge_comp.challenge.task.icon_task3"])
|
|
||||||
end
|
|
||||||
|
|
||||||
local tasksData = DataManager.DailyChallengeData:getTasks()
|
|
||||||
for i = 1, #self.tasks do
|
|
||||||
local taskObj = self.tasks[i]
|
|
||||||
if DataManager.DailyChallengeData:canClaimTask(i) then
|
|
||||||
-- 任务奖励可领取
|
|
||||||
taskObj:addRedPoint(30, 30, 0.6)
|
|
||||||
taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1")
|
|
||||||
else
|
|
||||||
-- 任务奖励不可领取
|
|
||||||
taskObj:removeRedPoint()
|
|
||||||
if not DataManager.DailyChallengeData:isTaskFinish(i) then
|
|
||||||
taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_1")
|
|
||||||
else
|
|
||||||
taskObj:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_2")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
taskObj:addClickListener(function()
|
|
||||||
if DataManager.DailyChallengeData:canClaimTask(i) then
|
|
||||||
ModuleManager.DailyChallengeManager:getTaskReward(i)
|
|
||||||
else
|
|
||||||
local rewards = DataManager.DailyChallengeData:getTaskRewards(tasksData[i].task_id)
|
|
||||||
local desc = DataManager.DailyChallengeData:getTaskDesc(tasksData[i].task_id)
|
|
||||||
ModuleManager.TipsManager:showRewardsTips(rewards, desc, taskObj, nil, nil, false, ModuleManager.TipsManager.REWARDS_TIPS_TYPE.TASK)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:refreshBuff()
|
|
||||||
local buffObj = self.uiMap["daily_challenge_comp.challenge.buffs.buff.btn_buff"]
|
|
||||||
local buffIds = DataManager.DailyChallengeData:getTodayBuffIds()
|
|
||||||
buffObj:addClickListener(function()
|
|
||||||
ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[1]), buffObj)
|
|
||||||
end)
|
|
||||||
|
|
||||||
local debuffObj = self.uiMap["daily_challenge_comp.challenge.buffs.debuff.btn_debuff"]
|
|
||||||
debuffObj:addClickListener(function()
|
|
||||||
ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[2]), debuffObj)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:refreshBoss()
|
|
||||||
local curBossInfo = DataManager.DailyChallengeData:getFinalBossInfo()
|
|
||||||
if not curBossInfo then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.curModelId == curBossInfo.model_id then
|
|
||||||
return
|
|
||||||
end
|
|
||||||
if self.spineBoss then
|
|
||||||
self.spineBoss:destroy()
|
|
||||||
self.spineBoss = nil
|
|
||||||
self.curModelId = nil
|
|
||||||
end
|
|
||||||
self.curModelId = curBossInfo.model_id
|
|
||||||
SpineManager:loadHeroAsync(self.curModelId, self.uiMap["daily_challenge_comp.boss.spine_node"], function(spineObject)
|
|
||||||
self.spineBoss = spineObject
|
|
||||||
self.spineBoss:setDefaultMix(0)
|
|
||||||
self.spineBoss:setLocalScale(curBossInfo.model_ui, curBossInfo.model_ui, curBossInfo.model_ui)
|
|
||||||
self.spineBoss:playAnimation(GConst.BattleConst.SPINE_ANIMATION_NAME.IDLE, true, false)
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:refreshCountdown()
|
|
||||||
self.countdownTx = self.uiMap["daily_challenge_comp.countdown.time_tx"]
|
|
||||||
if not self.countdownSid then
|
|
||||||
self.countdownSid = self:getBaseObject():scheduleGlobal(function()
|
|
||||||
self:updateTime()
|
|
||||||
end, 1)
|
|
||||||
end
|
|
||||||
self:updateTime()
|
|
||||||
end
|
|
||||||
|
|
||||||
function DailyChallengeComp:updateTime()
|
|
||||||
ModuleManager.DailyChallengeManager:checkDayChange()
|
|
||||||
local remainTime = Time:getTodaySurplusTime()
|
|
||||||
self.countdownTx:setText(GFunc.getTimeStrWithHMS(remainTime))
|
|
||||||
end
|
|
||||||
|
|
||||||
return DailyChallengeComp
|
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user