miduo_client/Assets/ManagedResources/~Lua/Modules/Map/TrialMiniGame/TrialMiniGameManager.lua

53 lines
1.3 KiB
Lua
Raw Normal View History

2020-06-23 18:36:24 +08:00
TrialMiniGameManager = {}
2020-06-13 11:47:13 +08:00
local this = TrialMiniGameManager
function this.Init()
this.gameType = nil
this.doneFunc = nil
this.gameId = nil
this.gameParams = nil
this.gameDrop = nil
this.isGameDone = nil
end
function this.StartGame(gameType, func)
this.gameType = gameType
this.doneFunc = func
-- 初始化数据
NetManager.MiniGameInitRequest(function(msg)
-- this.gameId = msg.type
this.gameId = msg.param[1]
this.gameParams = msg.param
UIManager.OpenPanel(UIName.TrialMiniGamePanel, this.gameType, this.gameId, this.gameParams)
end)
end
-- 请求操作
function this.GameOperate(index, func)
-- 初始化数据
NetManager.MiniGameOperateRequest(index, function(msg)
this.isGameDone = msg.gameStatus == 0
this.resultId = msg.resultId
if func then func(msg) end
end)
end
-- 游戏结束
function this.EndGame()
if UIManager.IsOpen(UIName.TrialMiniGamePanel) then
UIManager.ClosePanel(UIName.TrialMiniGamePanel)
end
end
-- 游戏界面关闭时调用
function this.GameClose()
if this.doneFunc then
this.doneFunc()
end
end
-- 判断游戏是否完成
function this.IsGameDone()
return this.isGameDone
end
return TrialMiniGameManager