This commit is contained in:
chenxi 2023-05-22 21:23:07 +08:00
parent 3f747de9aa
commit 78e03328ce
22 changed files with 198 additions and 73 deletions

View File

@ -79,6 +79,7 @@ BIReport.ADS_CLICK_TYPE = {
TASK_DAILY_REFRESH = "TaskDailyRefresh",
TASK_DAILY_TASK = "TaskDailyTask",
IDLE_QUICK_DROP = "IdleQuickDrop",
MAIL = "Mail",
}
BIReport.FIGHT_OPT_TYPE = {

View File

@ -15,7 +15,7 @@ function DataManager:init()
self:initManager("TutorialData", "app/userdata/tutorial/tutorial_data")
self:initManager("MailData", "app/userdata/mail/mail_data")
self:initManager("ActivityData", "app/userdata/activity/activity_data")
self:initManager("GodPigData", "app/userdata/activity/god_pig/god_pig_data")
self:initManager("GoldPigData", "app/userdata/activity/gold_pig/gold_pig_data")
self:initManager("BountyData", "app/userdata/bounty/bounty_data")
self:initManager("DailyTaskData", "app/userdata/task/daily_task_data")
self:initManager("IdleData", "app/userdata/idle/idle_data")
@ -84,7 +84,7 @@ function DataManager:clear()
self.FormationData:clear()
self.ActivityData:clear()
self.MailData:clear()
self.GodPigData:clear()
self.GoldPigData:clear()
self.BountyData:clear()
self.DailyTaskData:clear()
self.IdleData:clear()
@ -114,7 +114,7 @@ function DataManager:initWithServerData(data)
self.TutorialData:init(data.guide)
self.MailData:init(data.mail_info)
self.ActivityData:init()
self.GodPigData:init(data.pig)
self.GoldPigData:init(data.pig)
self.BountyData:init(data.bounty)
-- 任务要在BountyData之后初始化依赖BountyData的数据
self.DailyTaskData:init(data.task_daily)

View File

@ -25,6 +25,7 @@ EventManager.CUSTOM_EVENT = {
LOGIN_REQ_SUCCESS = "LOGIN_REQ_SUCCESS",
DAILY_TASK_ADD_PROGRESS = "DAILY_TASK_ADD_PROGRESS",
BOSS_ENTER_ANI_OVER = "BOSS_ENTER_ANI_OVER",
TIME_TRIGGERED_NEW_EMAIL = "TIME_TRIGGERED_NEW_EMAIL" -- 邮件到时间请求是否有新邮件
-- BORAD_TOUCH_BEGIN = "BORAD_TOUCH_BEGIN",
-- BORAD_TOUCH_OVER = "BORAD_TOUCH_OVER"
}

View File

@ -191,6 +191,13 @@ function Time:getDayofWeek(time)
return day
end
function Time:getDayofWeekUTC(time)
local curTime = time or self:getServerTime()
local day = tonumber(os.date("!%w", curTime))
day = day == 0 and 7 or day
return day
end
-- 00:00:00
function Time:formatNumTime(time)
if time <= 0 then

View File

@ -91,7 +91,7 @@ function ChapterManager:endFightFinish(result)
ModuleManager.BattleManager:showBattleResultUI(newRewards, reqData.combatReport, mysteryBoxIdx)
DataManager.ChapterData:fightChapter(reqData.chapter_id, result.max_chapter_id, result.max_wave, reqData.mystery_box_idx)
-- 处理金猪
-- DataManager.GodPigData:addGoldPigCount()
-- DataManager.GoldPigData:addGoldPigCount()
local newMaxChapter = DataManager.ChapterData:getNewChapterId()
if maxChapter ~= newMaxChapter then

View File

@ -66,6 +66,13 @@ Example: chapter 5 10 参数1 章节 参数2 波次]],
Example: reset_bounty]],
type = "reset_bounty"
},
{
title = "添加邮件",
desc = [[ type:add_mail
arg1:id
Example: add_mail 1]],
type = "add_mail"
},
}
return GMConst

View File

@ -148,7 +148,7 @@ function LoginManager:loginFinish(data)
CS.ThinkingAnalytics.ThinkingAnalyticsAPI.UserSet(data)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.LOGIN_REQ_SUCCESS)
-- ModuleManager.MailManager:getMailList(true)
ModuleManager.MailManager:getMailList(true)
DataManager:setLoginSuccess(true)
BIReport:postGameLoginFinish()

