JCFruitMaster.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. gamingUI.transform.Find("PauseExitBack/ExitBtn").gameObject.SetActive(false);
  21. gamingUI.transform.Find("PauseExitBack/PauseBtn").gameObject.SetActive(false);
  22. CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
  23. outBoundChecker.crossHair = aimingCross.transform as RectTransform;
  24. }
  25. void OnDestroy()
  26. {
  27. if (ins == this) ins = null;
  28. }
  29. void Update()
  30. {
  31. _needMouseAwaked = btnStart.activeInHierarchy || btnResume.activeInHierarchy;
  32. if (_mouseAwaked && !_needMouseAwaked)
  33. {
  34. SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
  35. _mouseAwaked = false;
  36. }
  37. else if (!_mouseAwaked && _needMouseAwaked)
  38. {
  39. SimulateMouseController.ins?.AddOpenLocker("NotGame");
  40. _mouseAwaked = true;
  41. }
  42. aimingCross.enabled = !SB_EventSystem.ins.simulateMouseIsAwaked;
  43. }
  44. public void ResetAim()
  45. {
  46. if (_needMouseAwaked)
  47. {
  48. AimHandler.ins?.DoIdentity();
  49. }
  50. else
  51. {
  52. AutoResetView.DoIdentity();
  53. }
  54. }
  55. }