diff --git a/lua/app/common/bi_report.lua b/lua/app/common/bi_report.lua index 8536f33d..ce491e3a 100644 --- a/lua/app/common/bi_report.lua +++ b/lua/app/common/bi_report.lua @@ -96,6 +96,9 @@ BIReport.ITEM_GET_TYPE = { DAILY_CHALLENGE_END = "DailyChallengeEnd", -- 每日挑战结算 DAILY_CHALLENGE_RESET = "DailyChallengeReset", -- 每日挑战重置 DAILY_CHALLENGE_TASK_REWARD = "DailyChallengeTaskReward", -- 每日挑战任务奖励 + DUNGEON_GOLD_CHALLENGE = "DungeonGoldChallenge", -- 金币副本挑战 + DUNGEON_GOLD_END = "DungeonGoldEnd", -- 金币副本结算 + DUNGEON_GOLD_SWEEP = "DungeonGoldSweep", -- 金币副本扫荡 } BIReport.ADS_CLICK_TYPE = { diff --git a/lua/app/common/data_manager.lua b/lua/app/common/data_manager.lua index d6a0dd4a..e5acc7e5 100644 --- a/lua/app/common/data_manager.lua +++ b/lua/app/common/data_manager.lua @@ -9,6 +9,7 @@ function DataManager:init() self:initManager("PlayerData", "app/userdata/player/player_data") self:initManager("ChapterData", "app/userdata/chapter/chapter_data") self:initManager("DailyChallengeData", "app/userdata/daily_challenge/daily_challenge_data") + self:initManager("DungeonData", "app/userdata/dungeon/dungeon_data") self:initManager("HeroData", "app/userdata/hero/hero_data") self:initManager("BagData", "app/userdata/bag/bag_data") self:initManager("BattleData", "app/userdata/battle/battle_data") @@ -85,6 +86,7 @@ function DataManager:clear() self.PlayerData:clear() self.ChapterData:clear() self.DailyChallengeData:clear() + self.DungeonData:clear() self.HeroData:clear() self.BagData:clear() self.FormationData:clear() @@ -119,6 +121,8 @@ function DataManager:initWithServerData(data) self.PlayerData:init(data) self.ChapterData:init(data.chapter) self.DailyChallengeData:init(data.chapter_daily_challenge) + self.DungeonData:initDungeonGold(data.chapter_gold_challenge) + self.DungeonData:initDungeonShards() self.HeroData:init(data.bag.heroes) self.BagData:init(data.bag) self.FormationData:init(data.fight_info) diff --git a/lua/app/common/event_manager.lua b/lua/app/common/event_manager.lua index 12cb89c1..c4b8ff53 100644 --- a/lua/app/common/event_manager.lua +++ b/lua/app/common/event_manager.lua @@ -29,8 +29,7 @@ EventManager.CUSTOM_EVENT = { SKILL_REFRESH_SUCC = "SKILL_REFRESH_SUCC", GO_SHOP = "GO_SHOP", -- 跳转商店 UPDATE_MAIN_MALL_HEIGHT = "UPDATE_MAIN_MALL_HEIGHT", -- 更新主要商品的高度 - GO_DAILY_CHALLENGE = "GO_DAILY_CHALLENGE", -- 跳转每日挑战 - GO_CHAPTER = "GO_CHAPTER", -- 跳转主线章节 + CHANGE_MAIN_COMP_MODULE = "CHANGE_MAIN_COMP_MODULE", -- 切换主界面模块 CLOSE_BOX_HERO_UI = "CLOSE_BOX_HERO_UI", CLOSE_BOX_OPEN_UI = "CLOSE_BOX_OPEN_UI", BIND_ACCOUNT_SUCCESS = "BIND_ACCOUNT_SUCCESS", diff --git a/lua/app/common/module_manager.lua b/lua/app/common/module_manager.lua index 1329067a..0e299a5e 100644 --- a/lua/app/common/module_manager.lua +++ b/lua/app/common/module_manager.lua @@ -51,6 +51,8 @@ local MODULE_PATHS = { PlayerManager = "app/module/player/player_manager", -- 账号 AccountManager= "app/module/account/account_manager", + -- 活动副本 + DungeonManager = "app/module/dungeon/dungeon_manager", } -- 这里的key对应func_open里的id @@ -70,6 +72,8 @@ ModuleManager.MODULE_KEY = { FIRST_RECHARGE = "first_charge", -- 首充礼包 BEGINNER_GIFT = "new_player_gift", -- 新手礼包 MAIL = "mail_open", -- 邮件 + DUNGEON_SHARDS = "dungeon_shards_open", -- 碎片副本 + DUNGEON_GOLD = "dungeon_gold_open", -- 金币副本 } local _moduleMgrs = {} diff --git a/lua/app/common/time.lua b/lua/app/common/time.lua index e26e3e01..ea3a7b6e 100644 --- a/lua/app/common/time.lua +++ b/lua/app/common/time.lua @@ -137,6 +137,15 @@ function Time:getOverOfServerToday(time) return self:getBeginningOfServerToday() + SECONDS_PRE_DAY end +-- 获取今日剩余时间 +function Time:getTodaySurplusTime() + local result = self:getOverOfServerToday() - self:getServerTime() + if result < 0 then + result = 0 + end + return result +end + function Time:getBeginningOfToday() local now = os.date('*t', self:getServerTime() + self:getTimeZoneOffset()*SECONDS_PRE_HOUR) local beginDay = os.time{year = now.year, month = now.month, day = now.day, hour = 0} @@ -271,6 +280,15 @@ function Time:getDayByTimeStamp(time) return now.day end +-- 获取当前处于星期几 +function Time:getWeekByTimeStamp(time) + time = time or self:getServerTime() + local now = os.date('!*t', time) + + local weekTab = {7, 1, 2, 3, 4, 5, 6} + return weekTab[now.wday] +end + -- 转换服务器时间字符串(ISO 8601)的对应的时间戳,例如2022-09-10T18:10:00.000Z function Time:convertServerTimeStringToTimestamp(str) local dateTime = CS.System.DateTime.Parse(str) diff --git a/lua/app/config/localization/localization_global_const.lua b/lua/app/config/localization/localization_global_const.lua index 9f44a86f..2388e36d 100644 --- a/lua/app/config/localization/localization_global_const.lua +++ b/lua/app/config/localization/localization_global_const.lua @@ -228,6 +228,7 @@ local LocalizationGlobalConst = DUNGEON_SHARDS_HELP = "DUNGEON_SHARDS_HELP", DUNGEON_SHARDS_OPEN = "DUNGEON_SHARDS_OPEN", MAIN_CHAPTER = "MAIN_CHAPTER", + SMASH = "SMASH", } return LocalizationGlobalConst \ No newline at end of file diff --git a/lua/app/config/strings/cn/global.lua b/lua/app/config/strings/cn/global.lua index 0f459dd7..b188bea5 100644 --- a/lua/app/config/strings/cn/global.lua +++ b/lua/app/config/strings/cn/global.lua @@ -228,6 +228,7 @@ local localization_global = ["DUNGEON_SHARDS_HELP"] = "检测实力的时候到了!\n打倒所有拦路的怪物们,告诉他们谁才是真正的勇士!\n注意!怪物们有备而来,部分角色的攻击会下降。", ["DUNGEON_SHARDS_OPEN"] = "开启时间:周一、周三、周五、周日", ["MAIN_CHAPTER"] = "主线章节", + ["SMASH"] = "扫荡", } return localization_global \ No newline at end of file diff --git a/lua/app/config/strings/en/global.lua b/lua/app/config/strings/en/global.lua index 73d9e108..30ef1458 100644 --- a/lua/app/config/strings/en/global.lua +++ b/lua/app/config/strings/en/global.lua @@ -218,6 +218,7 @@ local localization_global = ["CHAPTER_DESC_2"] = "Mysterious Chest{0}/{1}", ["FIRST_PASS"] = "1st Clear", ["MAIN_CHAPTER"] = "Main Chapter", + ["SMASH"] = "Smash", } return localization_global \ No newline at end of file diff --git a/lua/app/config/strings/zh/global.lua b/lua/app/config/strings/zh/global.lua index 7109511b..7ac96024 100644 --- a/lua/app/config/strings/zh/global.lua +++ b/lua/app/config/strings/zh/global.lua @@ -217,6 +217,7 @@ local localization_global = ["PAY_FAILED_DESC_1"] = "訂單異常,請聯繫客服處理", ["CHAPTER_DESC_2"] = "神祕寶箱{0}/{1}", ["MAIN_CHAPTER"] = "主線章節", + ["SMASH"] = "掃蕩", } return localization_global \ No newline at end of file diff --git a/lua/app/module/battle/battle_const.lua b/lua/app/module/battle/battle_const.lua index 30cb43e4..8e8b54c0 100644 --- a/lua/app/module/battle/battle_const.lua +++ b/lua/app/module/battle/battle_const.lua @@ -77,6 +77,8 @@ BattleConst.TIME_SCALE = { BattleConst.BATTLE_TYPE = { STAGE = "1", DAILY_CHALLENGE = "2", + DUNGEON_GOLD = "3", + DUNGEON_SHARDS = "4", } BattleConst.TYPEOF_LUA_COMP = { diff --git a/lua/app/module/dungeon.meta b/lua/app/module/dungeon.meta new file mode 100644 index 00000000..74913bc9 --- /dev/null +++ b/lua/app/module/dungeon.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 120307307c2846141b488d71d9d0a672 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/module/dungeon/dungeon_manager.lua b/lua/app/module/dungeon/dungeon_manager.lua new file mode 100644 index 00000000..42357dc9 --- /dev/null +++ b/lua/app/module/dungeon/dungeon_manager.lua @@ -0,0 +1,88 @@ +local DungeonManager = class("DungeonManager", BaseModule) + +function DungeonManager:checkDayChange() +end + +-- 请求挑战金币副本 +function DungeonManager:reqChallengeGold(id) + local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD + -- 判断次数 + if not DataManager.DungeonData:getRemainTimes(moduleKey) > 0 then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) + return + end + + -- 判断体力 + if not DataManager.DailyChallengeData:isEnoughHp(moduleKey) then + GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT) + ModuleManager.CommerceManager:showBuyVitUI() + return + end + + if not DataManager.DailyChallengeData:isCanChallenge(moduleKey) then + return + end + + local parmas = {} + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeStartReq, parmas, {}, self.respChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_CHALLENGE) +end + +-- 响应挑战副本 +function DungeonManager:respChallengeGold(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + end +end + +-- 请求结算金币副本 +function DungeonManager:reqEndChallengeGold() + local parmas = { + win = true, + total_damage = nil, + remaining_hp = nil, + chapter_gold_id = nil, + task_stat = nil, + combatReport = nil, + } + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeSettlementReq, parmas, {}, self.respEndChallengeGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_END) +end + +-- 响应结算金币副本 +function DungeonManager:respEndChallengeGold(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + ModuleManager.BattleManager:showBattleResultUI(GConst.BattleConst.BATTLE_TYPE.DUNGEON_GOLD, result.rewards, result.reqData.combatReport) + end +end + +-- 请求扫荡金币副本 +function DungeonManager:reqSweepGold(id) + local moduleKey = ModuleManager.MODULE_KEY.DUNGEON_GOLD + -- 判断次数 + if not DataManager.DungeonData:getRemainTimes(moduleKey) > 0 then + GFunc.showToast(I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE_DESC_1)) + return + end + + -- 判断体力 + if not DataManager.DailyChallengeData:isEnoughHp(moduleKey) then + GFunc.showItemNotEnough(GConst.ItemConst.ITEM_ID_VIT) + ModuleManager.CommerceManager:showBuyVitUI() + return + end + + if not DataManager.DailyChallengeData:isCanChallenge(moduleKey) then + return + end + + local parmas = { + chapter_gold_id = id, + } + self:sendMessage(ProtoMsgType.FromMsgEnum.ChapterGoldChallengeFarmReq, parmas, {}, self.respSweepGold, BIReport.ITEM_GET_TYPE.DUNGEON_GOLD_SWEEP) +end + +-- 响应扫荡金币副本 +function DungeonManager:respSweepGold(result) + if result.err_code == GConst.ERROR_STR.SUCCESS then + end +end + +return DungeonManager \ No newline at end of file diff --git a/lua/app/module/dungeon/dungeon_manager.lua.meta b/lua/app/module/dungeon/dungeon_manager.lua.meta new file mode 100644 index 00000000..622f4e3f --- /dev/null +++ b/lua/app/module/dungeon/dungeon_manager.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 10cc1e2d34182e345b319afee1686513 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/module/maincity/maincity_const.lua b/lua/app/module/maincity/maincity_const.lua index 6bf73be7..1bffbd83 100644 --- a/lua/app/module/maincity/maincity_const.lua +++ b/lua/app/module/maincity/maincity_const.lua @@ -18,6 +18,7 @@ MainCityConst.BOTTOM_CLOSE_ICON = { MainCityConst.MAIN_MODULE = { DAILY_CHALLENGE = 1, CHAPTER = 2, + DUNGEON = 3, } MainCityConst.LEFT_SIDE_BARS = { diff --git a/lua/app/proto/proto_msg_type.lua b/lua/app/proto/proto_msg_type.lua index 5a3e7739..ab4849b5 100644 --- a/lua/app/proto/proto_msg_type.lua +++ b/lua/app/proto/proto_msg_type.lua @@ -23,6 +23,8 @@ local ProtoMsgType = { [613795629] = "WatchADRsp", [737107384] = "BuyMallIdleReq", [737109217] = "BuyMallIdleRsp", + [834139466] = "ChapterGoldChallengeStartReq", + [834141299] = "ChapterGoldChallengeStartRsp", [1008447203] = "DeleteReq", [1008449036] = "DeleteRsp", [1068769299] = "ReconnectReq", @@ -31,6 +33,8 @@ local ProtoMsgType = { [1070843294] = "LoginRsp", [1433352538] = "ChapterDailyChallengeResetReq", [1433354371] = "ChapterDailyChallengeResetRsp", + [1435947790] = "AppStorePaidReq", + [1435949623] = "AppStorePaidRsp", [1471116409] = "BindReq", [1471118242] = "BindRsp", [1584689751] = "ActPaidResultReq", @@ -83,6 +87,8 @@ local ProtoMsgType = { [3309820798] = "HeroPutOnReq", [3309822631] = "HeroPutOnRsp", [3341173994] = "BountyBoughtNtf", + [3359969683] = "ChapterGoldChallengeSettlementReq", + [3359971516] = "ChapterGoldChallengeSettlementRsp", [3363939655] = "TaskDailyAdReq", [3363941488] = "TaskDailyAdRsp", [3421550443] = "GlobalGiftReq", @@ -112,6 +118,8 @@ local ProtoMsgType = { [3933877450] = "ChapterStartRsp", [4106156009] = "BountyLevelUnlockReq", [4106157842] = "BountyLevelUnlockRsp", + [4133057746] = "ChapterGoldChallengeFarmReq", + [4133059579] = "ChapterGoldChallengeFarmRsp", [4256333947] = "ExistReq", [4256335780] = "ExistRsp", }, @@ -139,6 +147,8 @@ local ProtoMsgType = { WatchADRsp = 613795629, BuyMallIdleReq = 737107384, BuyMallIdleRsp = 737109217, + ChapterGoldChallengeStartReq = 834139466, + ChapterGoldChallengeStartRsp = 834141299, DeleteReq = 1008447203, DeleteRsp = 1008449036, ReconnectReq = 1068769299, @@ -147,6 +157,8 @@ local ProtoMsgType = { LoginRsp = 1070843294, ChapterDailyChallengeResetReq = 1433352538, ChapterDailyChallengeResetRsp = 1433354371, + AppStorePaidReq = 1435947790, + AppStorePaidRsp = 1435949623, BindReq = 1471116409, BindRsp = 1471118242, ActPaidResultReq = 1584689751, @@ -199,6 +211,8 @@ local ProtoMsgType = { HeroPutOnReq = 3309820798, HeroPutOnRsp = 3309822631, BountyBoughtNtf = 3341173994, + ChapterGoldChallengeSettlementReq = 3359969683, + ChapterGoldChallengeSettlementRsp = 3359971516, TaskDailyAdReq = 3363939655, TaskDailyAdRsp = 3363941488, GlobalGiftReq = 3421550443, @@ -228,6 +242,8 @@ local ProtoMsgType = { ChapterStartRsp = 3933877450, BountyLevelUnlockReq = 4106156009, BountyLevelUnlockRsp = 4106157842, + ChapterGoldChallengeFarmReq = 4133057746, + ChapterGoldChallengeFarmRsp = 4133059579, ExistReq = 4256333947, ExistRsp = 4256335780, }, @@ -255,6 +271,8 @@ local ProtoMsgType = { WatchADRsp = "WatchADRsp", BuyMallIdleReq = "BuyMallIdleReq", BuyMallIdleRsp = "BuyMallIdleRsp", + ChapterGoldChallengeStartReq = "ChapterGoldChallengeStartReq", + ChapterGoldChallengeStartRsp = "ChapterGoldChallengeStartRsp", DeleteReq = "DeleteReq", DeleteRsp = "DeleteRsp", ReconnectReq = "ReconnectReq", @@ -263,6 +281,8 @@ local ProtoMsgType = { LoginRsp = "LoginRsp", ChapterDailyChallengeResetReq = "ChapterDailyChallengeResetReq", ChapterDailyChallengeResetRsp = "ChapterDailyChallengeResetRsp", + AppStorePaidReq = "AppStorePaidReq", + AppStorePaidRsp = "AppStorePaidRsp", BindReq = "BindReq", BindRsp = "BindRsp", ActPaidResultReq = "ActPaidResultReq", @@ -315,6 +335,8 @@ local ProtoMsgType = { HeroPutOnReq = "HeroPutOnReq", HeroPutOnRsp = "HeroPutOnRsp", BountyBoughtNtf = "BountyBoughtNtf", + ChapterGoldChallengeSettlementReq = "ChapterGoldChallengeSettlementReq", + ChapterGoldChallengeSettlementRsp = "ChapterGoldChallengeSettlementRsp", TaskDailyAdReq = "TaskDailyAdReq", TaskDailyAdRsp = "TaskDailyAdRsp", GlobalGiftReq = "GlobalGiftReq", @@ -344,6 +366,8 @@ local ProtoMsgType = { ChapterStartRsp = "ChapterStartRsp", BountyLevelUnlockReq = "BountyLevelUnlockReq", BountyLevelUnlockRsp = "BountyLevelUnlockRsp", + ChapterGoldChallengeFarmReq = "ChapterGoldChallengeFarmReq", + ChapterGoldChallengeFarmRsp = "ChapterGoldChallengeFarmRsp", ExistReq = "ExistReq", ExistRsp = "ExistRsp", }, diff --git a/lua/app/ui/dungeon.meta b/lua/app/ui/dungeon.meta new file mode 100644 index 00000000..55309697 --- /dev/null +++ b/lua/app/ui/dungeon.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c079de69e6c30a0438fa6e6a4f405800 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/ui/dungeon/dungeon_board_cell.lua b/lua/app/ui/dungeon/dungeon_board_cell.lua new file mode 100644 index 00000000..3fabcaee --- /dev/null +++ b/lua/app/ui/dungeon/dungeon_board_cell.lua @@ -0,0 +1,91 @@ +local DungeonBoardCell = class("DungeonBoardCell", BaseCell) + +function DungeonBoardCell:init() + self.uiMap = self:getUIMap() + + self.icon = self.uiMap["dungeon_board_cell.info.icon"] + self.txTitle = self.uiMap["dungeon_board_cell.info.icon.tx_title"] + self.countdown = self.uiMap["dungeon_board_cell.info.countdown"] + self.txCountdown = self.uiMap["dungeon_board_cell.info.countdown.tx_countdown"] + self.txOpen = self.uiMap["dungeon_board_cell.info.tx_open"] + self.lock = self.uiMap["dungeon_board_cell.lock"] + self.lockTxLock = self.uiMap["dungeon_board_cell.lock.desc.tx_lock"] + self.lockTxCountdown = self.uiMap["dungeon_board_cell.lock.countdown.tx_countdown"] + self.btnStart = self.uiMap["dungeon_board_cell.btn_start"] + self.txStart = self.uiMap["dungeon_board_cell.btn_start.tx_btn"] + self.txTimes = self.uiMap["dungeon_board_cell.btn_start.tx_times"] + self.btnHelp = self.uiMap["dungeon_board_cell.btn_help"] + + self.btnStart:addClickListener(function() + -- 打开副本关卡选择界面 + UIManager:showUI("app/ui/dungeon/dungeon_difficulty_ui", {module = self.moduleKey}) + end) + self.btnHelp:addClickListener(function() + -- 展示提示 + ModuleManager.TipsManager:showDescTips(DataManager.DungeonData:getRule(self.moduleKey), self.btnHelp) + end) +end + +function DungeonBoardCell:refresh(moduleKey) + self.moduleKey = moduleKey + + self:refreshInfo() + self:refreshRewards() +end + +function DungeonBoardCell:refreshInfo() + self.txTitle:setText(DataManager.DungeonData:getTitle(self.moduleKey)) + self.txOpen:setText(DataManager.DungeonData:getOpenTimeDesc(self.moduleKey)) + + if DataManager.DungeonData:isActive(self.moduleKey) then + self.btnStart:setVisible(true) + self.countdown:setVisible(true) + self.lock:setVisible(false) + + self.txOpen:setAnchoredPositionY(-115) + self.txStart:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) + self.txTimes:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, DataManager.DungeonData:getRemainTimes(self.moduleKey))) + self:refreshCountdown(self.txCountdown) + else + self.btnStart:setVisible(false) + self.countdown:setVisible(false) + self.lock:setVisible(true) + + self.txOpen:setAnchoredPositionY(-75) + self.lockTxLock:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_OPEN)) + self:refreshCountdown(self.lockTxCountdown) + end +end + +function DungeonBoardCell:refreshRewards() + self.rewards = DataManager.DungeonData:getBoardShowRewards() + if self.rewards == nil then + return + end + + self.scrollRect = self.uiMap[""]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) + self.scrollRect:addInitCallback(function() + return GConst.TYPEOF_LUA_CLASS.REWARD_CELL + end) + self.scrollRect:addRefreshCallback(function(index, cell) + cell:refreshByConfig(self.itemList[index]) + end) + self.scrollRect:clearCells() + self.scrollRect:setTotalCount(0) +end + +function DungeonBoardCell:refreshCountdown(txCountdown) + if not self.countdownSid then + self.countdownSid = txCountdown:scheduleGlobal(function() + self:updateTime(txCountdown) + end, 1) + end + self:updateTime(txCountdown) +end + +function DungeonBoardCell:updateTime(txCountdown) + local remainTime = Time:getTodaySurplusTime() + txCountdown:setText(GFunc.getTimeStrWithHMS(remainTime)) +end + +return DungeonBoardCell \ No newline at end of file diff --git a/lua/app/ui/dungeon/dungeon_board_cell.lua.meta b/lua/app/ui/dungeon/dungeon_board_cell.lua.meta new file mode 100644 index 00000000..5eafd3e5 --- /dev/null +++ b/lua/app/ui/dungeon/dungeon_board_cell.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 42e0b145611148845b047bd6359e9f4e +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/dungeon/dungeon_difficulty_ui.lua b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua new file mode 100644 index 00000000..1bd7422f --- /dev/null +++ b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua @@ -0,0 +1,105 @@ +local DungeonDifficultyUI = class("DungeonDifficultyUI", BaseUI) + +function DungeonDifficultyUI:isFullScreen() + return false +end + +function DungeonDifficultyUI:getPrefabPath() + return "assets/prefabs/ui/dungeon/dungeon_difficulty_ui.prefab" +end + +function DungeonDifficultyUI:ctor(params) + self.module = params.module + self.curId = DataManager.DungeonData:getPassedMaxId(self.module) + 1 +end + +function DungeonDifficultyUI:onCover() +end + +function DungeonDifficultyUI:onReshow() +end + +function DungeonDifficultyUI:onClose() +end + +function DungeonDifficultyUI:onLoadRootComplete() + self.uiMap = self.root:genAllChildren() + + self.btnClose = self.uiMap["dungeon_difficulty_ui.bg.close_btn"] + self.btnStart = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_start"] + self.txStart = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_start.tx_start"] + self.txStartCost = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_start.cost.tx_cost"] + self.btnSweep = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_sweep"] + self.txSweep = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_sweep.tx_sweep"] + self.txSweepCost = self.uiMap["dungeon_difficulty_ui.bg.btns.btn_sweep.cost.tx_cost"] + self.txTime = self.uiMap["dungeon_difficulty_ui.bg.btns.tx_time"] + self.txDifficulty = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.tx_difficulty"] + self.txLevel = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.tx_level"] + self.arrowLeft = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.arrow_left"] + self.arrowRight = self.uiMap["dungeon_difficulty_ui.bg.select.chapter.arrow_right"] + self.txDesc = self.uiMap["dungeon_difficulty_ui.bg.tx_desc"] + self.txTitle = self.uiMap["dungeon_difficulty_ui.bg.title.title_text"] + + self.txTitle:setText(DataManager.DungeonData:getTitle(self.module)) + self.txDesc:setText(DataManager.DungeonData:getRule(self.module)) + self.txDifficulty:setText(I18N:getGlobalText(I18N.GlobalConst.DUNGEON_STAGE)) + self.txStart:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) + self.txSweep:setText(I18N:getGlobalText(I18N.GlobalConst.SMASH)) + local cost = DataManager.DungeonData:getChallengeHpCost(self.module) + self.txStartCost:setText("-"..GFunc.getRewardNum(cost)) + self.txSweepCost:setText("-"..GFunc.getRewardNum(cost)) + self.txTime:setText(I18N:getGlobalText(I18N.GlobalConst.TODAY_REMAIN_TIMES, DataManager.DungeonData:getRemainTimes(self.module))) + -- todo 奖励 + + self:refreshDifficulty() + + self.btnClose:addClickListener(function() + self:closeUI() + end) + self.btnStart:addClickListener(function() + -- 开始挑战 + end) + self.btnSweep:addClickListener(function() + -- 开始扫荡 + end) + self.arrowLeft:addClickListener(function() + if self:isCanChallengeMinId() then + return + end + + self.curId = self.curId - 1 + self:refreshDifficulty() + end) + self.arrowRight:addClickListener(function() + if self:isCanChallengeMaxId() then + return + end + + self.curId = self.curId + 1 + self:refreshDifficulty() + end) +end + +function DungeonDifficultyUI:refreshDifficulty() + self.arrowLeft:setActive(not self:isCanChallengeMinId()) + self.arrowRight:setActive(not self:isCanChallengeMaxId()) + self.btnSweep:setActive(self:isCanSweepId()) + self.txLevel:setText(tostring(self.curId)) +end + +-- 是否是可扫荡关卡 +function DungeonDifficultyUI:isCanSweepId() + return self.curId <= DataManager.DungeonData:getPassedMaxId(self.module) +end + +--是否是能挑战的最大关卡 +function DungeonDifficultyUI:isCanChallengeMaxId() + return self.curId == DataManager.DungeonData:getPassedMaxId(self.module) + 1 +end + +--是否是能挑战的最小关卡 +function DungeonDifficultyUI:isCanChallengeMinId() + return self.curId == 1 +end + +return DungeonDifficultyUI \ No newline at end of file diff --git a/lua/app/ui/dungeon/dungeon_difficulty_ui.lua.meta b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua.meta new file mode 100644 index 00000000..77f4cfb7 --- /dev/null +++ b/lua/app/ui/dungeon/dungeon_difficulty_ui.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 93a0a9d95d4774c49b001c3108e5a61c +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/component/chapter_comp.lua b/lua/app/ui/main_city/component/chapter_comp.lua index 004f252e..98bf0633 100644 --- a/lua/app/ui/main_city/component/chapter_comp.lua +++ b/lua/app/ui/main_city/component/chapter_comp.lua @@ -12,7 +12,7 @@ function ChapterComp:getIsOpen() end function ChapterComp:getEntranceName() - return "主线章节" + return I18N:getGlobalText(I18N.GlobalConst.MAIN_CHAPTER) end function ChapterComp:getEntranceIcon() diff --git a/lua/app/ui/main_city/component/daily_challenge_comp.lua b/lua/app/ui/main_city/component/daily_challenge_comp.lua index 4c59f52d..3af7c0d7 100644 --- a/lua/app/ui/main_city/component/daily_challenge_comp.lua +++ b/lua/app/ui/main_city/component/daily_challenge_comp.lua @@ -6,7 +6,7 @@ function DailyChallengeComp:getIsOpen() end function DailyChallengeComp:getEntranceName() - return "每日挑战" + return I18N:getGlobalText(I18N.GlobalConst.DAILY_CHALLENGE) end function DailyChallengeComp:getEntranceIcon() @@ -137,7 +137,7 @@ end function DailyChallengeComp:updateTime() ModuleManager.DailyChallengeManager:checkDayChange() - local remainTime = DataManager.DailyChallengeData:getTodaySurplusTime() + local remainTime = Time:getTodaySurplusTime() self.countdownTx:setText(GFunc.getTimeStrWithHMS(remainTime)) end diff --git a/lua/app/ui/main_city/component/dungeon_comp.lua b/lua/app/ui/main_city/component/dungeon_comp.lua new file mode 100644 index 00000000..24dc9cae --- /dev/null +++ b/lua/app/ui/main_city/component/dungeon_comp.lua @@ -0,0 +1,53 @@ +local MainCompBaseCell = require "app/ui/main_city/component/main_comp_base_cell" +local DungeonComp = class("DungeonComp", MainCompBaseCell) + +function DungeonComp:getIsOpen() + return DataManager.DungeonData:isOpenAnyone() +end + +function DungeonComp:getEntranceName() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_BTN) +end + +function DungeonComp:getEntranceIcon() + return GConst.ATLAS_PATH.MAIN,"main_dec_1" +end + +function DungeonComp:getShowEntranceRedPoint() + return DataManager.DungeonData:isCanChallengeAnyone() +end + +function DungeonComp:ctor() +end + +function DungeonComp:init() + self.uiMap = self:getBaseObject():genAllChildren() + self:refreshShow() +end + +function DungeonComp:refreshShow() + self.openDungeons = DataManager.DungeonData:getOpenDungeons() + + self.scrollRect = self.uiMap["dungeon_comp.scrollrect"] + self.scrollRectComp = self.scrollRect:addLuaComponent(GConst.TYPEOF_LUA_CLASS.SCROLL_RECT_BASE) + self.scrollRectComp:addInitCallback(function() + return "app/ui/dungeon/dungeon_board_cell" + end) + self.scrollRectComp:addRefreshCallback(function(index, cell) + cell:refresh(self.openDungeons[index]) + end) + self.scrollRectComp:clearCells() + self.scrollRectComp:setTotalCount(0) + self:refreshScrollRect() +end + +function DungeonComp:refreshScrollRect() + if self.scrollRectComp:getTotalCount() ~= #self.openDungeons then + self.scrollRectComp:clearCells() + self.scrollRectComp:refillCells(#self.openDungeons) + else + self.scrollRectComp:updateAllCell() + end +end + +return DungeonComp \ No newline at end of file diff --git a/lua/app/ui/main_city/component/dungeon_comp.lua.meta b/lua/app/ui/main_city/component/dungeon_comp.lua.meta new file mode 100644 index 00000000..f7d453b9 --- /dev/null +++ b/lua/app/ui/main_city/component/dungeon_comp.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: eeb42cdacecfcf4468aecedc8d7cd340 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/ui/main_city/component/main_comp.lua b/lua/app/ui/main_city/component/main_comp.lua index 843351c0..9c3750e6 100644 --- a/lua/app/ui/main_city/component/main_comp.lua +++ b/lua/app/ui/main_city/component/main_comp.lua @@ -1,15 +1,15 @@ local MainComp = class("MainComp", LuaComponent) local CHAPTER_COMP = "app/ui/main_city/component/chapter_comp" local DAILY_CHALLENGE_COMP = "app/ui/main_city/component/daily_challenge_comp" +local DUNGEON_COMP = "app/ui/main_city/component/dungeon_comp" local BOTTOM_HEIGHT = 120 function MainComp:init() self.uiMap = self:getBaseObject():genAllChildren() - self:refreshModule(ModuleManager.MaincityManager:getCurModule()) self:initStageFormation() - + self:refreshModule(ModuleManager.MaincityManager:getCurModule()) end function MainComp:refreshModule(selectModule) @@ -25,31 +25,36 @@ function MainComp:refreshModule(selectModule) self.dailyChallengeComp = CellManager:addCellComp(dailyChallengeComp, DAILY_CHALLENGE_COMP) self.dailyChallengeComp:initWithParentUI(self) self.moduleMap[GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE] = self.dailyChallengeComp + -- 活动副本 + local dungeonComp = self.uiMap["main_comp.dungeon_comp"] + self.dungeonComp = CellManager:addCellComp(dungeonComp, DUNGEON_COMP) + self.dungeonComp:initWithParentUI(self) + self.moduleMap[GConst.MainCityConst.MAIN_MODULE.DUNGEON] = self.dungeonComp end if self.curModuleType ~= selectModule then self.curModuleType = selectModule ModuleManager.MaincityManager:setCurModule(self.curModuleType) + self:setFormationVisible(true) + if self.curModuleType == GConst.MainCityConst.MAIN_MODULE.CHAPTER then -- 切换到主线章节 - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_CHAPTER) elseif self.curModuleType == GConst.MainCityConst.MAIN_MODULE.DAILY_CHALLENGE then -- 切换到每日挑战 - EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.GO_DAILY_CHALLENGE) if not DataManager.TutorialData:getIsInTutorial() and DataManager.DailyChallengeData:getIsPopTask() then ModuleManager.DailyChallengeManager:showBattleTaskUI() end + elseif self.curModuleType == GConst.MainCityConst.MAIN_MODULE.DUNGEON then + -- 切换到活动副本 + self:setFormationVisible(false) end + EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.CHANGE_MAIN_COMP_MODULE, self.curModuleType) end for idx, cell in pairs(self.moduleMap) do cell:getBaseObject():setActive(self.curModuleType == idx) end - local heroBg = self.uiMap["main_comp.hero_bg"] - local heroBgPosY = heroBg:fastGetAnchoredPositionY() - local sWidth, sHeight = GFunc.getUIExpandScreenSize() - local hSHeight = sHeight / 2 - self.btnPosY = (heroBgPosY + (BOTTOM_HEIGHT / 2 - hSHeight)) / 2 + self:refreshBtns() end @@ -62,17 +67,18 @@ end function MainComp:refreshFightBtn() local moduleCell = self.moduleMap[self.curModuleType] - self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) local cost = moduleCell:getHpCost() if cost then + self.uiMap["main_comp.fight_btn"]:setActive(true) + self.uiMap["main_comp.fight_btn"]:addClickListener(moduleCell.onClickFight) + self.uiMap["main_comp.fight_btn"]:setAnchoredPositionY(self.btnPosY) + self.uiMap["main_comp.fight_btn.desc"]:setText(I18N:getGlobalText(I18N.GlobalConst.START_DESC)) self.uiMap["main_comp.fight_btn.desc_2"]:setText(GFunc.getRewardNum(cost)) else - self.uiMap["main_comp.fight_btn.desc_2"]:setText("0") + self.uiMap["main_comp.fight_btn"]:setActive(false) + return end - self.uiMap["main_comp.fight_btn"]:addClickListener(moduleCell.onClickFight) - self.uiMap["main_comp.fight_btn"]:setAnchoredPositionY(self.btnPosY) - local remainCount = moduleCell:getTodayRemainCount() if remainCount >= 0 then self.uiMap["main_comp.fight_btn.num_tx"]:setActive(true) @@ -167,6 +173,16 @@ function MainComp:initStageFormation() self.uiMap["main_comp.hero_bg.hero_cell_4"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), self.uiMap["main_comp.hero_bg.hero_cell_5"]:addLuaComponent(GConst.TYPEOF_LUA_CLASS.HERO_CELL), } + + self.heroFormation = self.uiMap["main_comp.hero_bg"] + local heroBgPosY = self.heroFormation:fastGetAnchoredPositionY() + local sWidth, sHeight = GFunc.getUIExpandScreenSize() + local hSHeight = sHeight / 2 + self.btnPosY = (heroBgPosY + (BOTTOM_HEIGHT / 2 - hSHeight)) / 2 +end + +function MainComp:setFormationVisible(visible) + self.heroFormation:setVisible(visible) end function MainComp:refresh() diff --git a/lua/app/ui/main_city/component/main_comp_base_cell.lua b/lua/app/ui/main_city/component/main_comp_base_cell.lua index 99255a0f..9c43bbbf 100644 --- a/lua/app/ui/main_city/component/main_comp_base_cell.lua +++ b/lua/app/ui/main_city/component/main_comp_base_cell.lua @@ -20,7 +20,7 @@ function MainCompBaseCell:getShowEntranceRedPoint() end function MainCompBaseCell:getHpCost() - return 0 + return nil-- 默认不显示挑战按钮 end function MainCompBaseCell:getTodayRemainCount() diff --git a/lua/app/ui/main_city/main_city_ui.lua b/lua/app/ui/main_city/main_city_ui.lua index 16003828..232a707d 100644 --- a/lua/app/ui/main_city/main_city_ui.lua +++ b/lua/app/ui/main_city/main_city_ui.lua @@ -158,18 +158,8 @@ function MainCityUI:_addListeners() end end) - self:addEventListener(EventManager.CUSTOM_EVENT.GO_DAILY_CHALLENGE, function() - if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then - return - end - self:refreshBounty() - end) - - self:addEventListener(EventManager.CUSTOM_EVENT.GO_CHAPTER, function() - if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then - return - end - self:refreshBounty() + self:addEventListener(EventManager.CUSTOM_EVENT.CHANGE_MAIN_COMP_MODULE, function(module) + self:switchMainCompModule(module) end) DataManager.MailData:checkNewMail() end @@ -714,6 +704,23 @@ function MainCityUI:switchComp(index) end end +-- 切换主界面活动模块 +function MainCityUI:switchMainCompModule(moduleKey) + if self.selectedIndex ~= GConst.MainCityConst.BOTTOM_PAGE.MAIN then + return + end + + if moduleKey == GConst.MainCityConst.MAIN_MODULE.DUNGEON then + -- 活动副本切换刷新 + self:setTopNodeVisible(false) + self:setSideBarVisible(false) + else + self:setTopNodeVisible(true) + self:setSideBarVisible(true) + self:refreshBounty() + end +end + function MainCityUI:updateTime() if self.selectedIndex == GConst.MainCityConst.BOTTOM_PAGE.SHOP and self.subComps[self.selectedIndex] then if self.subComps[self.selectedIndex] then diff --git a/lua/app/userdata/daily_challenge/daily_challenge_data.lua b/lua/app/userdata/daily_challenge/daily_challenge_data.lua index cf1e8d6c..b642af3f 100644 --- a/lua/app/userdata/daily_challenge/daily_challenge_data.lua +++ b/lua/app/userdata/daily_challenge/daily_challenge_data.lua @@ -113,15 +113,6 @@ function DailyChallengeData:getBuffDesc(buffId) return I18N:getText("buff_daily_challenge", buffId, "desc") end --- 获取今日剩余时间 -function DailyChallengeData:getTodaySurplusTime() - local result = Time:getOverOfServerToday() - Time:getServerTime() - if result < 0 then - result = 0 - end - return result -end - -- 获取最终boss配置信息 function DailyChallengeData:getFinalBossInfo() if not self:isOpen() then diff --git a/lua/app/userdata/dungeon.meta b/lua/app/userdata/dungeon.meta new file mode 100644 index 00000000..690af9e8 --- /dev/null +++ b/lua/app/userdata/dungeon.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 256d487279ef573429ce63e3bb5ca819 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/lua/app/userdata/dungeon/dungeon_data.lua b/lua/app/userdata/dungeon/dungeon_data.lua new file mode 100644 index 00000000..a482c51a --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_data.lua @@ -0,0 +1,277 @@ +local DungeonData = class("DungeonData", BaseData) + +-- 所有活动副本数据 + +function DungeonData:ctor() +end + +function DungeonData:clear() +end + +-- 初始化金币副本数据 +function DungeonData:initDungeonGold(data) + if EDITOR_MODE then + data = { + today_challenge_count = 2, + max_chapter_gold_id = 2, + -- latest_chapter_gold_id = 1,-- todo 这是啥数据呢? + } + end + + self:initAllDataClass() + self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_GOLD]:init(data) +end + +-- 初始化碎片副本数据 +function DungeonData:initDungeonShards(data) + if EDITOR_MODE then + data = { + today_challenge_count = 2, + max_chapter_shards_id = 2, + -- latest_chapter_shards_id = 1, + } + end + + self:initAllDataClass() + self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_SHARDS]:init(data) +end + +-- 初始化所有副本数据类 +function DungeonData:initAllDataClass() + if self.dataDungeons == nil then + self.dataDungeons = {} + self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_GOLD] = require "app/userdata/dungeon/dungeon_gold_data_comp":create() + self.dataDungeons[ModuleManager.MODULE_KEY.DUNGEON_SHARDS] = require "app/userdata/dungeon/dungeon_shards_data_comp":create() + end + + self:updateOpenDungeons() +end + +-- 更新已开启副本 +function DungeonData:updateOpenDungeons() + self.openDungeons = {} + for key, value in pairs(self.dataDungeons) do + if self:isOpen(key) then + table.insert(self.openDungeons, key) + end + end + if EDITOR_MODE then + Logger.logHighlight("已开启副本:") + Logger.printTable(self.openDungeons) + end +end + +-- 是否开启任意一个副本 +function DungeonData:isOpenAnyone() + for key, value in pairs(self.dataDungeons) do + if self:isOpen(key) then + return true + end + end + return false +end + +-- 某副本是否已开启 +function DungeonData:isOpen(moduleKey) + if not ModuleManager:getIsOpen(moduleKey, true) then + return false + end + return true +end + +-- 返回已开启的副本 +function DungeonData:getOpenDungeons() + return self.openDungeons +end + +-- 是否在活动副本时间内 +function DungeonData:isActive(moduleKey) + if not self:isOpen(moduleKey) then + return false + end + + -- 判断周期 + if self:isActiveCycle(moduleKey, Time:getWeekByTimeStamp()) then + return true + else + return false + end +end + +-- 判断是否在活跃周期内 +function DungeonData:isActiveCycle(moduleKey, checkWeek) + if not self.dataDungeons[moduleKey] then + return false + end + + for index, week in ipairs(self.dataDungeons[moduleKey]:getOpenWeekCycle()) do + if week == checkWeek then + return true + end + end + return false +end + +-- 是否任意一个副本可以挑战 +function DungeonData:isCanChallengeAnyone() + for key, value in pairs(self.dataDungeons) do + if self:isCanChallenge(key) then + return true + end + end + return false +end + +-- 副本是否可以挑战 +function DungeonData:isCanChallenge(moduleKey) + if not self:isActive(moduleKey) then + return false + end + if not (self:getRemainTimes(moduleKey) > 0) then + return false + end + if not self:isEnoughHp(moduleKey) then + return false + end + return true +end + +-- 副本是否可以扫荡 +function DungeonData:isCanSweep(moduleKey, id) + if not self:isActive(moduleKey) then + return false + end + if not (self:getRemainTimes(moduleKey) > 0) then + return false + end + if not self:isEnoughHp(moduleKey) then + return false + end + if not self:getPassedMaxId(moduleKey) >= id then + return false + end + return true +end + +-- 获取副本今日剩余次数 +function DungeonData:getRemainTimes(moduleKey) + if not self:isActive(moduleKey) then + return 0 + end + if not self.dataDungeons[moduleKey] then + return 0 + end + + return self.dataDungeons[moduleKey]:getTodayRemainLimitCount() +end + +-- 体力是否足够 +function DungeonData:isEnoughHp(moduleKey) + local const = self:getChallengeHpCost(moduleKey) + local constNum = 0 + if const then + constNum = GFunc.getRewardNum(const) + end + return constNum <= DataManager.BagData.ItemData:getVit() +end + +-- 获取挑战体力消耗 +function DungeonData:getChallengeHpCost(moduleKey) + if not self:isActive(moduleKey) then + return 0 + end + if not self.dataDungeons[moduleKey] then + return 0 + end + + return self.dataDungeons[moduleKey]:getChallengeHpCost() +end + +-- 获取副本开启倒计时 +function DungeonData:getOpenTime(moduleKey) + if not self.dataDungeons[moduleKey] then + return 0 + end + + local isClose = true + local count = 0 + while isClose do + local checkWeek = Time:getWeekByTimeStamp(self:getServerTime() + ((count + 1) * 86400)) + if self:isActiveCycle(moduleKey, checkWeek) then + isClose = false + else + count = count + 1 + end + end + + return Time:getTodaySurplusTime() + (count * 86400) +end + +-- 获取副本关闭倒计时 +function DungeonData:getCloseTime(moduleKey) + if not self.dataDungeons[moduleKey] then + return 0 + end + + local isActive = true + local count = 0 + while isActive do + local checkWeek = Time:getWeekByTimeStamp(self:getServerTime() + ((count + 1) * 86400)) + if not self:isActiveCycle(moduleKey, checkWeek) then + isActive = false + else + count = count + 1 + end + end + + return Time:getTodaySurplusTime() + (count * 86400) +end + +-- 获取看板展示的副本奖励 +function DungeonData:getBoardShowRewards(moduleKey) + return nil +end + +-- 获取展示副本首通奖励 +function DungeonData:getFirstReward(moduleKey, id) + -- 通关后,不展示首通奖励 + return self.dataDungeons[moduleKey]:getFirstReward(id) +end + +-- 获取展示副本通关奖励 +function DungeonData:getPassReward(moduleKey, id) + -- 波次奖励数量==通关+波次奖励数量 + return self.dataDungeons[moduleKey]:getPassReward(id) +end + +--获取副本已通关的最高关卡id +function DungeonData:getPassedMaxId(moduleKey) + return self.dataDungeons[moduleKey]:getPassedMaxId() +end + +-- 获取副本标题文案 +function DungeonData:getTitle(moduleKey) + return self.dataDungeons[moduleKey]:getTitleString() +end + +-- 获取副本规则描述 +function DungeonData:getRule(moduleKey) + return self.dataDungeons[moduleKey]:getRuleString() +end + +-- 获取副本开启时间描述 +function DungeonData:getOpenTimeDesc(moduleKey) + return self.dataDungeons[moduleKey]:getOpenWeekString() +end + +-- 获取副本角标图 +function DungeonData:getIcon(moduleKey) + return self.dataDungeons[moduleKey]:getIcon() +end + +-- 获取副本banner图 +function DungeonData:getBanner(moduleKey) + return self.dataDungeons[moduleKey]:getBanner() +end + +return DungeonData \ No newline at end of file diff --git a/lua/app/userdata/dungeon/dungeon_data.lua.meta b/lua/app/userdata/dungeon/dungeon_data.lua.meta new file mode 100644 index 00000000..27a7e375 --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_data.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 0dea895676e488b45ac59508224e0564 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/dungeon/dungeon_data_base_comp.lua b/lua/app/userdata/dungeon/dungeon_data_base_comp.lua new file mode 100644 index 00000000..4d391991 --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_data_base_comp.lua @@ -0,0 +1,87 @@ +local DungeonDataBaseComp = class("DungeonDataBaseComp", LuaComponent) + +-- 需要继承重写的部分 *********************************************************** + +-- 初始化服务器数据 +function DungeonDataBaseComp:init(data) +end + +-- 获取副本模块名,对应ModuleManager.MODULE_KEY +function DungeonDataBaseComp:getModuleKey() + return "" +end + +-- 获取副本开启周期(星期几) +function DungeonDataBaseComp:getOpenWeekCycle() + return {} +end + +-- 获取副本标题文案 +function DungeonDataBaseComp:getTitleString() + return "" +end + +-- 获取副本规则描述 +function DungeonDataBaseComp:getRuleString() + return "" +end + +-- 获取开始时间描述 +function DungeonDataBaseComp:getOpenWeekString() + return "" +end + +-- 获取副本角标图 +function DungeonDataBaseComp:getIcon() + return "" +end + +-- 获取副本banner图 +function DungeonDataBaseComp:getBanner() + return "" +end + +-- 获取今日已挑战次数 +function DungeonDataBaseComp:getTodayChallengeCount() + return 0 +end + +-- 获取已通关的最大副本id +function DungeonDataBaseComp:getPassedMaxId() + return 0 +end + +-- 获取挑战体力消耗 +function DungeonDataBaseComp:getChallengeHpCost() + return 0 +end + +-- 获取每日最大挑战次数 +function DungeonDataBaseComp:getTodayMaxCount() + return 0 +end + +-- 获取看板展示的副本奖励 +function DungeonDataBaseComp:getBoardShowReward() + return nil +end + +-- 获取首通奖励 +function DungeonDataBaseComp:getFirstReward() + return nil +end + +-- 获取通关奖励(通关+波次奖励 or 百分比奖励) +function DungeonDataBaseComp:getPassReward() + return nil +end + + +-- 常规逻辑 ********************************************************************* + +-- 获取今日剩余挑战次数 +function DungeonDataBaseComp:getTodayRemainLimitCount() + return self:getTodayMaxCount() - self:getTodayChallengeCount() +end + +return DungeonDataBaseComp \ No newline at end of file diff --git a/lua/app/userdata/dungeon/dungeon_data_base_comp.lua.meta b/lua/app/userdata/dungeon/dungeon_data_base_comp.lua.meta new file mode 100644 index 00000000..76653357 --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_data_base_comp.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 4e42e026c21002845b2e72498b2e2e92 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/dungeon/dungeon_gold_data_comp.lua b/lua/app/userdata/dungeon/dungeon_gold_data_comp.lua new file mode 100644 index 00000000..9f48acdb --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_gold_data_comp.lua @@ -0,0 +1,67 @@ +local DungeonDataBaseComp = require "app/userdata/dungeon/dungeon_data_base_comp" +local DungeonGoldDataComp = class("DungeonGoldDataComp", DungeonDataBaseComp) + +-- 金币副本数据 + +function DungeonGoldDataComp:init(data) + self.todayChallengeCount = data.today_challenge_count + self.maxPassedId = data.max_chapter_gold_id +end + +function DungeonDataBaseComp:getTodayChallengeCount() + return self.todayChallengeCount +end + +function DungeonDataBaseComp:getPassedMaxId() + return self.maxPassedId +end + +function DungeonGoldDataComp:getModuleKey() + return ModuleManager.MODULE_KEY.DUNGEON_GOLD +end + +function DungeonGoldDataComp:getOpenWeekCycle() + return {2,4,6,7} +end + +function DungeonGoldDataComp:getTitleString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_GOLD_TITLE) +end + +function DungeonGoldDataComp:getRuleString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_GOLD_HELP) +end + +function DungeonGoldDataComp:getOpenWeekString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_GOLD_OPEN) +end + +function DungeonGoldDataComp:getIcon() + return "" +end + +function DungeonGoldDataComp:getBanner() + return "" +end + +function DungeonGoldDataComp:getChallengeHpCost() + return GFunc.getConstReward("dungeon_gold_cost") +end + +function DungeonGoldDataComp:getTodayMaxCount() + return GFunc.getConstIntValue("dungeon_gold_limit") +end + +function DungeonGoldDataComp:getBoardShowReward() + return nil +end + +function DungeonGoldDataComp:getFirstReward(id) + return ConfigManager:getConfig("chapter_dungeon_gold")[id].first_pass_reward +end + +function DungeonGoldDataComp:getPassReward(id) + return ConfigManager:getConfig("chapter_dungeon_gold")[id].percent_reward +end + +return DungeonGoldDataComp \ No newline at end of file diff --git a/lua/app/userdata/dungeon/dungeon_gold_data_comp.lua.meta b/lua/app/userdata/dungeon/dungeon_gold_data_comp.lua.meta new file mode 100644 index 00000000..59bba927 --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_gold_data_comp.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 962fc33db86976b4cbcd1205a2fbdd82 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3} diff --git a/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua b/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua new file mode 100644 index 00000000..4b3661e9 --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua @@ -0,0 +1,70 @@ +local DungeonDataBaseComp = require "app/userdata/dungeon/dungeon_data_base_comp" +local DungeonShardsDataComp = class("DungeonShardsDataComp", DungeonDataBaseComp) + +-- 碎片副本数据 + +function DungeonShardsDataComp:init(data) + self.todayChallengeCount = data.today_challenge_count + self.maxPassedId = data.max_chapter_shards_id +end + +function DungeonDataBaseComp:getTodayChallengeCount() + return self.todayChallengeCount +end + +function DungeonDataBaseComp:getPassedMaxId() + return self.maxPassedId +end + +function DungeonShardsDataComp:getModuleKey() + return ModuleManager.MODULE_KEY.DUNGEON_SHARDS +end + +function DungeonShardsDataComp:getOpenWeekCycle() + return {1,3,5,7} +end + +function DungeonShardsDataComp:getTitleString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_SHARDS_TITLE) +end + +function DungeonShardsDataComp:getRuleString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_SHARDS_HELP) +end + +function DungeonShardsDataComp:getOpenWeekString() + return I18N:getGlobalText(I18N.GlobalConst.DUNGEON_SHARDS_OPEN) +end + +function DungeonShardsDataComp:getIcon() + return "" +end + +function DungeonShardsDataComp:getBanner() + return "" +end + +function DungeonShardsDataComp:getChallengeHpCost() + return GFunc.getConstReward("dungeon_shards_cost") +end + +function DungeonShardsDataComp:getTodayMaxCount() + return GFunc.getConstIntValue("dungeon_shards_limit") +end + +function DungeonShardsDataComp:getBoardShowReward() + return nil +end + +function DungeonShardsDataComp:getFirstReward(id) + return ConfigManager:getConfig("chapter_dungeon_shards")[id].first_pass_reward +end + +function DungeonShardsDataComp:getPassReward(id) + local pass = ConfigManager:getConfig("chapter_dungeon_shards")[id].pass_reward + local wave = ConfigManager:getConfig("chapter_dungeon_shards")[id].wave_reward + -- todo 处理奖励结构 + return pass +end + +return DungeonShardsDataComp \ No newline at end of file diff --git a/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua.meta b/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua.meta new file mode 100644 index 00000000..da7d0728 --- /dev/null +++ b/lua/app/userdata/dungeon/dungeon_shards_data_comp.lua.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: a6126d3822550ed449313e7bdb7b6fe1 +ScriptedImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 2 + userData: + assetBundleName: + assetBundleVariant: + script: {fileID: 11500000, guid: 3b8b241bab4a4ac9a22fcce9c64f1242, type: 3}