源战役客户端
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

216 行
7.9 KiB

-- require("game.proto.416.Require416")
require("game.mobilization.MobilizationModel")
require("game.mobilization.view.MobilizationView")--全民动员主界面
require("game.mobilization.view.MobilizationTab")--全民动员主界面tab
require("game.mobilization.view.MobilizationSubTab")--全民动员主界面tab
require("game.mobilization.view.MobilizationItem")--全民动员子界面item
require("game.mobilization.view.MobilizationGroupBuyingItem")--全民动员系列界面item
require("game.mobilization.view.MobilizationGroupBuyingDiscountItem")--全民动员系列界面打折和购买人数item
MobilizationController = MobilizationController or BaseClass(BaseController)
MobilizationController.Is_Debug = false
function MobilizationController:__init()
MobilizationController.Instance = self
self.model = MobilizationModel:getInstance()
self.mainVo = RoleManager.Instance.mainRoleInfo
self:RegisterAllProtocals()
self:AddAllEvents()
end
function MobilizationController:__delete()
end
function MobilizationController:AddAllEvents()
local function game_start_func()
end
GlobalEventSystem:Bind(EventName.GAME_START,game_start_func)
-- local function CheckRedPoint( ... )
-- end
-- GlobalEventSystem:Bind(GoodsModel.CHANGE_BAGLIST,game_start_func)
local onOpenMobilizationView = function (sub_type,day,is_close)
if not GetModuleIsOpen(331,CustomActivityModel.CustomActBaseType.MOBILIZATION) then return end
sub_type = sub_type or CustomActivityModel:getInstance():getActMinSubType(CustomActivityModel.CustomActBaseType.MOBILIZATION)
local open_bool = self.model:CheckActOpen(sub_type)--是否开启
if not open_bool then
Message.show("活动未开启","fault")
return
end
self:OpenView("MobilizationView",not is_close,sub_type,day)
-- 检查一下是否需要展示宣传图 并展示
AdvertisementModel:getInstance():CheckAndShowActivityAd( CustomActivityModel.CustomActBaseType.MOBILIZATION )
end
GlobalEventSystem:Bind(MobilizationModel.OPEN_MOBILIZATION_VIEW, onOpenMobilizationView)
local function request_info(request_id , ... )
if not MobilizationController.Is_Debug then
local fun_name = string.format("send%s",request_id)
if self[fun_name] then
print('----in MobilizationController.lua,line 53 request_id',request_id , ...)
self[fun_name](self,...)
end
elseif request_id == 33225 then
local fun_name = string.format("Handler%s",request_id)
if self[fun_name] then
print('----in MobilizationController.lua,line 59 request_idIs_Debug',request_id , ...)
self[fun_name](self,...)
end
end
end
self.model:Bind(MobilizationModel.REQUEST_INFO,request_info)
local function init_open_day( ... )--开服天数初始化
-- self.model:checkRuneIconBoolOpen()
end
GlobalEventSystem:Bind(EventName.OPEN_DAY_INIT,init_open_day)
--升级
local function onLevelUp(level)
if Config.Modulesub["331@71"].open_lv == level then
local base_type = CustomActivityModel.CustomActBaseType.MOBILIZATION
local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
if act_list then
for i,v in ipairs(act_list) do
self.model:CheckIconBoolOpen(v.sub_type)
end
end
end
end
RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
local function chnage_day_func(type)
if type == SettingModel.CHANGE_DAY.HOUR_0 then -- 跨0点
local base_type = CustomActivityModel.CustomActBaseType.MOBILIZATION
local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
if act_list then
for i,v in pairs(act_list) do
MobilizationModel:getInstance():Fire(MobilizationModel.REQUEST_INFO,33225,v.sub_type)
self.model:CheckIconBoolOpen(v.sub_type)
end
end
local base_type = CustomActivityModel.CustomActBaseType.KF_GROUP_BUYING
local act_list = CustomActivityModel:getInstance():getAllActListByBaseType(base_type) or {}
if act_list then
for i,v in pairs(act_list) do
for ii,vv in ipairs(v.condition_list) do
if vv[1] == "custom_act" and tonumber(vv[2]) == 71 then
MobilizationModel:getInstance():Fire(MobilizationModel.REQUEST_INFO,33225,tonumber(vv[3]))
break
end
end
end
end
end
end
GlobalEventSystem:Bind(EventName.CHANE_DAY, chnage_day_func)
local function onSceneStartHandler()
if self.model.need_load_scene_open_view then
-- GlobalEventSystem:Fire(MobilizationModel.OPEN_MERCENARY_SUPPLY_VIEW,self.model.need_load_scene_open_view)
self.model.need_load_scene_open_view = nil
end
end
self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
end
function MobilizationController:RegisterAllProtocals()
self:RegisterProtocal(33225, "Handler33225")--查询全民动员
self:RegisterProtocal(33226, "Handler33226")--全民动员 奖励领取
self:RegisterProtocal(33227, "Handler33227")--全民动员 日奖励领取
end
-- ########## 查询全民动员 ###########
-- protocol=33225
-- {
-- c2s{
-- sub_type :int16 // 活动子类型
-- }
-- s2c{
-- sub_type :int16 // 活动子类型
-- list:array{ // 每日任务状态列表
-- start_day :int16 // 开始天数
-- end_day :int16 // 结束天数
-- total :int16 // 大奖进度
-- total_state :int8 // 0:未完成 1:可领取 2:已完成
-- task_list:array{ // 任务列表
-- task_type :int16 // 任务类型id
-- id :int16 // 任务id
-- server_pro :int32 // 全服进度
-- person_pro :int32 // 个人进度
-- finish_pro :int8 // 领取条件0未完成1完成
-- state :int8 // 0:未完成 1:可领取 2:已完成
-- }
-- }
-- }
-- }
function MobilizationController:send33225(sub_type)
self:SendFmtToGame(33225,"h",sub_type)
end
function MobilizationController:Handler33225()
local vo = SCMD33225.New(true)
self.model:SetMobilizationInfo(vo)
self.model:Fire(MobilizationModel.UPDATE_MOBILIZATION_VIEW,vo.sub_type)
self.model:CheckIconBoolOpen(vo.sub_type)
end
-- ########## 全民动员 奖励领取 ###########
-- protocol=33226
-- {
-- c2s{
-- sub_type :int16 // 活动子类型
-- task_type :int16 // 任务类型id
-- id :int16 // 任务id
-- }
-- s2c{
-- sub_type :int16 // 活动子类型
-- res :int32 // 返回码(1即成功否则返回错误码)
-- }
-- }
function MobilizationController:send33226(sub_type,task_type,id)
self:SendFmtToGame(33226,"hhh",sub_type,task_type,id)
end
function MobilizationController:Handler33226()
local scmd = SCMD33226.New(true)
if scmd.res == 1 then
Message.show("领取成功","success")
self.model:Fire(MobilizationModel.REQUEST_INFO,33225,scmd.sub_type)
else
ErrorCodeShow(scmd.res)
end
end
-- ########## 全民动员 天数奖励领取 ###########
-- protocol=33227
-- {
-- c2s{
-- sub_type :int16 // 活动子类型
-- start_day :int16 // 开始天
-- end_day :int16 // 结算天
-- }
-- s2c{
-- sub_type :int16 // 活动子类型
-- res :int32 // 返回码(1即成功否则返回错误码)
-- }
-- }
function MobilizationController:send33227(sub_type,start_day,end_day)
self:SendFmtToGame(33227,"hhh",sub_type,start_day,end_day)
end
function MobilizationController:Handler33227()
local scmd = SCMD33227.New(true)
if scmd.res == 1 then
Message.show("领取成功","success")
self.model:Fire(MobilizationModel.REQUEST_INFO,33225,scmd.sub_type)
else
ErrorCodeShow(scmd.res)
end
end