LauncherConfig.cs 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using LitJson;
  2. using UnityEngine;
  3. namespace GFGGame
  4. {
  5. public class LauncherConfig
  6. {
  7. public enum EnumNetType { DEV, LOCAL, TEMP }
  8. public static EnumNetType netType = EnumNetType.LOCAL;
  9. public static string cfgName;
  10. public const int HTTP_GET_TIME_OUT = 3;
  11. public const int HTTP_POST_TIME_OUT = 15;
  12. public static string SOUND_KEY = "sound";
  13. public static string MUSIC_KEY = "music";
  14. public const string SQL_FILE_NAME = "excelConfig.sqlite.bytes";
  15. public static string CDN_ROOT;
  16. public static string loginApiUrl;
  17. public static string gameApiUrl;
  18. //平台id
  19. public static string cfgUrl = "http://39.99.144.134/res/platform/{cfgName}.json";
  20. public static int platformId = 1;
  21. public static string logKey;
  22. public static string logApiUrl;
  23. //public static string CDN_ROOT = "http://10.108.64.58/";
  24. public static bool ILRuntimeMode;
  25. public static void Init()
  26. {
  27. #if PT_DEV
  28. //外网dev版本
  29. netType = EnumNetType.DEV;
  30. cfgName = "cfg_dev";
  31. #elif PT_TEMP
  32. netType = EnumNetType.TEMP;
  33. cfgName = "cfg_temp";
  34. VEngine.Utility.buildPath = "Bundles_temp";
  35. #else
  36. netType = EnumNetType.LOCAL;
  37. cfgName = "cfg_local";
  38. #endif
  39. }
  40. /// <summary>
  41. /// 获取启动器配置
  42. /// </summary>
  43. public static void GetLauncherCfg()
  44. {
  45. var url = cfgUrl.Replace("{cfgName}", cfgName);
  46. HttpTool.Instance.Get(url, (string data) =>
  47. {
  48. ResultHandler(data);
  49. });
  50. }
  51. private static void ResultHandler(string data)
  52. {
  53. var result = JsonMapper.ToObject<Result>(data);
  54. CDN_ROOT = result.cdnRoot;
  55. loginApiUrl = result.loginApiUrl;
  56. logApiUrl = result.logApiUrl;
  57. logKey = result.logKey;
  58. ET.Log.Debug($"ptcfg \n{data}");
  59. LogServerHelperHttp.SendNodeLog((int)LogNode.OnStart);
  60. LauncherView.Instance.SetDesc("获取版本信息...");
  61. VersionController.Instance.Init();
  62. }
  63. private struct Result
  64. {
  65. public string cdnRoot;
  66. public string loginApiUrl;
  67. public string logApiUrl;
  68. public string logKey;
  69. }
  70. }
  71. }