115 lines
4.9 KiB
Lua
115 lines
4.9 KiB
Lua
local ActivityManager = class("ActivityManager", BaseModule)
|
||
|
||
-- 夏日活动分界线-----------------------------------------------------------------------------------------------------
|
||
|
||
function ActivityManager:showActivityUI(panelType)
|
||
if panelType == GConst.ActivityConst.PANEL_TYPE.SKIN then
|
||
UIManager:showUI("app/ui/activity/activity_gift_skin_ui", panelType)
|
||
elseif panelType == GConst.ActivityConst.PANEL_TYPE.HERO then
|
||
UIManager:showUI("app/ui/activity/activity_gift_hero_ui", panelType)
|
||
else
|
||
UIManager:showUI("app/ui/activity/activity_ui", panelType)
|
||
end
|
||
end
|
||
|
||
-- 购买夏日活动战令
|
||
function ActivityManager:buySummerBounty(giftId)
|
||
PayManager:purchasePackage(giftId, PayManager.PURCHARSE_TYPE.ACT_GIFT)
|
||
end
|
||
|
||
-- 初始化夏日活动计时器
|
||
function ActivityManager:initSummerTimer()
|
||
self:unscheduleGlobal(self.summerSid)
|
||
|
||
if DataManager.ActivityData:isActive() then
|
||
Logger.logHighlight("夏日活动结束倒计时:"..DataManager.ActivityData:getEndRemainTime())
|
||
self.summerSid = self:performWithDelayGlobal(function()
|
||
-- 夏日活动结束
|
||
Logger.logHighlight("夏日活动结束")
|
||
EventManager:dispatchEvent(EventManager.CUSTOM_EVENT.ACTIVITY_SUMMER_END)
|
||
end, DataManager.ActivityData:getEndRemainTime())
|
||
elseif DataManager.ActivityData:getStartRemainTime() > 0 then
|
||
Logger.logHighlight("夏日活动开始倒计时:"..DataManager.ActivityData:getStartRemainTime())
|
||
self.summerSid = self:performWithDelayGlobal(function()
|
||
-- 夏日活动结束
|
||
Logger.logHighlight("夏日活动开始")
|
||
self:reqSummerData()
|
||
end, DataManager.ActivityData:getStartRemainTime())
|
||
end
|
||
end
|
||
|
||
-- 请求夏日活动数据
|
||
function ActivityManager:reqSummerData()
|
||
if not DataManager.ActivityData:isOpen() then
|
||
return
|
||
end
|
||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerDataReq, {}, {}, self.rspSummerData, nil)
|
||
end
|
||
|
||
function ActivityManager:rspSummerData(result)
|
||
if result.summer then
|
||
DataManager.ActivityData:onGetActData(result.summer)
|
||
end
|
||
end
|
||
|
||
-- 请求夏日活动任务奖励
|
||
function ActivityManager:reqSummerTaskReward(id)
|
||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerTaskClaimReq, {id = id, stage = DataManager.ActivityData:getTaskStage(id)}, {}, self.rspSummerTaskReward, nil)
|
||
end
|
||
|
||
function ActivityManager:rspSummerTaskReward(result)
|
||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||
DataManager.ActivityData:onReceivedTaskReward(result.reqData.id, result.stage, result.level, result.exp)
|
||
|
||
BIReport:postActOpt(BIReport.ACTIVITY_SUMMER.TASK_REWARD, DataManager.ActivityData:getActId(), DataManager.ActivityData:getBountyLevel(), DataManager.ActivityData:getBountyLevelScore(), 0)
|
||
end
|
||
end
|
||
|
||
-- 请求夏日活动战令奖励,id为0就是领取档位全部可领奖励
|
||
function ActivityManager:reqSummerBountyReward(id, grade)
|
||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimReq, {id = id, grade = grade}, {}, self.rspSummerBountyReward, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_REWARD)
|
||
end
|
||
|
||
function ActivityManager:rspSummerBountyReward(result)
|
||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||
DataManager.ActivityData:onReceivedBountyReward(result.success_id_grade)
|
||
|
||
GFunc.showRewardBox(result.rewards)
|
||
end
|
||
end
|
||
|
||
-- 购买战令等级
|
||
function ActivityManager:reqBuyBountyLevel()
|
||
local cost = DataManager.ActivityData:getBuyBountyLevelCost()
|
||
local costId = GFunc.getRewardId(cost)
|
||
local costNum = GFunc.getRewardNum(cost)
|
||
if not GFunc.checkCost(costId, costNum, true) then
|
||
return
|
||
end
|
||
local params ={
|
||
titleTx = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_TITLE),
|
||
content = I18N:getGlobalText(I18N.GlobalConst.BOUNTY_BUY_LEVEL_COUNTENT),
|
||
boxType = GConst.MESSAGE_BOX_TYPE.MB_OK_CANCEL,
|
||
showToday = GConst.MESSAGE_BOX_SHOW_TODAY.ACTIVITY_BUY_LEVEL,
|
||
costId = costId,
|
||
costNum = costNum,
|
||
okFunc = function()
|
||
local id = DataManager.ActivityData:getBountyCfg()[DataManager.ActivityData:getBountyLevel() + 1].id
|
||
-- Logger.logHighlight("购买战令等级:"..id)
|
||
self:sendMessage(ProtoMsgType.FromMsgEnum.SummerBountyClaimByDiamondReq, {id = id}, {}, self.rspBuyBountyLevel, BIReport.ITEM_GET_TYPE.ACTIVITY_BOUNTY_LEVEL)
|
||
end,
|
||
}
|
||
GFunc.showMessageBox(params)
|
||
end
|
||
|
||
function ActivityManager:rspBuyBountyLevel(result)
|
||
if result.err_code == GConst.ERROR_STR.SUCCESS then
|
||
DataManager.ActivityData:onBoughtBountyLevel()
|
||
|
||
BIReport:postActOpt(BIReport.ACTIVITY_SUMMER.BUY_LEVEL_UP, DataManager.ActivityData:getActId(), DataManager.ActivityData:getBountyLevel(), DataManager.ActivityData:getBountyLevelScore(), DataManager.ActivityData:getBuyBountyLevelCost())
|
||
end
|
||
end
|
||
|
||
-- 夏日活动分界线-----------------------------------------------------------------------------------------------------
|
||
|
||
return ActivityManager |