LauncherConfig.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 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. string cfgName = "cfg_dev";
  27. #elif PT_TEMP
  28. netType = EnumNetType.TEMP;
  29. string cfgName = "cfg_temp";
  30. VEngine.Utility.buildPath = "Bundles_temp";
  31. #else
  32. netType = EnumNetType.LOCAL;
  33. string cfgName = "cfg_local";
  34. #endif
  35. string url = $"http://39.99.144.134/res/platform/{cfgName}.json";
  36. HttpTool.Instance.Get(url, "", (string data) => {
  37. ResultHandler(data);
  38. });
  39. Debug.Log($"loginApiUrl {loginApiUrl} netType {netType}");
  40. }
  41. private static void ResultHandler(string data)
  42. {
  43. var result = JsonMapper.ToObject<Result>(data);
  44. CDN_ROOT = result.cdnRoot;
  45. loginApiUrl = result.loginApiUrl;
  46. Debug.Log($"ptcfg \n{data}");
  47. LauncherView.Instance.SetDesc("»ñÈ¡°æ±¾ÐÅÏ¢...");
  48. VersionController.Instance.Init();
  49. }
  50. private struct Result
  51. {
  52. public string cdnRoot;
  53. public string loginApiUrl;
  54. }
  55. }
  56. }