|
-
- local GameAppBase = class("GameAppBase", cc.mvc.AppBase)
-
- function GameAppBase:ctor()
- GameAppBase.super.ctor(self);
- -- 保存所有配置
- self.config = require("luaScript.Config.Configs");
-
- --子游戏ID
- self.gameId = nil
- self.gameRule = nil
-
- --默认协议类型
- self.protocolType = PROTOCOL_TYPE.COMMON
-
- --子游戏协议
- self.room = nil
-
- -- 创建所有协议模块
- self:initAllProtocols()
- -- 初始化其他模块
- self:initModules()
-
- self:initOthers()
- end
-
- function GameAppBase:initAllProtocols()
-
- -- 非棋牌的审核版本,是不需要初始化各种协议的
- if isReviewWithMiniGame() then
- return
- end
-
- -- 网络层 - 连接配置服
- self.net = require("luaScript.Tools.NetGameServer"):new();
-
- -------------------- GameServer 协议 --------------------
-
- -- 服务器配置信息
- self.serverConfigs = require("luaScript.Protocol.Config.ProtocolConfig"):new(self.net)
-
- -- 用户协议
- self.user = require("luaScript.Protocol.ProtocolUser"):new(self.net);
-
- -- Hall
- self.hall = require("luaScript.Protocol.ProtocolHall"):new(self.net);
-
-
-
-
-
- -- 心跳协议
- self.heart = require("luaScript.Protocol.ProtocolHeart"):new(self.net);
-
-
- -------------------- PHP 协议 --------------------
-
- self.php = require("luaScript.Protocol.ProtocolPhp"):new()
-
- -- 商店协议
- self.phpShop = require("luaScript.Protocol.ProtocolPhpShop"):new()
-
-
- --茶馆
- self.club = require("luaScript.Protocol.Club.ClubProtocol"):new(self.net);
-
- --茶馆php
- self.club_php = require("luaScript.Protocol.Club.ClubProtocolPhp"):new(self.net);
-
- --茶馆战绩
- self.club_zhanji = require("luaScript.Protocol.ProtocolClubZhanji"):new(self.net);
-
- --大厅战绩
- self.allZhanji = require("luaScript.Protocol.ProtocolZhanJiGame"):new(-1, "zhanji_AllGame");
-
- -- 金币场
- self.coinProtocol = require("luaScript.Protocol.Coin.CoinProtocol"):new(self.net);
- -- 金币场php
- self.coinProtocolPhp = require("luaScript.Protocol.Coin.CoinProtocolPhp"):new(self.net);
- -- 比赛场
- self.match = require("luaScript.Protocol.Match.ProtocolMatch"):new(self.net)
- self.matchPhp = require("luaScript.Protocol.Match.ProtocolMatchPhp"):new(self.net)
- --红点消息管理器
- self.msgManager = require("luaScript.Tools.MessageManager"):new()
-
- --邮件php
- self.mail_php = require("luaScript.Protocol.Mail.MailProtocolPhp"):new()
-
- -- 战绩协议
- self.zhanji = {}
- end
-
- function GameAppBase:initModules()
-
- -- 非棋牌的审核版本,是不需要初始化各种协议的
- if isReviewWithMiniGame() then
- return
- end
-
- -- 子游戏配置
- self.subGameConfigManager = require("luaScript.SubGame.SubGameConfigManager"):new()
-
- -- 子游戏版本管理
- self.subGameManager = require("luaScript.SubGame.SubGameManager"):new()
-
- -- 管理本地的用户列表
- self.userManager = require("luaScript.User.UserManager"):new()
-
- -- 保存战绩中的所有玩家信息
- self.playerInfoManager = require("luaScript.Tools.PlayerInfoManager"):new()
-
- -- 创建插件
- self.plugin = require("luaScript.GlobalPlugin"):new();
- end
-
- -- 其他初始化
- function GameAppBase:initOthers()
- -- 系统设置
- self.systemSetting = require("luaScript.Protocol.ProtocolSystemSetting"):new();
- end
-
- --[[
- gameId : 游戏ID
- gameRule: 游戏玩法
- protocolType: 协议类型
- --]]
- function GameAppBase:changeGameProtocol(gameId, gameRule, protocolType)
-
- if not app.subGameManager:isInstaller(gameId) then
- showTooltip("游戏未安装")
- return
- end
-
- -- 记录
- self.gameId = gameId
- self.gameRule = gameRule
- self.protocolType = protocolType or PROTOCOL_TYPE.COMMON
-
- logD("GameAppBase:changeGameProtocol() ", gameId, gameRule)
-
- local protocolClass = getSubGameProtocolClass(gameId, gameRule, protocolType)
- if not protocolClass then
- logE(string.format("can not find protocolClass with id = %s, rule = %s", tostring(gameId), tostring(gameRule)))
- return
- end
-
- --如果是麻将 添加搜索路径 防止找不到路径问题
- local gameConfig=getSubGameConfig(gameId)
- if gameConfig and gameConfig.belongType==3 then
- MJFramework.Clean()
- elseif gameConfig and gameConfig.belongType==2 then
- ZPFramework.Clean()
- elseif gameConfig and gameConfig.belongType==1 then
- PKFramework.Clean()
- end
-
- -- 卸载旧的
- if self.room then
- self.room:unRegAll()
- self.room = nil
- end
-
- -- 加载新的
- logD("开始加载协议"..protocolClass)
- self.room = import(protocolClass):new(self.net);
- logD("加载协议完成")
- end
-
- function GameAppBase:addProtocolZhanJi(gameId)
- -- 加载战绩协议
- if not self.zhanji[gameId] then
- local protocolName = getSubGameProtocolZhanJi(gameId)
- if protocolName then
- self.zhanji[gameId] = import(protocolName):new()
- end
- end
- end
-
- -- 使用者请自行判断是否为空
- function GameAppBase:getProtocolZhanJi(gameId)
- return self.zhanji[gameId]
- end
-
-
-
- return GameAppBase;
|