GameGlobal.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using UnityEngine;
  2. using ET;
  3. using LitJson;
  4. namespace GFGGame
  5. {
  6. public class GameGlobal
  7. {
  8. public static bool isVisitor = false;
  9. public static bool isFirstEntry = false;
  10. public static string cfgName;
  11. //防沉迷开关
  12. public static bool antiAddiction = true;
  13. public static long userId = 0;
  14. public static int userAge = 0;
  15. public static bool skipGuide;
  16. public static bool skipCheckOpen;//跳过功能开启检查
  17. public static bool isEnterGame = false;
  18. public static string loginApiUrl;
  19. //ET
  20. public static Scene zoneScene;
  21. public static Unit myUnit;
  22. public static NumericComponent myNumericComponent;
  23. //平台
  24. public static int platformId = 1;
  25. public static void Init()
  26. {
  27. cfgName = LauncherConfig.cfgName + "_in";
  28. }
  29. public static string version
  30. {
  31. get
  32. {
  33. return Application.version + "." + VEngine.Versions.ManifestsVersion;
  34. }
  35. }
  36. /// <summary>
  37. /// 获取游戏配置
  38. /// </summary>
  39. public static void GetGameCfg()
  40. {
  41. var url = LauncherConfig.cfgUrl.Replace("{cfgName}", cfgName);
  42. HttpTool.Instance.Get(url, (string data) => {
  43. ResultHandler(data);
  44. });
  45. }
  46. private static void ResultHandler(string data)
  47. {
  48. var result = JsonMapper.ToObject<Result>(data);
  49. loginApiUrl = result.loginApiUrl;
  50. ConstValue.LoginAddress = loginApiUrl;
  51. //开始游戏
  52. GameController.Start().Coroutine();
  53. }
  54. private struct Result
  55. {
  56. public string loginApiUrl;
  57. }
  58. }
  59. }