LauncherConfig.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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://gfg1.obs.cn-north-4.myhuaweicloud.com/14/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 PT_TEMP
  28. return "dfs";
  29. #else
  30. return null;
  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. #else
  46. netType = EnumNetType.LOCAL;
  47. cfgName = "cfg_local";
  48. #endif
  49. }
  50. /// <summary>
  51. /// 获取启动器配置
  52. /// </summary>
  53. public static void GetLauncherCfg()
  54. {
  55. var url = cfgUrl.Replace("{cfgName}", cfgName);
  56. HttpTool.Instance.Get(url, (string data) =>
  57. {
  58. ResultHandler(data);
  59. });
  60. }
  61. private static void ResultHandler(string data)
  62. {
  63. var result = JsonMapper.ToObject<Result>(data);
  64. CDN_ROOT = result.cdnRoot;
  65. //CDN_ROOT = "http://10.108.64.127/";
  66. loginApiUrl = result.loginApiUrl;
  67. logApiUrl = result.logApiUrl;
  68. logKey = result.logKey;
  69. ET.Log.Debug($"ptcfg \n{data}");
  70. LogServerHelperHttp.SendNodeLog((int)LogNode.OnStart);
  71. LauncherView.Instance.SetDesc("获取版本信息...");
  72. VersionController.Instance.Init();
  73. }
  74. private struct Result
  75. {
  76. public string cdnRoot;
  77. public string loginApiUrl;
  78. public string logApiUrl;
  79. public string logKey;
  80. }
  81. }
  82. }