提示逻辑补全

This commit is contained in:
Fang 2023-05-26 14:13:37 +08:00
parent 7a87210ae3
commit d473cbc537
7 changed files with 147 additions and 121 deletions

View File

@ -21,7 +21,7 @@ end
-- 开始挑战
function DailyChallengeManager:startChallenge()
Logger.logHighlight("开始每日挑战")
Logger.logHighlight("每日挑战 开始挑战...")
-- 判断次数
if not DataManager.DailyChallengeData:isEnoughChallengeTime() then
GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1))
@ -45,17 +45,6 @@ function DailyChallengeManager:startChallenge()
return
end
local cost = DataManager.DailyChallengeData:getChallengeHpCost()
local vitCostNum = 0
if cost then
vitCostNum = GFunc.getRewardNum(cost)
end
if vitCostNum > DataManager.BagData.ItemData:getVit() then -- 体力不足
GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT)
ModuleManager.CommerceManager:showBuyVitUI()
return
end
local parmas = {}
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeStartReq, parmas, {}, self.rspStartChallenge, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE)
end
@ -69,6 +58,7 @@ end
-- 挑战结束
function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgress, heroInfo, lastBossRound)
Logger.logHighlight("每日挑战 挑战完成...")
local parmas = {
win = combatReport.victory,
chapter_id = chapterId,
@ -81,7 +71,7 @@ function DailyChallengeManager:endChallenge(chapterId, combatReport, taskProgres
parmas[fieldName] = value
end
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterSettlementReq, 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
function DailyChallengeManager:endChallengeFinish(result)
@ -96,14 +86,13 @@ function DailyChallengeManager:endChallengeFinish(result)
end
function DailyChallengeManager:onDayChange()
Logger.logHighlight("每日挑战 跨天...")
self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterDailyChallengeResetReq, nil, {}, self.rspDayChange, BIReport.ITEM_GET_TYPE.DAILY_CHALLENGE_RESET)
end
function DailyChallengeManager:rspDayChange(result)
if result.err_code == GConst.ERROR_STR.SUCCESS then
DataManager.DailyChallengeData:init(result.daily_challenge)
end
end
-- 获取波次(战斗)奖励
function DailyChallengeManager:getWaveReward()

View File

@ -17,6 +17,11 @@ TipsManager.ALIGN_TYPE = {
RIGHT_BOTTOM = 13
}
TipsManager.REWARDS_TIPS_TYPE = {
COMMON = "reward_node",
TASK = "reward2_node",
}
function TipsManager:showHelpTips(params)
params = params or {}
UIManager:showUI("app/ui/tips/help_tips", params)
@ -57,7 +62,7 @@ function TipsManager:showItemTips(id, tarPrefabObj, alignType)
UIManager:showUI("app/ui/tips/item_tips", params)
end
function TipsManager:showRewardsTips(rewards, customTitleStr, tarPrefabObj, callback, alignType)
function TipsManager:showRewardsTips(rewards, customTitleStr, tarPrefabObj, callback, alignType, showBlackBg, typeNode)
local params = {
rewards = rewards,
customTitleStr = customTitleStr,
@ -69,6 +74,8 @@ function TipsManager:showRewardsTips(rewards, customTitleStr, tarPrefabObj, call
local tarCornerScreenPos, location = self:getCornerScreenPosition(tarPrefabObj, alignType)
params.tarCornerScreenPos = tarCornerScreenPos
params.location = location
params.showBlackBg = showBlackBg == nil or showBlackBg
params.typeNode = typeNode or TipsManager.REWARDS_TIPS_TYPE.COMMON
end
UIManager:showUI("app/ui/tips/rewards_tips", params)
end

View File

@ -5,24 +5,23 @@ end
function DailyChallengeComp:init()
self.uiMap = self:getBaseObject():genAllChildren()
self:ininShow()
self:refreshShow()
end
function DailyChallengeComp:ininShow()
self:initTxt()
self:initTask()
self:initBuff()
self:initBoss()
self:refreshTips()
self:initShowCountdown()
function DailyChallengeComp:refreshShow()
self:refreshTxt()
self:refreshTask()
self:refreshBuff()
self:refreshBoss()
self:refreshCountdown()
end
function DailyChallengeComp:initTxt()
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:getTotalFightCount()))
end
function DailyChallengeComp:initTask()
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"])
@ -30,6 +29,7 @@ function DailyChallengeComp:initTask()
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
if not DataManager.DailyChallengeData:isTaskFinish(i) then
-- 任务未完成
@ -39,81 +39,57 @@ function DailyChallengeComp:initTask()
self.tasks[i]:setSprite(GConst.ATLAS_PATH.DAILY_CHALLENGE, "daily_task_2")
end
self.tasks[i]:addClickListener(function()
self:refreshTips(self.tasks[i], 1, 1)-- todo 临时id
local rewards = DataManager.DailyChallengeData:getTaskRewards(tasksData[i].task_id)
local desc = DataManager.DailyChallengeData:getTaskDesc(tasksData[i].task_id)
ModuleManager.TipsManager:showRewardsTips(rewards, desc, self.tasks[i], nil, nil, false, ModuleManager.TipsManager.REWARDS_TIPS_TYPE.TASK)
end)
end
end
function DailyChallengeComp:initBuff()
function DailyChallengeComp:refreshBuff()
local buffObj = self.uiMap["daily_challenge_comp.challenge.buffs.buff.btn_buff"]
local buffIds = DataManager.DailyChallengeData:getTodayBuffIds()
buffObj:addClickListener(function()
self:refreshTips(buffObj, 0, 1)-- todo 临时id
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()
self:refreshTips(debuffObj, 0, 11)-- todo 临时id
ModuleManager.TipsManager:showDescTips(DataManager.DailyChallengeData:getBuffDesc(buffIds[2]), debuffObj)
end)
end
function DailyChallengeComp:initBoss()
SpineManager:loadHeroAsync(DataManager.DailyChallengeData:getFinalBossId(), self.uiMap["daily_challenge_comp.boss.spine_node"], function(spineObject)
-- todo 有问题
spineObject:setDefaultMix(0)
spineObject:playAnimation(GConst.BattleConst.SPINE_ANIMATION_NAME.IDLE, true, false)
end)
end
-- 刷新提示提示对象提示类型0为buff1为任务buffid或者任务id
function DailyChallengeComp:refreshTips(obj, tipsType, id)
self.uiMap["daily_challenge_comp.tips"]:setActive(false)
self.uiMap["daily_challenge_comp.tips.tips_buff"]:setActive(false)
self.uiMap["daily_challenge_comp.tips.tips_task"]:setActive(false)
if obj == nil or tipsType == nil or id == nil then
function DailyChallengeComp:refreshBoss()
local curBossId = DataManager.DailyChallengeData:getFinalBossModelId()
if self.bossId == curBossId then
return
end
local pos = obj:getAnchoredPosition()
if tipsType == 0 then
-- 展示buff提示
self.uiMap["daily_challenge_comp.tips"]:setActive(true)
self.uiMap["daily_challenge_comp.tips.tips_buff"]:setActive(true)
self.uiMap["daily_challenge_comp.tips.tips_buff.buff_tips_tx"]:setText(DataManager.DailyChallengeData:getBuffTips(id))
self.uiMap["daily_challenge_comp.tips.tips_buff"]:setAnchoredPosition(pos.x, pos.y + 100)
elseif tipsType == 1 then
-- 展示任务提示
self.uiMap["daily_challenge_comp.tips"]:setActive(true)
self.uiMap["daily_challenge_comp.tips.tips_task"]:setActive(true)
self.uiMap["daily_challenge_comp.tips.tips_task.task_tips_tx"]:setText(DataManager.DailyChallengeData:getTaskTips(id))
if not self.rewardCell then
self.rewardCell = CellManager:addCellComp(self.uiMap["daily_challenge_comp.tips.tips_task.reward.reward_cell"], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
if self.spineBoss then
self.spineBoss:onDestroy()
self.spineBoss = nil
self.bossId = nil
end
local reward = DataManager.DailyChallengeData:getTaskReward("todo id")
if reward and reward[1] then
self.rewardCell:refreshByConfig(reward[1])
end
self.uiMap["daily_challenge_comp.tips.tips_task"]:setAnchoredPosition(pos.x, pos.y + 100)
end
self.uiMap["daily_challenge_comp.tips.mask"]:addClickListener(function()
self.uiMap["daily_challenge_comp.tips"]:setActive(false)
self.bossId = curBossId
SpineManager:loadHeroAsync(self.bossId, self.uiMap["daily_challenge_comp.boss.spine_node"], function(spineObject)
self.spineBoss = spineObject
self.spineBoss:setDefaultMix(0)
self.spineBoss:playAnimation(GConst.BattleConst.SPINE_ANIMATION_NAME.IDLE, true, false)
end)
end
function DailyChallengeComp:initShowCountdown()
-- self.sid = self:scheduleGlobal(function()
-- self:updateTime()
-- end, 1)
function DailyChallengeComp:refreshCountdown()
self.countdownTx = self.uiMap["daily_challenge_comp.countdown.time_tx"]
if not self.countdownSid then
self.countdownSid = self.countdownTx:scheduleGlobal(function()
self:updateTime()
end, 1)
end
self:updateTime()
end
function DailyChallengeComp:updateTime()
local remainTime = DataManager.DailyChallengeData:getTodaySurplusTime()
self.uiMap["daily_challenge_comp.countdown.time_tx"]:setText(GFunc.getTimeStrWithHMS(remainTime))
self.countdownTx:setText(GFunc.getTimeStrWithHMS(remainTime))
end
return DailyChallengeComp

View File

@ -6,20 +6,26 @@ local MODULE_DATA = {
[1] = {
["type"] = GConst.MainCityConst.BOTTOM_MODULE_KEY.DAILY_CHALLENGE,
["title"] = "每日挑战",-- 标题
["atlas"] = GConst.ATLAS_PATH.ICON_ITEM,-- 图集路径
["icon"] = "1",-- 图片名
["atlas"] = GConst.ATLAS_PATH.MAIN,-- 图集路径
["icon"] = "main_dec_1",-- 图片名
["numFunc"] = function()-- 挑战按钮显示数值
return DataManager.DailyChallengeData:getChallengeHpCost()
end,
["clickFunc"] = function()-- 点击回调
ModuleManager.DailyChallengeManager:startChallenge()
end
end,
["redDot"] = function()-- 显示红点
return DataManager.DailyChallengeData:isMeetChallenge()
end,
["fightNum"] = function()-- 显示今日剩余次数
return DataManager.DailyChallengeData:getTodayRemainLimitCount()
end,
},
[2] = {
["type"] = GConst.MainCityConst.BOTTOM_MODULE_KEY.CHAPTER,
["title"] = "主线章节",
["atlas"] = GConst.ATLAS_PATH.ICON_ITEM,
["icon"] = "2",
["atlas"] = GConst.ATLAS_PATH.COMMON,
["icon"] = "common_dec_1",
["numFunc"] = function()
return DataManager.ChapterData:getFightCost()
end,
@ -94,40 +100,59 @@ function MainComp:refreshFightBtn()
end
self.uiMap["main_comp.fight_btn"]:addClickListener(module["clickFunc"])
if module["fightNum"] ~= nil then
self.uiMap["main_comp.fight_btn.num_tx"]:setActive(true)
self.uiMap["main_comp.fight_btn.num_tx"]:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, module["fightNum"]()))
else
self.uiMap["main_comp.fight_btn.num_tx"]:setActive(false)
end
end
function MainComp:refreshLeftBtn()
local module = MODULE_DATA[self:getCurLeftModuleIdx()]
local leftBtn = self.uiMap["main_comp.left_btn"]
if module == nil then
self.uiMap["main_comp.left_btn"]:setActive(false)
leftBtn:setActive(false)
return
end
self.uiMap["main_comp.left_btn"]:setActive(true)
leftBtn: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()
leftBtn:addClickListener(function()
self.curModuleType = module["type"]
self:refreshBtns()
self:refreshModuleComp()
end)
if module["redDot"] ~= nil and module["redDot"]() then
leftBtn:addRedPoint(65, 35, 0.6)
else
leftBtn:removeRedPoint()
end
end
function MainComp:refreshRightBtn()
local module = MODULE_DATA[self:getCurRightModuleIdx()]
local rightBtn = self.uiMap["main_comp.right_btn"]
if module == nil then
self.uiMap["main_comp.right_btn"]:setActive(false)
rightBtn:setActive(false)
return
end
self.uiMap["main_comp.right_btn"]:setActive(true)
rightBtn: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()
rightBtn:addClickListener(function()
self.curModuleType = module["type"]
self:refreshBtns()
self:refreshModuleComp()
end)
if module["redDot"] ~= nil and module["redDot"]() then
rightBtn:addRedPoint(-65, 35, 0.6)
else
rightBtn:removeRedPoint()
end
end
function MainComp:getCurLeftModuleIdx()
@ -172,6 +197,10 @@ function MainComp:refreshChapter(force)
self.chapterComp:refreshChapter(force)
end
function MainComp:refreshChallenge()
self.dailyChallengeComp:refreshShow()
end
function MainComp:refreshStageFormaion()
local formation = DataManager.FormationData:getStageFormation()
for i, heroCell in ipairs(self.heroCells) do

View File

@ -193,6 +193,14 @@ function MainCityUI:_bind()
end
end
end)
self:bind(DataManager.DailyChallengeData, "isDirty", function()
if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.MAIN then
if self.subComps[self.selectedIndex] then
self.subComps[self.selectedIndex]:refreshChallenge()
end
end
end)
end
function MainCityUI:initBottomUI()

View File

@ -15,6 +15,12 @@ end
function RewardsTips:init()
local uiMap = self.root:genAllChildren()
self.bg = uiMap["rewards_tips.bg"]
self.bgBlack = uiMap["rewards_tips.bg_black"]
uiMap["rewards_tips.bg.reward_node"]:setActive(false)
uiMap["rewards_tips.bg.reward2_node"]:setActive(false)
if self.params.typeNode == ModuleManager.TipsManager.REWARDS_TIPS_TYPE.COMMON then
self.tipsNode = uiMap["rewards_tips.bg.reward_node"]
self.descTx = uiMap["rewards_tips.reward_node.desc"]
self.rewardNode = uiMap["rewards_tips.reward_node.reward_layout"]
if not self.rewardCells then
@ -23,6 +29,17 @@ function RewardsTips:init()
self.rewardCells[i] = CellManager:addCellComp(uiMap["rewards_tips.bg.reward_node.reward_layout.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
end
end
elseif self.params.typeNode == ModuleManager.TipsManager.REWARDS_TIPS_TYPE.TASK then
self.tipsNode = uiMap["rewards_tips.bg.reward2_node"]
self.descTx = uiMap["rewards_tips.bg.reward2_node.desc"]
self.rewardNode = uiMap["rewards_tips.bg.reward2_node.reward_layout"]
if not self.rewardCells then
self.rewardCells = {}
for i = 1, 3 do
self.rewardCells[i] = CellManager:addCellComp(uiMap["rewards_tips.bg.reward2_node.reward_layout.reward_cell_" .. i], GConst.TYPEOF_LUA_CLASS.REWARD_CELL)
end
end
end
end
function RewardsTips:onLoadRootComplete()
@ -39,6 +56,8 @@ function RewardsTips:onRefresh()
self:closeUI()
end)
self.tipsNode:setActive(true)
self.bgBlack:setActive(self.params.showBlackBg)
self.descTx:setText(self.params.customTitleStr or I18N:getGlobalText(I18N.GlobalConst.REWARD_PREVIEW_DESC))
if self.params.rewards then
for i, cell in ipairs(self.rewardCells) do

View File

@ -5,6 +5,10 @@ local FIXED_HERO_TASK = {[2] = true, [7] = true}
local MATCH_TYPE_TASK = {[5] = true, [8] = true}
local NEED_PROGRESS_TASK = {[3] = true, [4] = true, [5] = true, [7] = true, [8] = true}
function DailyChallengeData:ctor()
self.data.isDirty = false
end
function DailyChallengeData:init(data)
data = data or {}
data = { -- 临时数据
@ -43,12 +47,10 @@ function DailyChallengeData:init(data)
self.buffIds = data.buff_id or {}
self.totalFightCount = data.totalFightCount or 0
self.todayFightCount = data.today_challenge_count or 0
self:setDirty()
if not data then
return
end
self.taskIds = {1,2,3}
Logger.logHighlight("每日挑战 更新数据...")
Logger.printTable(data)
end
function DailyChallengeData:clear()
@ -58,6 +60,11 @@ function DailyChallengeData:isOpen()
return ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.DAILY_CHALLENGE, true)
end
function DailyChallengeData:setDirty()
self.data.isDirty = not self.data.isDirty
end
-- 是否满足挑战条件
function DailyChallengeData:isMeetChallenge()
return self:isOpen() and self:isEnoughChallengeTime() and self:isEnoughHp()
@ -92,22 +99,8 @@ function DailyChallengeData:getChallengeHpCost()
end
-- 获取今日挑战场景配置
function DailyChallengeData:getTodayConfig()
-- body
end
-- 获取今日挑战任务id列表
function DailyChallengeData:getTaskIds()
return self.taskIds
end
-- 获取任务奖励
function DailyChallengeData:getTaskReward(id)
local task = self.taskIds[id]
if task == nil then
return GConst.EMPTY_STRING
end
return self:getTaskCfg()[task.taskId].reward
function DailyChallengeData:getMapConfig()
return ConfigManager:getConfig("chapter_daily_challenge")[self.fixedChapterId]
end
function DailyChallengeData:getBuffTips(id)
@ -131,9 +124,13 @@ function DailyChallengeData:getTodayPassNum()
end
-- 获取今日增益、负面buff
function DailyChallengeData:getTodayBuff()
function DailyChallengeData:getTodayBuffIds()
return self.buffIds
-- return ConfigManager:getConfig("buff_daily_challenge")[self.buffIds[1]], ConfigManager:getConfig("buff_daily_challenge")[self.buffIds[2]]
end
-- 获取buff描述
function DailyChallengeData:getBuffDesc(buffId)
return I18N:getText("buff_daily_challenge", buffId, "desc")
end
-- 获取今日剩余时间
@ -145,9 +142,10 @@ function DailyChallengeData:getTodaySurplusTime()
return result
end
-- 获取最终boss id
function DailyChallengeData:getFinalBossId()
return "m10001"
-- 获取最终boss 模型 id
function DailyChallengeData:getFinalBossModelId()
local mapCfg = self:getMapConfig()
return ConfigManager:getConfig("monster")[mapCfg.monster[#mapCfg.monster]].model_id
end
-- 任务是否完成