LauncherConfig.cs 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. Debug.Log($"identifier: {Application.identifier}");
  23. #if PT_DEV
  24. //ÍâÍødev°æ±¾
  25. netType = EnumNetType.DEV;
  26. cfgName = "cfg_dev";
  27. #else
  28. netType = EnumNetType.LOCAL;
  29. string cfgName = "cfg_local";
  30. #endif
  31. string url = $"http://39.99.144.134/res_dev/platform/{cfgName}.json";
  32. HttpTool.Instance.Get(url, "", (string data) => {
  33. ResultHandler(data);
  34. });
  35. Debug.Log($"loginApiUrl {loginApiUrl} netType {netType}");
  36. }
  37. private static void ResultHandler(string data)
  38. {
  39. var result = JsonMapper.ToObject<Result>(data);
  40. CDN_ROOT = result.cdnRoot;
  41. loginApiUrl = result.loginApiUrl;
  42. Debug.Log($"ptcfg \n{data}");
  43. LauncherView.Instance.SetDesc("»ñÈ¡°æ±¾ÐÅÏ¢...");
  44. VersionController.Instance.Init();
  45. }
  46. private struct Result
  47. {
  48. public string cdnRoot;
  49. public string loginApiUrl;
  50. }
  51. }
  52. }