|
require("game.proto.603.Require603")
|
|
require("game.csMain.CSMainModel")
|
|
require("game.csMain.CSMainConst")
|
|
-------------------
|
|
require("game.csMain.CSMainBaseView")
|
|
require("game.csMain.CSMainRoleModelItem")
|
|
-------------------
|
|
require("game.csMain.CSMainTaskView")
|
|
require("game.csMain.CSMainTaskItem")
|
|
-------------------
|
|
require("game.csMain.CSMainExploitRankView")
|
|
require("game.csMain.CSMainExploitRankTab")
|
|
require("game.csMain.CSMainExploitRankItem")
|
|
require("game.csMain.CSMainExploitRankTopItem")
|
|
require("game.csMain.CSMainExploitRankDailyRewardView")
|
|
require("game.csMain.CSMainExploitRankDailyRewardItem")
|
|
-------------------
|
|
require("game.csMain.CSMainMilitaryRanksAttrItem")
|
|
require("game.csMain.CSMainMilitaryRanksBaseView")
|
|
require("game.csMain.CSMainMilitaryRanksTab")
|
|
require("game.csMain.CSMainMilitaryRanksDetailsView")
|
|
require("game.csMain.CSMainMilitaryRanksRankView")
|
|
require("game.csMain.CSMainMilitaryRanksRankItem")
|
|
-------------------
|
|
require("game.csMain.CSMainAppointView")
|
|
require("game.csMain.CSMainAppointTab")
|
|
require("game.csMain.CSMainAppointRankItem")
|
|
require("game.csMain.CSMainAppointRoleListItem")
|
|
require("game.csMain.CSMainAppointRoleItem")
|
|
require("game.csMain.CSMainAppointOtherRecordView")
|
|
require("game.csMain.CSMainAppointAllRoleListItem")
|
|
-------------------
|
|
require("game.csMain.CSMainAdvanceNoticeView")
|
|
|
|
CSMainController = CSMainController or BaseClass(BaseController, true)
|
|
local CSMainController = CSMainController
|
|
|
|
function CSMainController:__init()
|
|
CSMainController.Instance = self
|
|
self.model = CSMainModel:getInstance()
|
|
self:AddEvents()
|
|
self:RegisterAllProtocal()
|
|
end
|
|
|
|
function CSMainController:__delete()
|
|
end
|
|
|
|
function CSMainController:RegisterAllProtocal( )
|
|
self:RegisterProtocal(60300, "Handle60300")
|
|
self:RegisterProtocal(60301, "Handle60301")
|
|
self:RegisterProtocal(60302, "Handle60302")
|
|
self:RegisterProtocal(60303, "Handle60303")
|
|
self:RegisterProtocal(60304, "Handle60304")
|
|
self:RegisterProtocal(60305, "Handle60305")
|
|
self:RegisterProtocal(60306, "Handle60306")
|
|
self:RegisterProtocal(60307, "Handle60307")
|
|
self:RegisterProtocal(60308, "Handle60308")
|
|
self:RegisterProtocal(60309, "Handle60309")
|
|
self:RegisterProtocal(60310, "Handle60310")
|
|
self:RegisterProtocal(60311, "Handle60311")
|
|
self:RegisterProtocal(60312, "Handle60312")
|
|
self:RegisterProtocal(60313, "Handle60313")
|
|
self:RegisterProtocal(60314, "Handle60314")
|
|
self:RegisterProtocal(60315, "Handle60315")
|
|
self:RegisterProtocal(60316, "Handle60316")
|
|
self:RegisterProtocal(60317, "Handle60317")
|
|
|
|
end
|
|
|
|
function CSMainController:AddEvents()
|
|
local function onGameStart()
|
|
local function onDelay()
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60301)
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60308)
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
|
|
-- local my_country = KfWorldModel:GetInstance():GetMyCountryId()
|
|
-- if my_country then
|
|
-- self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
|
|
-- end
|
|
end
|
|
setTimeout(onDelay, 2.5)
|
|
|
|
local function delay_method( )
|
|
local my_country = KfWorldModel:GetInstance():GetMyCountryId()
|
|
if my_country then
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
|
|
end
|
|
end
|
|
setTimeout(delay_method, 5)
|
|
end
|
|
GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
|
|
|
|
-- 满足等级后请求信息
|
|
local function onLevelUp(level)
|
|
if level == GetModuleOpenLevel(603) then
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60301)
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60308)
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
|
|
local my_country = KfWorldModel:GetInstance():GetMyCountryId()
|
|
if my_country then
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
|
|
end
|
|
elseif level == 96 then
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60315)
|
|
end
|
|
end
|
|
RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, onLevelUp)
|
|
|
|
--请求信息 i|32 h|16 c|8 l|64 s|字符串
|
|
local function onRequestHandler(...)
|
|
local args_list = {...}
|
|
if args_list[1] == 60300 then
|
|
self:SendFmtToGame(args_list[1])
|
|
elseif args_list[1] == 60301 then
|
|
self:SendFmtToGame(args_list[1])
|
|
elseif args_list[1] == 60304 then
|
|
self:SendFmtToGame(args_list[1],"cc",args_list[2],args_list[3])
|
|
elseif args_list[1] == 60305 then
|
|
self:SendFmtToGame(args_list[1])
|
|
elseif args_list[1] == 60306 then
|
|
self:SendFmtToGame(args_list[1],"l",args_list[2])
|
|
elseif args_list[1] == 60307 or args_list[1] == 60316 then
|
|
self:SendFmtToGame(args_list[1],"c",args_list[2])
|
|
elseif args_list[1] == 60308 then
|
|
self:SendFmtToGame(args_list[1])
|
|
elseif args_list[1] == 60309 then
|
|
self:SendFmtToGame(args_list[1],"l",args_list[2])
|
|
elseif args_list[1] == 60310 then
|
|
self:SendFmtToGame(args_list[1])
|
|
elseif args_list[1] == 60311 then
|
|
self:SendFmtToGame(args_list[1])
|
|
elseif args_list[1] == 60312 then
|
|
self:SendFmtToGame(args_list[1],"c",args_list[2])
|
|
else
|
|
self:SendFmtToGame(args_list[1])
|
|
end
|
|
end
|
|
self.model:Bind(CSMainConst.REQUEST_CCMD_EVENT, onRequestHandler)
|
|
|
|
--主界面
|
|
local function on_open_cs_main_base_view(is_close)
|
|
if is_close then
|
|
if self.cs_main_base_view then
|
|
self.cs_main_base_view:Close()
|
|
end
|
|
return
|
|
end
|
|
if self.cs_main_base_view == nil then
|
|
self.cs_main_base_view = CSMainBaseView.New()
|
|
end
|
|
self.cs_main_base_view:Open()
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_BASE_VIEW,on_open_cs_main_base_view)
|
|
|
|
--任务界面
|
|
local function on_open_cs_main_task_view(is_close)
|
|
if is_close then
|
|
if self.cs_main_task_view then
|
|
self.cs_main_task_view:Close()
|
|
end
|
|
return
|
|
end
|
|
|
|
if self.cs_main_task_view == nil then
|
|
self.cs_main_task_view = CSMainTaskView.New()
|
|
end
|
|
|
|
--跳到有红点的任务页签去
|
|
local jump_index = 1
|
|
for i=1,3 do
|
|
local red = self.model:GetTaskRedByColor(i)
|
|
if red then
|
|
jump_index = i
|
|
break
|
|
end
|
|
end
|
|
|
|
self.cs_main_task_view:Open(jump_index)
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_TASK_VIEW,on_open_cs_main_task_view)
|
|
|
|
--军功排行界面
|
|
local function on_open_cs_main_exploit_rank_view()
|
|
if self.cs_main_exploit_rank_view == nil then
|
|
self.cs_main_exploit_rank_view = CSMainExploitRankView.New()
|
|
end
|
|
self.cs_main_exploit_rank_view:Open()
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_EXPLOIT_RANK_VIEW,on_open_cs_main_exploit_rank_view)
|
|
|
|
--每日奖励领取界面
|
|
local function on_open_cs_main_exploit_rank_daily_reward_view()
|
|
if self.cs_main_exploit_rank_daily_reward_view == nil then
|
|
self.cs_main_exploit_rank_daily_reward_view = CSMainExploitRankDailyRewardView.New()
|
|
end
|
|
self.cs_main_exploit_rank_daily_reward_view:Open()
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_EXPLOIT_RANK_DAILY_REWARD_VIEW,on_open_cs_main_exploit_rank_daily_reward_view)
|
|
|
|
--军衔主界面
|
|
local function on_open_cs_main_military_ranks_base_view()
|
|
if self.cs_main_military_ranks_base_view == nil then
|
|
self.cs_main_military_ranks_base_view = CSMainMilitaryRanksBaseView.New()
|
|
end
|
|
self.cs_main_military_ranks_base_view:Open()
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_MILITARY_RANKS_BSAE_VIEW,on_open_cs_main_military_ranks_base_view)
|
|
|
|
--职位任命界面
|
|
local function on_open_cs_main_appoint_view()
|
|
if self.cs_main_appoint_view == nil then
|
|
self.cs_main_appoint_view = CSMainAppointView.New()
|
|
end
|
|
self.cs_main_appoint_view:Open()
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_APPOINT_VIEW,on_open_cs_main_appoint_view)
|
|
|
|
--其他职位任命界面
|
|
local function on_open_cs_main_appoint_view(vo)
|
|
if self.cs_main_other_appoint_view == nil then
|
|
self.cs_main_other_appoint_view = CSMainAppointOtherRecordView.New()
|
|
end
|
|
self.cs_main_other_appoint_view:Open(vo)
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_OTHER_APPOINT_VIEW,on_open_cs_main_appoint_view)
|
|
|
|
--星域世界预告界面
|
|
local function on_open_cs_main_advance_notice_view()
|
|
if self.cs_main_advance_notice_view == nil then
|
|
self.cs_main_advance_notice_view = CSMainAdvanceNoticeView.New()
|
|
end
|
|
self.cs_main_advance_notice_view:Open()
|
|
end
|
|
self.model:Bind(CSMainConst.OPEN_CS_MAIN_ADVANCE_NOTICE_VIEW,on_open_cs_main_advance_notice_view)
|
|
|
|
--主要的更新红点方法
|
|
local function update_red_dot_by_tab_id_func( tab_id )
|
|
if not tab_id then
|
|
self.model:IsNeedRedAll()
|
|
else
|
|
self.model:IsNeedRed(tab_id)
|
|
end
|
|
local bool = self.model:GetMainRed()
|
|
-- GlobalEventSystem:Fire(EventName.SHOW_FUNCTION_RED_POINT, 603, bool)
|
|
self.model:Fire(CSMainConst.UPDATE_MAIN_RIGHT_TOP_RED)
|
|
end
|
|
self.model:Bind(CSMainConst.UPDATE_RED_DOT,update_red_dot_by_tab_id_func)
|
|
|
|
local function update_cs_main_goods_num()
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
|
|
end
|
|
self.model:Bind(CSMainConst.UPDATE_CS_MAIN_GOODS_NUM,update_cs_main_goods_num)
|
|
|
|
local function on_announce_sand_table_red_update( )
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.SandTable)
|
|
end
|
|
SandTableModel:getInstance():Bind(SandTableConst.RedDotRefresh, on_announce_sand_table_red_update)
|
|
|
|
|
|
local function update_power_change()
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
|
|
end
|
|
self.update_power_change_id = RoleManager.Instance.mainRoleInfo:BindOne("fighting", update_power_change)
|
|
end
|
|
|
|
|
|
|
|
|
|
--############ 指挥室 ############
|
|
function CSMainController:Handle60300( )
|
|
local vo = SCMD60300.New(true)
|
|
-- print("==WQ==:SCMD60300 [start:183] vo:", vo)
|
|
-- PrintTable(vo)
|
|
-- print("==WQ==:CSMainController [end]")
|
|
self.model:SetCSMainDirectorData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_CS_MAIN_BASE_VIEW)
|
|
end
|
|
|
|
--############ 任务单 ############
|
|
function CSMainController:Handle60301( )
|
|
local vo = SCMD60301.New(true)
|
|
-- print("==WQ==:SCMD60301 [start:193] vo:", vo)
|
|
-- PrintTable(vo)
|
|
-- print("==WQ==:CSMainController [end]")
|
|
self.model:SetCSMainTaskData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_CS_MAIN_TASK_VIEW)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Active)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Task)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
|
|
end
|
|
|
|
--#############任务更新##########
|
|
function CSMainController:Handle60302( )
|
|
local vo = SCMD60302.New(true)
|
|
self.model:UpdateCSMainTaskData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_CS_MAIN_TASK_ITEM,vo.id)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Task)
|
|
end
|
|
|
|
--#############指定值更新##########
|
|
function CSMainController:Handle60303( )
|
|
local vo = SCMD60303.New(true)
|
|
-- print("==WQ==:SCMD60303 [start:209] vo:", vo)
|
|
-- PrintTable(vo)
|
|
-- print("==WQ==:CSMainController [end]")
|
|
self.model:UpdateCSMainKeyValue(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
|
|
end
|
|
|
|
--############ 领取 ############
|
|
function CSMainController:Handle60304( )
|
|
local vo = SCMD60304.New(true)
|
|
if vo.res == 1 then
|
|
self.model:SetCSMainGetRewardData(vo)
|
|
if vo.opty == 0 then
|
|
elseif vo.opty == 1 then
|
|
self.model:Fire(CSMainConst.REFRESH_CS_MAIN_TASK_ITEM_SORT)
|
|
end
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Active)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.Task)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
end
|
|
|
|
--########军衔进阶#############
|
|
function CSMainController:Handle60305( )
|
|
local vo = SCMD60305.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("军衔进阶成功")
|
|
self.model:UpdateCSMainMilitaryRanksData(vo)
|
|
self.model:Fire(CSMainConst.CS_MAIN_MILITARY_ADVANCE_SUCCESE)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.MilitaryRanks)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
end
|
|
|
|
--############# 主动查询个人形象(00协议返回空的时候用) #############
|
|
function CSMainController:Handle60306( )
|
|
local vo = SCMD60306.New(true)
|
|
-- print("==WQ==:SCMD60305 [start:233] vo:", vo)
|
|
-- PrintTable(vo)
|
|
-- print("==WQ==:CSMainController [end]")
|
|
if vo and vo.role_id and vo.role_id ~= 0 then
|
|
self.model:UpdateCSMainDirectorData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_CS_MAIN_BASE_VIEW_ROLE_REQUEST,vo.role_id)
|
|
end
|
|
end
|
|
|
|
--#########榜单获取##########
|
|
function CSMainController:Handle60307( )
|
|
local vo = SCMD60307.New(true)
|
|
self.model:SetMyCountryExploitRankNum(vo)--记录我的国家军功排行数,如果数量为0,表示不能膜拜,不给红点
|
|
self.model:Fire(CSMainConst.UPDATE_EXPLOIT_RANK_CON,vo)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.WorShip)
|
|
end
|
|
|
|
--##########榜单页面相关##############
|
|
function CSMainController:Handle60308( )
|
|
local vo = SCMD60308.New(true)
|
|
-- print("==WQ==:CSMainController [start:260] vo:", vo)
|
|
-- PrintTable(vo)
|
|
-- print("==WQ==:CSMainController [end]")
|
|
-- vo.last_rank = 10
|
|
-- vo.day_award = 0
|
|
self.model:UpdateCSMainExploitData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_EXPLOIT_RANK_DATA_EXTRA)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.DailyReward)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.WorShip)
|
|
end
|
|
|
|
--##########膜拜##############
|
|
function CSMainController:Handle60309( )
|
|
local vo = SCMD60309.New(true)
|
|
if vo.res == 1 then
|
|
self.model:UpdateCSMainClickWorshipRole(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_WORSHIP_STATE)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.WorShip)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
end
|
|
|
|
--##########领取##############
|
|
function CSMainController:Handle60310( )
|
|
local vo = SCMD60310.New(true)
|
|
if vo.res == 1 then
|
|
self.model:UpdateRankRewardState()
|
|
self.model:Fire(CSMainConst.UPDATE_EXPLOIT_DAILY_REWARD_VIEW)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.DailyReward)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
end
|
|
|
|
--#########上期军功排名##########
|
|
function CSMainController:Handle60311( )
|
|
local vo = SCMD60311.New(true)
|
|
self.model:SetLastMilitaryScoreRankData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_LAST_MILITARY_SCORE_RANK_VIEW,vo)
|
|
end
|
|
|
|
--#########历史名单############
|
|
function CSMainController:Handle60312( )
|
|
local vo = SCMD60312.New(true)
|
|
self.model:SetAppointData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_APPOINT_DATA_VIEW,vo.opty)
|
|
end
|
|
|
|
--#########军衔排行############
|
|
function CSMainController:Handle60313( )
|
|
local vo = SCMD60313.New(true)
|
|
self.model:Fire(CSMainConst.UPDATE_MILITARY_RANKS_RANK_VIEW,vo)
|
|
end
|
|
|
|
--#########上期团战成绩排行############
|
|
function CSMainController:Handle60314( )
|
|
local vo = SCMD60314.New(true)
|
|
self.model:SetLastGuildWarScoreRankData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_LAST_GUILD_WAR_SCORE_RANK_VIEW,vo)
|
|
end
|
|
|
|
--#########预告领取情况############
|
|
function CSMainController:Handle60315( )
|
|
local vo = SCMD60315.New(true)
|
|
-- print("==WQ==:SCMD60315 [start:421] vo:", vo)
|
|
-- PrintTable(vo)
|
|
-- print("==WQ==:CSMainController [end]")
|
|
self.model:SetCSMainAdvanceNoticeRewardData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_CS_MAIN_ADVANCE_NOTICE_REWARD_STATE)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.NoticeReward)
|
|
end
|
|
|
|
--#########预告领取############
|
|
function CSMainController:Handle60316( )
|
|
local vo = SCMD60316.New(true)
|
|
if vo.res == 1 then
|
|
self.model:UpdateCSMainAdvanceNoticeRewardData(vo)
|
|
self.model:Fire(CSMainConst.UPDATE_CS_MAIN_ADVANCE_NOTICE_REWARD_STATE)
|
|
self.model:Fire(CSMainConst.UPDATE_RED_DOT,CSMainConst.RedType.NoticeReward)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
lua_soundM:PlayEffect(self, "fault",false,LuaSoundManager.SOUND_TYPE.UI)
|
|
end
|
|
end
|
|
|
|
--#########通知自己国家军功榜前五名变动############
|
|
function CSMainController:Handle60317( )
|
|
local vo = SCMD60317.New(true)
|
|
local my_country = KfWorldModel:GetInstance():GetMyCountryId()
|
|
if my_country then
|
|
self.model:Fire(CSMainConst.REQUEST_CCMD_EVENT,60307, KfWorldModel:GetInstance():GetMyCountryId())--请求一次自己国家的军功榜,用于判断膜拜红点
|
|
end
|
|
end
|