源战役客户端
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

311 rindas
12 KiB

require("game.proto.424.Require424")
require("game.treasureMap.TreasureMapConst")
require("game.treasureMap.TreasureMapModel")
require("game.treasureMap.TreasureMapDescView") -- 藏宝图介绍界面
require("game.treasureMap.TreasureMapDescScrollItem") -- 藏宝图介绍界面节点
require("game.treasureMap.TreasureMapQuizView") -- 藏宝图答题界面
require("game.treasureMap.TreasureMapShopView") -- 藏宝图限时商城界面
require("game.treasureMap.TreasureMapShopItem") -- 藏宝图限时商城界面item
require("game.treasureMap.TreasureMapStorageShopView") -- 藏宝图限时商城界面(收纳)
require("game.treasureMap.TreasureMapStorageShopItem") -- 藏宝图限时商城界面item(收纳)
require("game.treasureMap.TreasureMapNormalRollView") -- 普通藏宝图结算界面
require("game.treasureMap.TreasureMapAdvanceRollView") -- 高级藏宝图抽奖界面
require("game.treasureMap.TreasureMapRewardPreviewView") -- 藏宝图奖池预览界面
require("game.treasureMap.TreasureMapFeedbackView") -- 藏宝图遗宝馈赠界面
require("game.treasureMap.TreasureMapFeedbackItem") -- 藏宝图遗宝馈赠界面
TreasureMapController = TreasureMapController or BaseClass(BaseController, true)
local TreasureMapController = TreasureMapController
function TreasureMapController:__init()
TreasureMapController.Instance = self
self.model = TreasureMapModel:getInstance()
self:AddEvents()
self:RegisterAllProtocal()
end
function TreasureMapController:__delete()
end
function TreasureMapController:RegisterAllProtocal( )
local register_cfg = {
[42401] = { -- 使用藏宝图
handler = function(self, vo)
if vo.errcode == 1 then
self.model:SetCurrentTreasureData(vo, vo.need_find_way == 1)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42402] = { -- 获取藏宝[这个只会处理开箱和转盘两种藏宝类型,其他的走其他协议]
handler = function(self, vo)
if vo.errcode == 1 then
self.model._tm_can_fly_goods = false -- 收到协议之后禁止道具飞入表现
if vo.event == TreasureMapConst.EventType.Normal then -- 普通宝箱
self.model:Fire(TreasureMapConst.OPEN_NORMAL_EVENT_RESULT_VIEW, true, vo)
elseif vo.event == TreasureMapConst.EventType.Roll then -- 转盘
self.model:Fire(TreasureMapConst.OPEN_ROLL_EVENT_RESULT_VIEW, true, vo)
end
-- 清除藏宝图数据
self.model:SetCurrentTreasureData(nil)
else
self.model._tm_can_fly_goods = true
ErrorCodeShow(vo.errcode)
end
end,
},
[42403] = { -- 普通藏宝图使用次数
handler = function(self, vo)
self.model:SetNormalTreasureMapTimes(vo.daily_count)
end,
},
[42405] = { -- 高级藏宝图月度次数信息
handler = function(self, vo)
self.model:SetAdvTreasureMapMonthTimesData(vo)
self.model:CheckTreasureMapRed(TreasureMapConst.RedType.MonthReward)
self.model:Fire(TreasureMapConst.UPDATE_MONTH_TIMES_DATA)
end,
},
[42406] = { -- 领取高级藏宝图月度次数奖励
handler = function(self, vo)
if vo.errcode == 1 then
self.model:UpdateAdvTreasureMapMonthTimesData(vo)
self.model:CheckTreasureMapRed(TreasureMapConst.RedType.MonthReward)
self.model:Fire(TreasureMapConst.UPDATE_MONTH_TIMES_DATA)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42407] = { -- 获取题目
handler = function(self, vo)
if vo.errcode == 1 then
self.model:Fire(TreasureMapConst.OPEN_TREASUREMAP_QUIZ_VIEW, true, vo)
-- 清空藏宝图数据
self.model:SetCurrentTreasureData(nil)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42408] = { -- 提交答案
handler = function(self, vo)
if vo.errcode == 1 then
self.model:Fire(TreasureMapConst.UPDATE_QUIZ_VIEW)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42409] = { -- 获取限时商城信息
handler = function(self, vo)
if vo.errcode == 1 then
self.model:SetTreasureMapShopData(vo)
self.model:CheckTreasureMapRed(TreasureMapConst.RedType.Shop)
self.model:Fire(TreasureMapConst.OPEN_TREASUREMAP_SHOP_VIEW, true, vo)
-- 清空藏宝图数据
self.model:SetCurrentTreasureData(nil)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42410] = { -- 购买限时商店道具
handler = function(self, vo)
if vo.errcode == 1 then
Message.show("购买成功", "success")
self.model:SetTreasureMapShopRestNumData(vo)
self.model:Fire(TreasureMapConst.UPDATE_TREASUREMAP_SHOP_VIEW, true)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42411] = { -- 挖宝后触发怪物事件
handler = function(self, vo)
if vo.errcode == 1 then
self.model._check_tm_tips = TreasureMapConst.Normal
self.model:CheckTreasureTipUseViewOpen()
-- 清空藏宝图数据
self.model:SetCurrentTreasureData(nil)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42412] = { -- 购买限时商店的免费物品
handler = function(self, vo)
if vo.errcode == 1 then
Message.show("购买成功", "success")
self.model:Fire(TreasureMapConst.UPDATE_SHOP_FREE_RECEIVE_STATUS, true)
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42413] = { -- 批量使用普通藏宝图
handler = function(self, vo)
if vo.errcode == 1 then
Message.show("批量使用成功", "success")
else
ErrorCodeShow(vo.errcode)
end
end,
},
[42414] = { -- 收纳后限时未过期道具信息
handler = function(self, vo)
self.model:SetTreasureMapStorageShopData(vo)
self.model:CheckStorageShopIcon(false)
end,
},
[42415] = { -- 收纳限时道具购买
handler = function(self, vo)
if vo.errcode == 1 then
self.model:UpdateTreasureMapStorageShopData(vo)
self.model:CheckStorageShopIcon(true)
self.model:Fire(TreasureMapConst.UPDATE_STORAGE_SHOP_DATA, vo)
else
ErrorCodeShow(vo.errcode)
end
end,
},
}
self:RegisterProtocalByCFG(register_cfg)
end
function TreasureMapController:AddEvents()
local function onGameStart()
self.model:Reset()
local function delay_method( )
if GetModuleIsOpen(424) then
self.model:Fire(TreasureMapConst.REQUEST_CCMD_EVENT, 42401, 0) -- 查询进行中的藏宝图
self.model:Fire(TreasureMapConst.REQUEST_CCMD_EVENT, 42403) -- 查询普通藏宝图每日次数信息
self.model:Fire(TreasureMapConst.REQUEST_CCMD_EVENT, 42405) -- 查询高级藏宝图月度次数信息
self.model:Fire(TreasureMapConst.REQUEST_CCMD_EVENT, 42414) -- 查询藏宝图限时商城信息
end
end
setTimeout(delay_method, 1)
end
GlobalEventSystem:Bind(EventName.GAME_START, onGameStart)
--请求基本信息
local function onRequestEvent(...)
local args = {...}
if args[1] == 42401 then
self:SendFmtToGame(args[1], "c", args[2])
elseif args[1] == 42402 then
self.model._tm_can_fly_goods = false -- 发送协议前,先禁止道具飞入表现
self:SendFmtToGame(args[1], "cc", args[2], args[3])
elseif args[1] == 42406 then
self:SendFmtToGame(args[1], "h", args[2])
elseif args[1] == 42408 then
self:SendFmtToGame(args[1], "hc", args[2], args[3])
elseif args[1] == 42410 then
self:SendFmtToGame(args[1], "hch", args[2], args[3], args[4])
elseif args[1] == 42413 then
self:SendFmtToGame(args[1], "h", args[2])
elseif args[1] == 42415 then
self:SendFmtToGame(args[1], "ihch", args[2], args[3], args[4], args[5])
else
self:SendFmtToGame(args[1])
end
end
self.model:Bind(TreasureMapConst.REQUEST_CCMD_EVENT, onRequestEvent)
local function openDescView(show)
self:OpenView("TreasureMapDescView", show)
end
self.model:Bind(TreasureMapConst.OPEN_DESC_VIEW, openDescView)
local function openTMQuizView(show, vo)
if (show and vo) or not show then
self:OpenView("TreasureMapQuizView", show, vo)
if show then
GlobalEventSystem:Fire(EventName.OPEN_TREASUREMAP_USE_TIP_VIEW, false)
end
end
end
self.model:Bind(TreasureMapConst.OPEN_TREASUREMAP_QUIZ_VIEW, openTMQuizView)
local function openTMShopView(show, vo)
if (show and vo) or not show then
self:OpenView("TreasureMapShopView", show, vo)
if show then
GlobalEventSystem:Fire(EventName.OPEN_TREASUREMAP_USE_TIP_VIEW, false)
end
end
end
self.model:Bind(TreasureMapConst.OPEN_TREASUREMAP_SHOP_VIEW, openTMShopView)
local function openTMStorageShopView(show)
self:OpenView("TreasureMapStorageShopView", show)
end
self.model:Bind(TreasureMapConst.OPEN_TREASUREMAP_STORAGE_SHOP_VIEW, openTMStorageShopView)
local function openNormalResultView(show, vo)
if (show and vo) or not show then
self:OpenView("TreasureMapNormalRollView", show, vo)
if show then
GlobalEventSystem:Fire(EventName.OPEN_TREASUREMAP_USE_TIP_VIEW, false)
end
end
end
self.model:Bind(TreasureMapConst.OPEN_NORMAL_EVENT_RESULT_VIEW, openNormalResultView)
local function openRollResultView(show, vo)
if (show and vo) or not show then
self:OpenView("TreasureMapAdvanceRollView", show, vo)
if show then
GlobalEventSystem:Fire(EventName.OPEN_TREASUREMAP_USE_TIP_VIEW, false)
end
end
end
self.model:Bind(TreasureMapConst.OPEN_ROLL_EVENT_RESULT_VIEW, openRollResultView)
local function openRewardPreviewView(show, index)
self:OpenView("TreasureMapRewardPreviewView", show, index)
end
self.model:Bind(TreasureMapConst.OPEN_REWARD_PERVIEW_VIEW, openRewardPreviewView)
local function openFeedbackView(show)
self:OpenView("TreasureMapFeedbackView", show)
end
self.model:Bind(TreasureMapConst.OPEN_FEEDBACK_VIEW, openFeedbackView)
-- 当藏宝商城的按钮被删除之后,需要重新获取缓存中的未过期道具再尝试创建一次按钮
local function checkStorageShopIcon(icon_type)
if icon_type and icon_type == 42414 then
local function delay_method( )
self.model:CheckStorageShopIcon(true)
end
setTimeout(delay_method, 3)
end
end
GlobalEventSystem:Bind(ActivityIconManager.DELETE_ICON, checkStorageShopIcon)
local function scene_change_func()
if self.model.tm_need_refind_way then -- 需要重新寻路
local function delay_method( )
self.model:TreasureMapFindWay()
end
setTimeout(delay_method, 2)
end
end
GlobalEventSystem:Bind(EventName.SCENE_LOAD_VIEW_COMPLETE, scene_change_func)
end
----请求基本信息
--function TreasureMapController:Handle35025( )
-- if not TreasureMapController.IsDebug then
-- else
--
-- end
--end