LauncherConfig.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. {
  50. ResultHandler(data);
  51. });
  52. }
  53. private static void ResultHandler(string data)
  54. {
  55. var result = JsonMapper.ToObject<Result>(data);
  56. CDN_ROOT = result.cdnRoot;
  57. loginApiUrl = result.loginApiUrl;
  58. logApiUrl = result.logApiUrl;
  59. logKey = result.logKey;
  60. Debug.Log($"ptcfg \n{data}");
  61. LauncherView.Instance.SetDesc("获取版本信息...");
  62. VersionController.Instance.Init();
  63. }
  64. private struct Result
  65. {
  66. public string cdnRoot;
  67. public string loginApiUrl;
  68. public string logApiUrl;
  69. public string logKey;
  70. }
  71. }
  72. }