ViewGlobal.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using FairyGUI;
  2. using UI.Common;
  3. using UnityEngine;
  4. namespace GFGGame
  5. {
  6. public class ViewGlobal
  7. {
  8. private static UI_ComHolder comHolder;
  9. private static GameObject _gameObj;
  10. private static GoWrapper _wrapper;
  11. public static void CreatClickEffect()
  12. {
  13. if (comHolder == null)
  14. {
  15. comHolder = UI_ComHolder.Create();
  16. comHolder.target.touchable = false;
  17. ViewManager.AddChildToFloatLayer(comHolder.target);
  18. comHolder.target.SetPosition(-100, -100, 0);
  19. string resPath = ResPathUtil.GetViewEffectPath("ui_dj", "ui_dj");
  20. SceneController.AddObjectToView(_gameObj, _wrapper, comHolder.m_holder, resPath, out _gameObj, out _wrapper);
  21. GRoot.inst.onTouchBegin.Add(SetClickPos);
  22. }
  23. }
  24. private static void SetClickPos()
  25. {
  26. Vector2 pos = GRoot.inst.GlobalToLocal(Stage.inst.touchPosition);
  27. comHolder.m_holder.visible = false;
  28. comHolder.m_holder.visible = true;
  29. comHolder.target.SetPosition(pos.x, pos.y, 0);
  30. }
  31. private static int index = 0;
  32. public static void AddShowGMViewEventListener()
  33. {
  34. if (LauncherConfig.netType == LauncherConfig.EnumNetType.LOCAL)
  35. {
  36. GRoot.inst.onTouchBegin.Add(OnTouchBegin);
  37. }
  38. }
  39. private static void OnTouchBegin(EventContext context)
  40. {
  41. if (context.inputEvent.button == 1 || Stage.inst.touchCount == 2)
  42. {
  43. if (index == 0)
  44. {
  45. Timers.inst.Add(1, 1, OnTimeComplete);
  46. }
  47. index++;
  48. if (index == 2)
  49. {
  50. ShowGmView();
  51. }
  52. }
  53. }
  54. private static void OnTimeComplete(object param)
  55. {
  56. index = 0;
  57. }
  58. public static void ShowGmView()
  59. {
  60. ViewManager.Show(ViewName.GM_PANEL_VIEW);
  61. }
  62. }
  63. }