LauncherConfig.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 = "1";
  22. public static string logApiUrl = "http://10.108.64.127:10004/report";
  23. //public static string CDN_ROOT = "http://10.108.64.58/";
  24. public static bool ILRuntimeMode;
  25. public static void Init()
  26. {
  27. Debug.Log($"identifier: {Application.identifier}");
  28. #if PT_DEV
  29. //外网dev版本
  30. netType = EnumNetType.DEV;
  31. cfgName = "cfg_dev";
  32. #elif PT_TEMP
  33. netType = EnumNetType.TEMP;
  34. cfgName = "cfg_temp";
  35. VEngine.Utility.buildPath = "Bundles_temp";
  36. #else
  37. netType = EnumNetType.LOCAL;
  38. cfgName = "cfg_local";
  39. #endif
  40. //Debug.Log($"loginApiUrl {loginApiUrl} netType {netType}");
  41. }
  42. /// <summary>
  43. /// 获取启动器配置
  44. /// </summary>
  45. public static void GetLauncherCfg()
  46. {
  47. var url = cfgUrl.Replace("{cfgName}", cfgName);
  48. HttpTool.Instance.Get(url, (string data) => {
  49. ResultHandler(data);
  50. });
  51. }
  52. private static void ResultHandler(string data)
  53. {
  54. var result = JsonMapper.ToObject<Result>(data);
  55. CDN_ROOT = result.cdnRoot;
  56. loginApiUrl = result.loginApiUrl;
  57. //logApiUrl = result.logApiUrl;
  58. logKey = result.logKey;
  59. Debug.Log($"ptcfg \n{data}");
  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. }