|
--[[
|
|
跨服沙盘玩法
|
|
--]]
|
|
require("game.proto.604.Require604")
|
|
require("game.sandTable.SandTableModel")
|
|
require("game.sandTable.SandTableConst")
|
|
require("game.sandTable.view.SandTableView")--主界面
|
|
require("game.sandTable.view.SandTableNodeItem")--据点Item
|
|
-------------------------
|
|
require("game.sandTable.view.SandTableNodeTip")--据点tip信息
|
|
require("game.sandTable.view.SandTableNodeTipItem")--据点tip信息item
|
|
require("game.sandTable.view.SandTableTipCon")--tip信息页容器
|
|
require("game.sandTable.view.SandTableRankTip")--战功榜信息
|
|
require("game.sandTable.view.SandTableRankItem")--战功榜信息item
|
|
require("game.sandTable.view.SandTableSelfTip")--本国战况信息页
|
|
require("game.sandTable.view.SandTableBuffTip")--buff据点信息页
|
|
require("game.sandTable.view.SandTableSceneView")--场景
|
|
require("game.sandTable.view.SandTableSceneRankItem")--场景伤害榜单节点
|
|
require("game.sandTable.view.SandTableResultView")--结算
|
|
|
|
|
|
|
|
SandTableController = SandTableController or BaseClass(BaseController, true)
|
|
local SandTableController = SandTableController
|
|
|
|
function SandTableController:__init()
|
|
SandTableController.Instance = self
|
|
self.model = SandTableModel:getInstance()
|
|
self:RegisterAllProtocal()
|
|
self:AddEvents()
|
|
end
|
|
|
|
function SandTableController:__delete()
|
|
end
|
|
|
|
function SandTableController:RegisterAllProtocal( )
|
|
self:RegisterProtocal(60400, "on60400")-- 跨服沙盘-开启状态
|
|
self:RegisterProtocal(60401, "on60401")-- 跨服沙盘-全局信息
|
|
self:RegisterProtocal(60402, "on60402")-- 跨服沙盘-全局信息-单个据点-主推
|
|
self:RegisterProtocal(60403, "on60403")-- 跨服沙盘-查看据点攻占详情
|
|
self:RegisterProtocal(60404, "on60404")-- 跨服沙盘-进攻据点
|
|
self:RegisterProtocal(60405, "on60405")-- 跨服沙盘-插旗
|
|
self:RegisterProtocal(60407, "on60407")-- 跨服沙盘-领取据点占领奖励
|
|
self:RegisterProtocal(60408, "on60408")-- 跨服沙盘-我方激活的buff
|
|
self:RegisterProtocal(60409, "on60409")-- 跨服沙盘-副本内信息
|
|
self:RegisterProtocal(60410, "on60410")-- 跨服沙盘-副本结算信息
|
|
end
|
|
|
|
function SandTableController:AddEvents()
|
|
local protocal_format = {
|
|
[60402] = "h",
|
|
[60403] = "h",
|
|
[60404] = "hc",
|
|
[60405] = "hc",
|
|
[60406] = "c",
|
|
[60407] = "h",
|
|
}
|
|
local function onSendCmdFunc( ... )
|
|
local args_list = {...}
|
|
if protocal_format[args_list[1]] then
|
|
local proto_id = table.remove(args_list,1)
|
|
self:SendFmtToGame(proto_id, protocal_format[proto_id], unpack(args_list))
|
|
else
|
|
self:SendFmtToGame(args_list[1])
|
|
end
|
|
end
|
|
self.model:Bind(SandTableConst.PROTO_CCMD_EVENT, onSendCmdFunc)
|
|
|
|
local function on_game_start()
|
|
self.model:Reset()
|
|
if GetModuleIsOpen(604,nil) then
|
|
self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60400)
|
|
end
|
|
end
|
|
GlobalEventSystem:Bind(EventName.GAME_START, on_game_start)
|
|
|
|
RoleManager.Instance.mainRoleInfo:Bind(EventName.CHANGE_LEVEL, function (level)
|
|
if GetModuleOpenLevel( 604,nil) == level then
|
|
self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60400)
|
|
end
|
|
end)
|
|
|
|
local function OPEN_MAIN_VIEW( is_close )
|
|
if is_close then
|
|
if self.sandtableview then
|
|
self.sandtableview:Close()
|
|
end
|
|
else
|
|
self.sandtableview = self.sandtableview or SandTableView.New()
|
|
if not self.sandtableview:HasOpen() then
|
|
self.sandtableview:Open()
|
|
end
|
|
end
|
|
end
|
|
self.model:Bind(SandTableConst.OPEN_MAIN_VIEW, OPEN_MAIN_VIEW)
|
|
|
|
local function OPEN_RESULT_VIEW( data )
|
|
self.sandtableresultview = self.sandtableresultview or SandTableResultView.New()
|
|
if not self.sandtableresultview:HasOpen() then
|
|
self.sandtableresultview:Open(data)
|
|
end
|
|
end
|
|
self.model:Bind(SandTableConst.OPEN_RESULT_VIEW, OPEN_RESULT_VIEW)
|
|
|
|
local function onSceneStartHandler( )
|
|
self.model:ResetFightScoreCfg()--重置积分,节约空间
|
|
self:ChangeScene()
|
|
end
|
|
self:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, onSceneStartHandler)
|
|
|
|
local function ANS_CSGWAR_RED( )
|
|
self:CheckRedDot()
|
|
end
|
|
CSGWarModel:GetInstance():Bind(CSGWarConst.ANS_CSGWAR_RED, ANS_CSGWAR_RED)
|
|
|
|
local function on_arms_num_change_var( )
|
|
-- 那几个满足挑战条件的,给个外部红点让人去打
|
|
self:CheckRedDot()
|
|
end
|
|
CSMainModel:getInstance():BindOne("arms_num", on_arms_num_change_var)
|
|
end
|
|
|
|
function SandTableController:ChangeScene( )
|
|
if self.sandtablesceneview then
|
|
self.sandtablesceneview:Close()
|
|
end
|
|
if SceneManager.Instance:IsSandTableDungeon() then
|
|
self.sandtablesceneview = self.sandtablesceneview or SandTableSceneView.New()
|
|
self.sandtablesceneview:Open()
|
|
|
|
-------------------------
|
|
local point_type = self.model:GetPointTypeByDunId( )
|
|
local str = SandTableConst.EnterTip[point_type]
|
|
if not str then return end
|
|
local main_vo = RoleManager.Instance.mainRoleInfo
|
|
local temp_head_name = main_vo.name
|
|
local data = {
|
|
head_type = 1000 + main_vo.career,
|
|
desc = str,
|
|
head_name = temp_head_name or "",
|
|
hide_time = 8,
|
|
dalay_time = 1,
|
|
is_task_type = true,
|
|
}
|
|
GlobalEventSystem:Fire(EventName.SHOW_COM_DIALOGUE_SHOW_VIEW,data)
|
|
else
|
|
local last_id = SceneManager.Instance:GetLastSceneId()
|
|
if SceneManager.Instance:IsSandTableDungeonScene(last_id) then
|
|
--上一次是沙盘副本场景
|
|
CSMainModel:getInstance():Fire(CSMainConst.OPEN_CS_MAIN_BASE_VIEW)
|
|
local function delay( )
|
|
self.model:Fire(SandTableConst.OPEN_MAIN_VIEW)
|
|
end
|
|
setTimeout(delay,0.2)
|
|
end
|
|
end
|
|
end
|
|
|
|
-- ############ 跨服沙盘-开启状态 protocol=60400 ############
|
|
function SandTableController:on60400( )
|
|
local vo = SCMD60400.New(true)
|
|
self.model:SetActInfo(vo)
|
|
self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60401)
|
|
end
|
|
-- ############ 跨服沙盘-全局信息 protocol=60401 ############
|
|
function SandTableController:on60401( )
|
|
local vo = SCMD60401.New(true)
|
|
self.model:SetPointDateList( vo.point_list,true )
|
|
self.model:SetBuffInfo( vo.buff_info )
|
|
self.model:Fire(SandTableConst.REFRESH_ALL_POINT_INFO)
|
|
self:CheckRedDot( )
|
|
end
|
|
-- ############ 跨服沙盘-全局信息-单个据点-主推 protocol=60402 ############
|
|
function SandTableController:on60402( )
|
|
local vo = SCMD60402.New(true)
|
|
self.model:SetPointDateList( {vo} )
|
|
self.model:Fire(SandTableConst.REFRESH_ALL_POINT_INFO)
|
|
self:CheckRedDot( )
|
|
end
|
|
-- ############ 跨服沙盘-查看据点攻占详情 protocol=60403 ############
|
|
function SandTableController:on60403( )
|
|
local vo = SCMD60403.New(true)
|
|
self.model:SetFightRankData(vo)
|
|
self.model:Fire(SandTableConst.OPEN_POINT_INFO_VIEW, vo.point_id, nil, vo)
|
|
end
|
|
-- ############ 跨服沙盘-进攻据点 protocol=60404 ############
|
|
function SandTableController:on60404( )
|
|
local vo = SCMD60404.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("操作成功~")
|
|
self.model:SetDungeonInfo(false)
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
-- ############ 跨服沙盘-插旗 protocol=60405 ############
|
|
function SandTableController:on60405( )
|
|
local vo = SCMD60405.New(true)
|
|
if vo.res == 1 then
|
|
self.model:Fire(SandTableConst.CancelShowTip)
|
|
-------------------------
|
|
if vo.type == 1 then
|
|
Message.show("发起成功~")
|
|
-- local is_us = self.model:IsSelfFactionByPoint( vo.point_id )
|
|
local cfg = self.model:GetPointCfg( vo.point_id )
|
|
if cfg then
|
|
local content = string.format(SandTableConst.FlagTalk, Trim(cfg.name))
|
|
ChatModel:getInstance():Fire(ChatModel.SEND_MSG,ChatModel.CHANNEL_COUNTRY,content,nil,nil,ChatModel.CHAT_COMMON_TYPE.SYSTEM)
|
|
end
|
|
else
|
|
Message.show("已取消~")
|
|
end
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
-- ############ 跨服沙盘-领取据点占领奖励 protocol=60407 ############
|
|
function SandTableController:on60407( )
|
|
local vo = SCMD60407.New(true)
|
|
if vo.res == 1 then
|
|
Message.show("领取成功")
|
|
local data = self.model:GetPointDateList( vo.point_id )
|
|
if data then
|
|
--找到数据就自己更新
|
|
data.award_time = vo.award_time
|
|
self:CheckRedDot( )
|
|
self.model:Fire(SandTableConst.REFRESH_ALL_POINT_INFO)
|
|
else
|
|
--没找到就请求数据了
|
|
self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60401)
|
|
end
|
|
else
|
|
ErrorCodeShow(vo.res)
|
|
end
|
|
end
|
|
-- ############ 跨服沙盘-我方激活的buff protocol=60408 ############
|
|
function SandTableController:on60408( )
|
|
local vo = SCMD60408.New(true)
|
|
self.model:SetSelfActiveBuff(vo.skill_list)
|
|
end
|
|
-- ############ 跨服沙盘-副本内信息 protocol=60409 ############
|
|
function SandTableController:on60409( )
|
|
local vo = SCMD60409.New(true)
|
|
self.model:SetDungeonInfo(vo)
|
|
self.model:Fire(SandTableConst.ANS_DUNGEON_INFO)
|
|
end
|
|
-- ############ 跨服沙盘-副本结算信息 protocol=60410 ############
|
|
function SandTableController:on60410( )
|
|
CustomActivityModel:getInstance():SetGoodsCanFly(false)
|
|
local vo = SCMD60410.New(true)
|
|
self.model:Fire(SandTableConst.OPEN_RESULT_VIEW, vo)
|
|
self.model:Fire(SandTableConst.CancelShowTip)
|
|
self.model:Fire(SandTableConst.PROTO_CCMD_EVENT, 60402, vo.point_id)
|
|
end
|
|
|
|
function SandTableController:CheckRedDot( )
|
|
local function call_backack( )
|
|
-- local csgwar_red_data = CSGWarModel:getInstance():GetCSGWarRedData()
|
|
-- local csgwar_red = csgwar_red_data.one_red or csgwar_red_data.support_red or csgwar_red_data.fight_red or csgwar_red_data.occupy_red
|
|
-------------------------
|
|
self.model:GetRedDot( true )
|
|
-------------------------
|
|
self.model:Fire(SandTableConst.RedDotRefresh)
|
|
end
|
|
TimeManager.GetInstance():StartTime("SandTableController_CheckRedDot", 0.5, call_backack)
|
|
end
|