GameGlobal.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using FairyGUI;
  2. using UnityEngine;
  3. using VEngine;
  4. using UI.Common;
  5. namespace GFGGame
  6. {
  7. public class GameGlobal
  8. {
  9. public static bool isOfflineVisitor = false;
  10. public static bool isVisitor = false;
  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 string loginApiUrl;
  17. public static string gameApiUrl;
  18. public static string gameApiUrlTest;
  19. //ET
  20. public static ET.Scene zoneScene;
  21. public const string LoginAddress = "127.0.0.1:10002";
  22. private static UI_ComHolder comHolder;
  23. private static GameObject _gameObj;
  24. private static GoWrapper _wrapper;
  25. public static void Init()
  26. {
  27. loginApiUrl = LauncherConfig.loginApiUrl;
  28. gameApiUrl = loginApiUrl;//外网
  29. gameApiUrlTest = "http://localhost:8081/api/";
  30. CreatClickEffect();
  31. }
  32. public static string version
  33. {
  34. get
  35. {
  36. return Application.version + "." + Versions.ManifestsVersion;
  37. }
  38. }
  39. private static void CreatClickEffect()
  40. {
  41. if (comHolder == null)
  42. {
  43. comHolder = UI_ComHolder.Create();
  44. comHolder.target.touchable = false;
  45. ViewManager.AddChildToTopLayer(comHolder.target);
  46. string resPath = ResPathUtil.GetViewEffectPath("ui_dj", "ui_dj");
  47. SceneController.AddObjectToView(_gameObj, _wrapper, comHolder.m_holder, resPath, out _gameObj, out _wrapper);
  48. GRoot.inst.onTouchBegin.Add(SetClickPos);
  49. }
  50. }
  51. private static void SetClickPos()
  52. {
  53. // Vector2 pos = Stage.inst.touchPosition;
  54. Vector2 pos = GRoot.inst.GlobalToLocal(Stage.inst.touchPosition);
  55. Debug.Log("pos:" + pos);
  56. comHolder.m_holder.visible = false;
  57. comHolder.m_holder.visible = true;
  58. comHolder.target.SetPosition(pos.x, pos.y, 0);
  59. }
  60. }
  61. }