LauncherConfig.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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, TEMP }
  9. public static EnumNetType netType = EnumNetType.LOCAL;
  10. public static string cfgName;
  11. public const int HTTP_GET_TIME_OUT = 3;
  12. public const int HTTP_POST_TIME_OUT = 15;
  13. public static string SOUND_KEY = "sound";
  14. public static string MUSIC_KEY = "music";
  15. public const string SQL_FILE_NAME = "excelConfig.sqlite.bytes";
  16. public static string CDN_ROOT;
  17. public static string loginApiUrl;
  18. public static string gameApiUrl;
  19. //public static string CDN_ROOT = "http://10.108.64.58/";
  20. public static bool ILRuntimeMode;
  21. public static void Init()
  22. {
  23. Debug.Log($"identifier: {Application.identifier}");
  24. #if PT_DEV
  25. //ÍâÍødev°æ±¾
  26. netType = EnumNetType.DEV;
  27. cfgName = "cfg_dev";
  28. #elif PT_TEMP
  29. netType = EnumNetType.TEMP;
  30. cfgName = "cfg_temp";
  31. VEngine.Utility.buildPath = "Bundles_temp";
  32. #else
  33. netType = EnumNetType.LOCAL;
  34. cfgName = "cfg_local";
  35. #endif
  36. //Debug.Log($"loginApiUrl {loginApiUrl} netType {netType}");
  37. }
  38. public static void GetPlatformCfg()
  39. {
  40. string url = $"http://39.99.144.134/res/platform/{cfgName}.json";
  41. HttpTool.Instance.Get(url, "", (string data) => {
  42. ResultHandler(data);
  43. });
  44. }
  45. private static void ResultHandler(string data)
  46. {
  47. var result = JsonMapper.ToObject<Result>(data);
  48. CDN_ROOT = result.cdnRoot;
  49. loginApiUrl = result.loginApiUrl;
  50. Debug.Log($"ptcfg \n{data}");
  51. LauncherView.Instance.SetDesc("»ñÈ¡°æ±¾ÐÅÏ¢...");
  52. VersionController.Instance.Init();
  53. }
  54. private struct Result
  55. {
  56. public string cdnRoot;
  57. public string loginApiUrl;
  58. }
  59. }
  60. }