LauncherConfig.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using LitJson;
  2. using UnityEngine;
  3. using UnityEngine.Networking;
  4. namespace GFGGame
  5. {
  6. public class LauncherConfig
  7. {
  8. public enum EnumNetType { DEV, LOCAL }
  9. public static EnumNetType netType = EnumNetType.LOCAL;
  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 CDN_ROOT = "http://10.108.64.58/";
  19. public static bool ILRuntimeMode;
  20. public static void Init()
  21. {
  22. netType = EnumNetType.LOCAL;
  23. string cfgName = "cfg_local";
  24. #if PT_DEV
  25. //ÍâÍødev°æ±¾
  26. cfgName = "cfg_dev";
  27. #endif
  28. string url = $"http://39.99.144.134/res_dev/platform/{cfgName}.json";
  29. HttpTool.Instance.Get(url, "", (string data) => {
  30. ResultHandler(data);
  31. });
  32. Debug.Log($"loginApiUrl {loginApiUrl} netType {netType}");
  33. }
  34. private static void ResultHandler(string data)
  35. {
  36. var result = JsonMapper.ToObject<Result>(data);
  37. CDN_ROOT = result.cdnRoot;
  38. loginApiUrl = result.loginApiUrl;
  39. Debug.Log($"ptcfg \n{data}");
  40. LauncherView.Instance.SetDesc("»ñÈ¡°æ±¾ÐÅÏ¢...");
  41. VersionController.Instance.Init();
  42. }
  43. private struct Result
  44. {
  45. public string cdnRoot;
  46. public string loginApiUrl;
  47. }
  48. }
  49. }