Пример #1
0
 internal static void ExecuteLuaCallback(uint callId, string jsonStr)
 {
     try
     {
         if (Pandora.Instance.IsDebug)
         {
             Logger.Log("回调Lua, callId " + callId + ": ");
             Logger.Log(jsonStr);
         }
         if (LuaStateManager.IsInitialized)
         {
             LuaStateManager.CallLuaFunction("Common.ExecuteCallback", new object[]
             {
                 callId,
                 jsonStr
             });
         }
     }
     catch (Exception ex)
     {
         string text = "回调Lua出错了, jsonStr: " + jsonStr + " " + ex.Message;
         Logger.LogError(text);
         Pandora.Instance.ReportError(text, 10217592);
     }
 }
Пример #2
0
 public void Logout()
 {
     try
     {
         if (this._isInitialized)
         {
             if (this._atmSocket != null)
             {
                 this._atmSocket.Close();
             }
             if (this._brokerSocket != null)
             {
                 this._brokerSocket.Close();
             }
             this._userData.Clear();
             PanelManager.DestroyAll();
             LuaStateManager.Reset();
             AssetManager.Clear();
         }
     }
     catch (Exception ex)
     {
         Logger.LogError("Pandora Logout发生异常: " + ex.Message);
     }
 }
Пример #3
0
 private void OnLoaded(string group, List <RemoteConfig.AssetInfo> fileInfoList)
 {
     this._loadedGroupCount++;
     if (this._loadedGroupCount >= this._totalGroupCount)
     {
         CacheManager.WriteProgramAssetMeta();
     }
     this.CallGame("{\"type\":\"assetLoadComplete\",\"name\":\"" + group + "\"}");
     LuaStateManager.DoLuaFileInFileInfoList(group, fileInfoList);
 }
Пример #4
0
 private void OnGetRemoteConfig(RemoteConfig remoteConfig)
 {
     if (remoteConfig.IsError || remoteConfig.IsEmpty)
     {
         this.CallGame("{\"type\":\"pandoraError\",\"content\":\"cgiFailed\"}");
         return;
     }
     if (!remoteConfig.IsEmpty && !remoteConfig.IsError)
     {
         Logger.LogInfo(this._userData.ToString());
         Logger.LogInfo("<color=#00ff00>匹配到管理端规则:</color>  " + remoteConfig.ruleId.ToString());
         this._remoteConfig = remoteConfig;
         LuaStateManager.Initialize();
         this._atmSocket = this._gameObject.AddComponent <AtmSocket>();
         this._atmSocket.Connect(PandoraSettings.GetAtmHost(), PandoraSettings.GetAtmPort(), new Action(this.OnAtmConnected));
     }
 }
Пример #5
0
 internal static void GameCallLua(string jsonStr)
 {
     try
     {
         if (LuaStateManager.IsInitialized)
         {
             LuaStateManager.CallLuaFunction("Common.CommandFromGame", new object[]
             {
                 jsonStr
             });
         }
     }
     catch (Exception ex)
     {
         string text = "Lua执行游戏发送过来的消息失败, " + jsonStr + " " + ex.Message;
         Logger.LogError(text);
         Pandora.Instance.ReportError(text, 10217591);
     }
 }
Пример #6
0
 internal static void AndroidPayFinish(string jsonStr)
 {
     try
     {
         if (LuaStateManager.IsInitialized)
         {
             Logger.Log("安卓米大师支付回调Lua层: " + jsonStr);
             LuaStateManager.CallLuaFunction("Common.AndroidPayFinish", new object[]
             {
                 jsonStr
             });
         }
     }
     catch (Exception ex)
     {
         string text = "安卓米大师支付回调Lua层发生错误\n" + ex.Message;
         Logger.LogError(text);
         Pandora.Instance.ReportError(text, 0);
     }
 }
Пример #7
0
 public static void DoLuaFileInFileInfoList(string group, List <RemoteConfig.AssetInfo> fileInfoList)
 {
     if (LuaStateManager._executingLuaGroupSet.Contains(group))
     {
         string text = "资源组 " + group + " 中的Lua文件正在运行中~";
         Logger.LogError(text);
         Pandora.Instance.ReportError(text, 0);
         return;
     }
     LuaStateManager._executingLuaGroupSet.Add(group);
     for (int i = 0; i < fileInfoList.Count; i++)
     {
         string name = fileInfoList[i].name;
         if (name.ToLower().Contains("_lua.assetbundle"))
         {
             string luaName = LuaStateManager.GetLuaName(name);
             string message = "资源组加载完成,开始执行入口Lua文件: " + luaName;
             Logger.Log(message);
             try
             {
                 LuaStateManager.DoFile(luaName);
             }
             catch (Exception var_5_90)
             {
                 string text2 = "Lua DoFile 失败, FileName: " + luaName;
                 Pandora.Instance.ReportError(text2, 10217594);
                 Pandora.Instance.Report(text2, 10217603, 2);
             }
         }
     }
     if (LuaStateManager._executingLuaGroupSet.Count == 1)
     {
         string error = "执行Lua了";
         Pandora.Instance.ReportError(error, 10217595);
     }
 }
Пример #8
0
 public void LoadProgramAsset(string group)
 {
     Logger.Log("用户发起重连请求");
     if (this._userData == null || this._userData.IsRoleEmpty())
     {
         return;
     }
     if (this._remoteConfig == null)
     {
         this.LoadRemoteConfig(this._userData);
         this.ReportError("用户成功发起重连请求!", 10217602);
         return;
     }
     this._totalGroupCount  = 1;
     this._loadedGroupCount = 0;
     if (this._remoteConfig != null && this._remoteConfig.assetInfoListDict.ContainsKey(group) && !LuaStateManager.IsGroupLuaExecuting(group))
     {
         AssetManager.LoadProgramAssetList(group, this._remoteConfig.assetInfoListDict[group], new Action <string, List <RemoteConfig.AssetInfo> >(this.OnLoaded));
         this.ReportError("用户成功发起重连请求!", 10217602);
     }
 }
Пример #9
0
 public static object DoFile(string fileName)
 {
     byte[] luaBytes = AssetManager.GetLuaBytes(fileName);
     return(LuaStateManager.DoBuffer(luaBytes, fileName));
 }