JCFruitMaster.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class JCFruitMaster : MonoBehaviour
  6. {
  7. [SerializeField] Canvas menuUI;
  8. [SerializeField] Canvas gamingUI;
  9. [SerializeField] GameObject btnStart;
  10. [SerializeField] GameObject btnResume;
  11. bool _mouseAwaked = true;
  12. bool _needMouseAwaked;
  13. [SerializeField] Image aimingCross;
  14. private bool open = false;
  15. private bool visiable = false;
  16. private bool onlyShow = true;
  17. public static JCFruitMaster ins;
  18. void Start()
  19. {
  20. ins = this;
  21. menuUI.sortingOrder = 4;
  22. gamingUI.sortingOrder = 4;
  23. gamingUI.transform.Find("PauseExitBack/ExitBtn").gameObject.SetActive(false);
  24. gamingUI.transform.Find("PauseExitBack/PauseBtn").gameObject.SetActive(false);
  25. CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
  26. outBoundChecker.crossHair = aimingCross.transform as RectTransform;
  27. this.open = UserSettings.ins.openCrossHair;
  28. this.visiable = aimingCross.enabled;
  29. //读取准心值
  30. SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
  31. }
  32. void OnDestroy()
  33. {
  34. if (ins == this) ins = null;
  35. }
  36. void Update()
  37. {
  38. _needMouseAwaked = btnStart.activeInHierarchy || btnResume.activeInHierarchy;
  39. if (_mouseAwaked && !_needMouseAwaked)
  40. {
  41. SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
  42. _mouseAwaked = false;
  43. }
  44. else if (!_mouseAwaked && _needMouseAwaked)
  45. {
  46. SimulateMouseController.ins?.AddOpenLocker("NotGame");
  47. _mouseAwaked = true;
  48. }
  49. //aimingCross.enabled = !SB_EventSystem.ins.simulateMouseIsAwaked;
  50. if (open) SetVisiable(onlyShow && !SB_EventSystem.ins.simulateMouseIsAwaked);
  51. }
  52. public void ResetAim()
  53. {
  54. if (_needMouseAwaked)
  55. {
  56. AimHandler.ins?.DoIdentity();
  57. }
  58. else
  59. {
  60. AutoResetView.DoIdentity();
  61. }
  62. }
  63. #region 显示和隐藏准心
  64. void SetVisiable(bool value)
  65. {
  66. if (visiable == value) return;
  67. visiable = value;
  68. Debug.Log("AimingCross_img.enabled :" + visiable);
  69. aimingCross.enabled = visiable;
  70. Debug.Log("AimingCross_img.enabled :" + aimingCross.enabled);
  71. }
  72. public void SetOpen(bool open)
  73. {
  74. this.open = open;
  75. if (!this.open)
  76. {
  77. SetVisiable(false);
  78. }
  79. }
  80. public bool GetOpen()
  81. {
  82. return this.open;
  83. }
  84. public void SetOnlyShow(bool onlyShow)
  85. {
  86. this.onlyShow = onlyShow;
  87. Debug.Log("AimingCross_img.onlyShow :" + this.onlyShow);
  88. }
  89. public bool GetOnlyShow()
  90. {
  91. return this.onlyShow;
  92. }
  93. #endregion
  94. }