View File

@ -128,8 +128,8 @@ function MailManager:readMailFinish(result)
end
function MailManager:needUpdateMail()
DataManager.MailData:setNeedGetNewMail(true)
DataManager.MailData:setDirty()
-- 收到推送后不一定是有新邮件,要去拉一下
self:getMailList(true)
end
return MailManager

View File

@ -23,7 +23,7 @@ MainCityConst.LEFT_SIDE_BARS = {
}
MainCityConst.RIGHT_SIDE_BARS = {
"app/ui/main_city/cell/side_bar_god_pig_cell",
"app/ui/main_city/cell/side_bar_gold_pig_cell",
}
return MainCityConst

View File

@ -45,6 +45,8 @@ local ProtoMsgType = {
[2118853729] = "HeroUpgradeRsp",
[2285872137] = "ChapterBoxRewardReq",
[2285873970] = "ChapterBoxRewardRsp",
[2429586383] = "MailCycleReq",
[2429588216] = "MailCycleRsp",
[2515553923] = "BuyMallDailyReq",
[2515555756] = "BuyMallDailyRsp",
[2581180989] = "MailListReq",
@ -86,6 +88,8 @@ local ProtoMsgType = {
[3663247602] = "MallDailyResetNtf",
[3663314292] = "MallDailyResetReq",
[3663316125] = "MallDailyResetRsp",
[3741702491] = "MallDailyOverDayReq",
[3741704324] = "MallDailyOverDayRsp",
[3757169544] = "BountyRewardReq",
[3757171377] = "BountyRewardRsp",
[3763117270] = "HeartbeatReq",
@ -145,6 +149,8 @@ local ProtoMsgType = {
HeroUpgradeRsp = 2118853729,
ChapterBoxRewardReq = 2285872137,
ChapterBoxRewardRsp = 2285873970,
MailCycleReq = 2429586383,
MailCycleRsp = 2429588216,
BuyMallDailyReq = 2515553923,
BuyMallDailyRsp = 2515555756,
MailListReq = 2581180989,
@ -186,6 +192,8 @@ local ProtoMsgType = {
MallDailyResetNtf = 3663247602,
MallDailyResetReq = 3663314292,
MallDailyResetRsp = 3663316125,
MallDailyOverDayReq = 3741702491,
MallDailyOverDayRsp = 3741704324,
BountyRewardReq = 3757169544,
BountyRewardRsp = 3757171377,
HeartbeatReq = 3763117270,
@ -245,6 +253,8 @@ local ProtoMsgType = {
HeroUpgradeRsp = "HeroUpgradeRsp",
ChapterBoxRewardReq = "ChapterBoxRewardReq",
ChapterBoxRewardRsp = "ChapterBoxRewardRsp",
MailCycleReq = "MailCycleReq",
MailCycleRsp = "MailCycleRsp",
BuyMallDailyReq = "BuyMallDailyReq",
BuyMallDailyRsp = "BuyMallDailyRsp",
MailListReq = "MailListReq",
@ -286,6 +296,8 @@ local ProtoMsgType = {
MallDailyResetNtf = "MallDailyResetNtf",
MallDailyResetReq = "MallDailyResetReq",
MallDailyResetRsp = "MallDailyResetRsp",
MallDailyOverDayReq = "MallDailyOverDayReq",
MallDailyOverDayRsp = "MallDailyOverDayRsp",
BountyRewardReq = "BountyRewardReq",
BountyRewardRsp = "BountyRewardRsp",
HeartbeatReq = "HeartbeatReq",

View File

@ -5,14 +5,35 @@ function GoldPigUI:isFullScreen()
end
function GoldPigUI:getPrefabPath()
return "assets/prefabs/ui/activity/god_pig/gold_pig_ui.prefab"
return "assets/prefabs/ui/activity/gold_pig/gold_pig_ui.prefab"
end
function GoldPigUI:onLoadRootComplete()
local uiMap = self.root:genAllChildren()
uiMap["gold_pig_ui.gift_bg.buy_btn"]:addClickListener(function()
uiMap["gold_pig_ui.bg.close_btn"]:addClickListener(function()
self:closeUI()
end)
uiMap["gold_pig_ui.bg.title_tx"]:setText("临时文本:超值金猪")
uiMap["gold_pig_ui.bg.desc_tx"]:setText("临时文本:挑战关卡并收集钻石,你就可以获得一笔划算的交易。")
uiMap["gold_pig_ui.bg.value_bg.tx"]:setText("临时文本:300%")
local currGem = DataManager.GoldPigData:getGoldPigGemCount()
local maxGem = DataManager.GoldPigData:getGoldPigGemMaxCount()
local nowGemTx = uiMap["gold_pig_ui.bg.slider.now_gem_bg.gem_tx"]
nowGemTx:setText(GFunc.intToString(currGem))
local nowGemImg = uiMap["gold_pig_ui.bg.slider.now_gem_bg.gem_img"]
GFunc.centerImgAndTx(nowGemImg, nowGemTx, 0, -4)
local maxGemTx = uiMap["gold_pig_ui.bg.slider.max_gem_bg.gem_tx"]
maxGemTx:setText(GFunc.intToString(maxGem))
local maxGemImg = uiMap["gold_pig_ui.bg.slider.max_gem_bg.gem_img"]
GFunc.centerImgAndTx(maxGemImg, maxGemTx, 0, -4)
uiMap["gold_pig_ui.bg.slider"]:getComponent(GConst.TYPEOF_UNITY_CLASS.BF_SLIDER).value = currGem / maxGem
uiMap["gold_pig_ui.bg.buy_btn"]:addClickListener(function()
end)
local rechargeId = DataManager.GoldPigData:getRechargeId()
uiMap["gold_pig_ui.bg.buy_btn.text"]:setText(GFunc.getFormatPrice(rechargeId))
end
return GoldPigUI

View File

@ -81,7 +81,7 @@ function BountyBuyUI:initBtns()
local buyProBountyAddLevels = DataManager.BountyData:getBuyProBountyAddLevelCount()
if level > maxLevel - buyProBountyAddLevels then
local params = {
content = "购买此通行证会超过通行证等级上限,会造成损失,是否购买?",
content = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_DESC_4),
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
okFunc = function()
self:closeUI()

View File

@ -70,7 +70,7 @@ function MessageBox:showMessageBox(params)
uiMap["message_box.title_bg_img.title_text"]:setText(titleTx)
uiMap["message_box.title_bg_img.bg.content_tx"]:setText(content)
uiMap["message_box.title_bg_img.btn.cancel_btn.text"]:setText(cancelText or I18N:getGlobalText(I18N.GlobalConst.CANCEL_1))
uiMap["message_box.title_bg_img.btn.cancel_btn.text"]:setText(cancelText or I18N:getGlobalText(I18N.GlobalConst.BTN_TEXT_CANCEL))
if boxType == GConst.MESSAGE_BOX_TYPE.MB_OK then
uiMap["message_box.title_bg_img.btn.cancel_btn"]:setVisible(false)

View File

@ -1,16 +0,0 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarGodPigCell = class("SideBarGodPigCell", SideBarBaseCellComp)
function SideBarGodPigCell:getIsOpen()
return false
end
function SideBarGodPigCell:getIconRes()
return "main_btn_pig"
end
function SideBarGodPigCell:onClick()
ModuleManager.ActivityManager:showGoldPigUI()
end
return SideBarGodPigCell

View File

@ -0,0 +1,16 @@
local SideBarBaseCellComp = require "app/ui/main_city/cell/side_bar_base_cell"
local SideBarGoldPigCell = class("SideBarGoldPigCell", SideBarBaseCellComp)
function SideBarGoldPigCell:getIsOpen()
return true
end
function SideBarGoldPigCell:getIconRes()
return "main_btn_pig"
end
function SideBarGoldPigCell:onClick()
ModuleManager.ActivityManager:showGoldPigUI()
end
return SideBarGoldPigCell

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4997d640a2606ed4288d0d6d708d7cea
guid: 93980678bfb82024380ec443e5da7099
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

View File

@ -110,6 +110,13 @@ function MainCityUI:_display()
end
function MainCityUI:_addListeners()
self:addEventListener(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL, function()
local time = math.random(10000, 30000) / 20000
ModuleManager.MailManager:performWithDelayGlobal(function()
ModuleManager.MailManager:getTriggeredTimeMail()
end, time)
end)
DataManager.MailData:checkNewMail()
end
function MainCityUI:_bind()

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 97616c4602b36c14eb280f12d16bdd56
guid: 1f9faf25e847f994892adf3d644b9969
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@ -1,6 +1,6 @@
local GodPigData = class("GodPigData", BaseData)
local GoldPigData = class("GoldPigData", BaseData)
function GodPigData:init(data)
function GoldPigData:init(data)
data = data or GConst.EMPTY_TABLE
self.data.id = data.id or 0
if self.data.id == 0 then
@ -12,11 +12,11 @@ function GodPigData:init(data)
self.data.isOpen = false
end
function GodPigData:getIsOpen()
function GoldPigData:getIsOpen()
return self.data.isOpen
end
function GodPigData:addGoldPigCount()
function GoldPigData:addGoldPigCount()
if not self.data.isOpen then
self:tryActiveGoldPig()
return
@ -34,47 +34,67 @@ function GodPigData:addGoldPigCount()
end
end
function GodPigData:getFirstLevelId()
function GoldPigData:getGoldPigGemCount()
return self.data.count
end
function GoldPigData:getGoldPigGemMaxCount()
local info = self:getCurrLevelInfo()
if info == nil then
return 1
end
return info.max_diamond
end
function GoldPigData:getRechargeId()
local info = self:getCurrLevelInfo()
if info == nil then
return 0
end
return info.recharge_id
end
function GoldPigData:getFirstLevelId()
if self.firstLevelId == nil then
self.firstLevelId = ConfigManager:getConfig("const")["act_gold_pig_first_id"].value
end
return self.firstLevelId
end
function GodPigData:getTimeOverCD()
function GoldPigData:getTimeOverCD()
if self.timeOverCD == nil then
self.timeOverCD = ConfigManager:getConfig("const")["act_gold_pig_cd"].value * 3600
end
return self.timeOverCD
end
function GodPigData:getBoughtCD()
function GoldPigData:getBoughtCD()
if self.boughtCD == nil then
self.boughtCD = ConfigManager:getConfig("const")["act_gold_pig_buy_cd"].value * 3600
end
return self.boughtCD
end
function GodPigData:getCfg()
function GoldPigData:getCfg()
if self.cfg == nil then
self.cfg = ConfigManager:getConfig("act_god_pig")
self.cfg = ConfigManager:getConfig("act_gold_pig")
end
return self.cfg
end
function GodPigData:getDuration()
function GoldPigData:getDuration()
if self.duration == nil then
self.duration = ConfigManager:getConfig("const")["act_gold_pig_full_cd"].value * 3600
end
return self.duration
end
function GodPigData:getCurrLevelInfo()
function GoldPigData:getCurrLevelInfo()
local cfg = self:getCfg()
return cfg[self.data.id]
end
function GodPigData:tryActiveGoldPig()
function GoldPigData:tryActiveGoldPig()
if not ModuleManager:getIsOpen(ModuleManager.MODULE_KEY.GOLD_PIG, true) then
return
end
@ -89,7 +109,7 @@ function GodPigData:tryActiveGoldPig()
end
-- 时间到了,消失并降档
function GodPigData:onTimeOver()
function GoldPigData:onTimeOver()
if not self.data.isOpen then
return
end
@ -105,7 +125,7 @@ function GodPigData:onTimeOver()
end
-- 购买后,消失并升档位
function GodPigData:onBought(id)
function GoldPigData:onBought(id)
if not self.data.isOpen then
return
end
@ -118,4 +138,4 @@ function GodPigData:onBought(id)
self.data.cd = self:getBoughtCD()
end
return GodPigData
return GoldPigData

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: b67c66ef72d69404bba1a01a2e3c400a
guid: f25fb374307a0744fbe9ea15052f86c5
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}

View File

@ -173,10 +173,6 @@ function BountyData:getMaxLevel()
return #self.bountyLevelCfg
end
function BountyData:getBountyLevelCfg()
return self.bountyLevelCfg
end
function BountyData:getAllProRewards()
if self.proRewards and #self.proRewards > 0 then
return self.proRewards

View File

@ -9,6 +9,7 @@ local TIME_TYPE = {
}
function MailData:ctor()
self.mails = {}
self.checkNewMailTimsList = {}
self.needGetNewMail = false
self.data.isDirty = false
self.data.redPoint = false
@ -20,6 +21,8 @@ function MailData:clear()
self.data.redPoint = false
self.lastMailId = nil
self.mailIsOpen = false
DataManager:unregisterDataCd("MailData")
DataManager:unregisterCrossDayFunc("MailData")
end
function MailData:init(data)
@ -30,48 +33,98 @@ function MailData:init(data)
self:updateRedPointCd()
DataManager:registerDataCd("MailData")
DataManager:registerCrossDayFunc("MailData", function()
self:updateRedPointCd()
end)
end
function MailData:updateRedPointCd()
self.needUpdateRedPointInfo = {}
for i = 1, #self.checkNewMailTimsList do
table.remove(self.checkNewMailTimsList)
end
local cfg = ConfigManager:getConfig("mail")
for i,v in ipairs(cfg) do
if v.time_type == TIME_TYPE.DAY then
for ii = 1, 7 do
self.needUpdateRedPointInfo[ii] = self.needUpdateRedPointInfo[ii] or {}
if #v.time_send == 3 then
local time = v.time_send[1] * 3600 + v.time_send[2] * 60 + v.time_send[3]
if not table.containValue(self.needUpdateRedPointInfo[ii], time) then
table.insert(self.needUpdateRedPointInfo[ii], time)
local time = v.time_send[1] * 3600 + v.time_send[2] * 60 + v.time_send[3] + 1
local currTime = Time:getServerTime() % 86400
if time >= currTime then
local find = false
for k, v in ipairs(self.checkNewMailTimsList) do
if v == time then
find = true
break
end
end
if not find then
table.insert(self.checkNewMailTimsList, time)
end
end
end
elseif v.time_type == TIME_TYPE.WEEK then
if #v.time_send == 4 then
if #v.time_send == 4 then -- 周几,时,分,秒
local day = v.time_send[1]
self.needUpdateRedPointInfo[day] = self.needUpdateRedPointInfo[day] or {}
local time = v.time_send[2] * 3600 + v.time_send[3] * 60 + v.time_send[4]
if not table.containValue(self.needUpdateRedPointInfo[day], time) then
table.insert(self.needUpdateRedPointInfo[day], time)
if day == Time:getDayofWeekUTC() then
local time = v.time_send[2] * 3600 + v.time_send[3] * 60 + v.time_send[4] + 1
local currTime = Time:getServerTime() % 86400
if time >= currTime then
local find = false
for k, v in ipairs(self.checkNewMailTimsList) do
if v == time then
find = true
break
end
end
if not find then
table.insert(self.checkNewMailTimsList, time)
end
end
end
end
elseif v.time_type == TIME_TYPE.MONTH then
--TODO 暂时没有 无数据格式
if #v.time_send == 4 then -- 几号,时,分,秒
local offsetSeconds = math.floor(Time:getClientTimeZone() * 3600)
local time = Time:getServerTime()
local utcNow = os.date('!*t', time)
local targetTime = math.floor(os.time({day = v.time_send[1], month = utcNow.month, year = utcNow.year, hour = v.time_send[2], min = v.time_send[3], sec = v.time_send[4]})) + offsetSeconds
if targetTime >= time then -- 还没到目标时间
local diff = targetTime - time
local todayRemainTime = time % 86400 -- 到今天24点还剩余的秒数
if diff <= todayRemainTime then -- 今天内就能达到目标时间
local targetRemainTime = targetTime % 86400
local find = false
for k, v in ipairs(self.checkNewMailTimsList) do
if v == targetRemainTime then
find = true
break
end
end
if not find then
table.insert(self.checkNewMailTimsList, targetRemainTime)
end
end
end
end
end
end
end
function MailData:checkNewMail()
if #self.checkNewMailTimsList <= 0 then
return
end
local nowTime = Time:getServerTime() % 86400
for i = #self.checkNewMailTimsList, 1, -1 do
if self.checkNewMailTimsList[i] <= nowTime then
table.remove(self.checkNewMailTimsList, i)
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL)
break
end
end
end
function MailData:updateCd()
local nowTime = Time:getServerTime()
local today = Time:getDayofWeek()
local times = self.needUpdateRedPointInfo[today] or {}
local curTime = nowTime % 86400
for i, v in ipairs(times) do
if v == curTime then
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.TIME_TRIGGERED_NEW_EMAIL)
break
end
end
self:checkNewMail()
end
function MailData:addMails(mails)