LauncherConfig.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. using LitJson;
  2. namespace GFGGame
  3. {
  4. public class LauncherConfig
  5. {
  6. public enum EnumNetType { DEV, LOCAL, TEMP, TISHEN }
  7. public static EnumNetType netType = EnumNetType.LOCAL;
  8. public static string cfgName;
  9. //热更代码存放位置
  10. public const string DllDirHotfix = "Assets/ResIn/Dll/Update/";
  11. public const string DllDirAOT = "Assets/ResIn/Dll/AOT/";
  12. public const int HTTP_GET_TIME_OUT = 3;
  13. public const int HTTP_POST_TIME_OUT = 15;
  14. public static string SOUND_KEY = "sound";
  15. public static string MUSIC_KEY = "music";
  16. public const string SQL_FILE_NAME = "excelConfig.sqlite.bytes";
  17. public static string CDN_ROOT;
  18. public static string loginApiUrl;
  19. public static string gameApiUrl;
  20. public static string cfgUrl;
  21. //平台id
  22. public static int platformId = 1;
  23. public static string logKey;
  24. public static string logApiUrl;
  25. public static string apkVersion;
  26. public static int serverStatus;
  27. public static int onDebug;
  28. public static string manifest_v;
  29. public static string resKey
  30. {
  31. get
  32. {
  33. #if PT_TEMP
  34. return "dfs";
  35. #else
  36. return null;
  37. #endif
  38. }
  39. }
  40. public static void InitScriptCompilation()
  41. {
  42. #if PT_DEV
  43. //外网dev版本
  44. netType = EnumNetType.DEV;
  45. cfgName = "cfg_dev";
  46. #elif PT_TEMP
  47. netType = EnumNetType.TEMP;
  48. cfgName = "cfg_temp";
  49. #else
  50. netType = EnumNetType.LOCAL;
  51. cfgName = "cfg_local";
  52. #endif
  53. cfgUrl = "http://gfg1.obs.cn-north-4.myhuaweicloud.com/14/platform/{cfgName}.json";
  54. }
  55. public static void InitPlatform(string json)
  56. {
  57. ET.Log.Debug($"ptcfg \n{json}");
  58. var result = JsonMapper.ToObject<Result>(json);
  59. LauncherConfig.CDN_ROOT = result.cdnRoot;
  60. //CDN_ROOT = "http://10.108.64.127/";
  61. LauncherConfig.logApiUrl = result.logApiUrl;
  62. LauncherConfig.logKey = result.logKey;
  63. LauncherConfig.apkVersion = result.apkVersion;
  64. LauncherConfig.serverStatus = int.Parse(result.serverStatus);
  65. LauncherConfig.platformId = int.Parse(result.platformId);
  66. LauncherConfig.onDebug = int.Parse(result.onDebug);
  67. LauncherConfig.manifest_v = result.manifest_v;
  68. ET.Log.Debug($"platformId {LauncherConfig.platformId}");
  69. }
  70. private struct Result
  71. {
  72. public string cdnRoot;
  73. public string logApiUrl;
  74. public string logKey;
  75. public string apkVersion;
  76. public string serverStatus;
  77. public string platformId;
  78. public string onDebug;
  79. public string manifest_v;
  80. }
  81. }
  82. }