LauncherConfig.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using LitJson;
  2. namespace GFGGame
  3. {
  4. public class LauncherConfig
  5. {
  6. public enum EnumNetType { DEV, LOCAL, TEMP }
  7. public static EnumNetType netType = EnumNetType.LOCAL;
  8. public static string cfgName;
  9. public static bool ILRuntimeMode;
  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. public static string cfgUrl;
  19. //ƽ̨id
  20. public static int platformId = 1;
  21. public static string logKey;
  22. public static string logApiUrl;
  23. public static string apkVersion;
  24. public static int serverStatus;
  25. public static string resKey
  26. {
  27. get
  28. {
  29. #if PT_TEMP
  30. return "dfs";
  31. #else
  32. return null;
  33. #endif
  34. }
  35. }
  36. public static void InitScriptCompilation()
  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. #else
  46. netType = EnumNetType.LOCAL;
  47. cfgName = "cfg_local";
  48. #endif
  49. cfgUrl = "http://gfg1.obs.cn-north-4.myhuaweicloud.com/14/platform/{cfgName}.json";
  50. }
  51. public static void InitPlatform(string json)
  52. {
  53. ET.Log.Debug($"ptcfg \n{json}");
  54. var result = JsonMapper.ToObject<Result>(json);
  55. LauncherConfig.CDN_ROOT = result.cdnRoot;
  56. //CDN_ROOT = "http://10.108.64.127/";
  57. LauncherConfig.loginApiUrl = result.loginApiUrl;
  58. LauncherConfig.logApiUrl = result.logApiUrl;
  59. LauncherConfig.logKey = result.logKey;
  60. LauncherConfig.apkVersion = result.apkVersion;
  61. LauncherConfig.serverStatus = int.Parse(result.serverStatus);
  62. LauncherConfig.platformId = int.Parse(result.platformId);
  63. ET.Log.Debug($"platformId {LauncherConfig.platformId}");
  64. }
  65. private struct Result
  66. {
  67. public string cdnRoot;
  68. public string loginApiUrl;
  69. public string logApiUrl;
  70. public string logKey;
  71. public string apkVersion;
  72. public string serverStatus;
  73. public string platformId;
  74. }
  75. }
  76. }