LauncherConfig.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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 resKey
  24. {
  25. get
  26. {
  27. #if LOCAL
  28. return null;
  29. #else
  30. return "dfs";
  31. #endif
  32. }
  33. }
  34. //public static string CDN_ROOT = "http://10.108.64.127/";
  35. public static bool ILRuntimeMode;
  36. public static void Init()
  37. {
  38. #if PT_DEV
  39. //外网dev版本
  40. netType = EnumNetType.DEV;
  41. cfgName = "cfg_dev";
  42. #elif PT_TEMP
  43. netType = EnumNetType.TEMP;
  44. cfgName = "cfg_temp";
  45. VEngine.Utility.buildPath = "Bundles_temp";
  46. #else
  47. netType = EnumNetType.LOCAL;
  48. cfgName = "cfg_local";
  49. #endif
  50. }
  51. /// <summary>
  52. /// 获取启动器配置
  53. /// </summary>
  54. public static void GetLauncherCfg()
  55. {
  56. var url = cfgUrl.Replace("{cfgName}", cfgName);
  57. HttpTool.Instance.Get(url, (string data) =>
  58. {
  59. ResultHandler(data);
  60. });
  61. }
  62. private static void ResultHandler(string data)
  63. {
  64. var result = JsonMapper.ToObject<Result>(data);
  65. CDN_ROOT = result.cdnRoot;
  66. //CDN_ROOT = "http://10.108.64.127/";
  67. loginApiUrl = result.loginApiUrl;
  68. logApiUrl = result.logApiUrl;
  69. logKey = result.logKey;
  70. ET.Log.Debug($"ptcfg \n{data}");
  71. LogServerHelperHttp.SendNodeLog((int)LogNode.OnStart);
  72. LauncherView.Instance.SetDesc("获取版本信息...");
  73. VersionController.Instance.Init();
  74. }
  75. private struct Result
  76. {
  77. public string cdnRoot;
  78. public string loginApiUrl;
  79. public string logApiUrl;
  80. public string logKey;
  81. }
  82. }
  83. }