JCFruitMaster.cs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. public static JCFruitMaster ins;
  15. void Start()
  16. {
  17. ins = this;
  18. menuUI.sortingOrder = 4;
  19. gamingUI.sortingOrder = 4;
  20. }
  21. void OnDestroy()
  22. {
  23. if (ins == this) ins = null;
  24. }
  25. void Update()
  26. {
  27. _needMouseAwaked = btnStart.activeInHierarchy || btnResume.activeInHierarchy;
  28. if (_mouseAwaked && !_needMouseAwaked)
  29. {
  30. SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
  31. _mouseAwaked = false;
  32. }
  33. else if (!_mouseAwaked && _needMouseAwaked)
  34. {
  35. SimulateMouseController.ins?.AddOpenLocker("NotGame");
  36. _mouseAwaked = true;
  37. }
  38. aimingCross.enabled = !SB_EventSystem.ins.simulateMouseIsAwaked;
  39. }
  40. public void ResetAim()
  41. {
  42. if (_needMouseAwaked)
  43. {
  44. AimHandler.ins?.DoIdentity();
  45. }
  46. else
  47. {
  48. AutoResetView.DoIdentity();
  49. }
  50. }
  51. }