GameGlobal.cs 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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 isVisitor = false;
  10. //防沉迷开关
  11. public static bool antiAddiction = true;
  12. public static long userId = 0;
  13. public static int userAge = 0;
  14. public static bool skipGuide;
  15. public static string loginApiUrl;
  16. public static string gameApiUrl;
  17. public static string gameApiUrlTest;
  18. //ET
  19. public static ET.Scene zoneScene;
  20. public const string LoginAddress = "127.0.0.1:10002";
  21. private static UI_ComHolder comHolder;
  22. private static GameObject _gameObj;
  23. private static GoWrapper _wrapper;
  24. public static void Init()
  25. {
  26. loginApiUrl = LauncherConfig.loginApiUrl;
  27. gameApiUrl = loginApiUrl;//外网
  28. gameApiUrlTest = "http://localhost:8081/api/";
  29. CreatClickEffect();
  30. }
  31. public static string version
  32. {
  33. get
  34. {
  35. return Application.version + "." + Versions.ManifestsVersion;
  36. }
  37. }
  38. private static void CreatClickEffect()
  39. {
  40. if (comHolder == null)
  41. {
  42. comHolder = UI_ComHolder.Create();
  43. ViewManager.AddChildToTopLayer(comHolder.target);
  44. string resPath = ResPathUtil.GetViewEffectPath("ui_dj", "ui_dj");
  45. SceneController.AddObjectToView(_gameObj, _wrapper, comHolder.m_holder, resPath, out _gameObj, out _wrapper);
  46. GRoot.inst.onTouchBegin.Add(SetClickPos);
  47. }
  48. }
  49. private static void SetClickPos()
  50. {
  51. // Vector2 pos = Stage.inst.touchPosition;
  52. Vector2 pos = GRoot.inst.GlobalToLocal(Stage.inst.touchPosition);
  53. Debug.Log("pos:" + pos);
  54. comHolder.m_holder.visible = false;
  55. comHolder.m_holder.visible = true;
  56. comHolder.target.SetPosition(pos.x, pos.y, 0);
  57. }
  58. }
  59. }