| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class JCFruitMaster : MonoBehaviour
- {
- [SerializeField] Canvas menuUI;
- [SerializeField] Canvas gamingUI;
- [SerializeField] GameObject btnStart;
- [SerializeField] GameObject btnResume;
- bool _mouseAwaked = true;
- bool _needMouseAwaked;
- [SerializeField] Image aimingCross;
- private bool open = false;
- private bool visiable = false;
- private bool onlyShow = true;
- public static JCFruitMaster ins;
- void Start()
- {
- ins = this;
- menuUI.sortingOrder = 4;
- gamingUI.sortingOrder = 4;
- gamingUI.transform.Find("PauseExitBack/ExitBtn").gameObject.SetActive(false);
- gamingUI.transform.Find("PauseExitBack/PauseBtn").gameObject.SetActive(false);
- CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
- outBoundChecker.crossHair = aimingCross.transform as RectTransform;
- //this.open = UserSettings.ins.openCrossHair;
- SetOpen(UserSettings.ins.openCrossHair);
- //this.visiable = aimingCross.enabled;
- visiable = open;
- aimingCross.enabled = open;
- //读取准心值
- if (AimHandler.ins&&!AimHandler.ins.bRuning9Axis() && InfraredDemo._ins) SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
- }
- void OnDestroy()
- {
- if (ins == this) ins = null;
- }
- void Update()
- {
- _needMouseAwaked = btnStart.activeInHierarchy || btnResume.activeInHierarchy;
- if (_mouseAwaked && !_needMouseAwaked)
- {
- SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
- _mouseAwaked = false;
- }
- else if (!_mouseAwaked && _needMouseAwaked)
- {
- SimulateMouseController.ins?.AddOpenLocker("NotGame");
- _mouseAwaked = true;
- }
- //aimingCross.enabled = !SB_EventSystem.ins.simulateMouseIsAwaked;
- if (AutoResetView.ins != null)
- {
- //进入校准时候,一定显示准心
- SetVisiable(true);
- }
- else
- {
- if (open)
- SetVisiable(onlyShow && !SB_EventSystem.ins.simulateMouseIsAwaked);
- else
- SetVisiable(false);
- }
- }
- public void ResetAim()
- {
- if (_needMouseAwaked)
- {
- AimHandler.ins?.DoIdentity();
- }
- else
- {
- AutoResetView.DoIdentity();
- }
- }
- #region 显示和隐藏准心
- void SetVisiable(bool value)
- {
- if (visiable == value) return;
- visiable = value;
- //Debug.Log("AimingCross_img.enabled :" + visiable);
- aimingCross.enabled = visiable;
- //Debug.Log("AimingCross_img.enabled :" + aimingCross.enabled);
- }
- public void SetOpen(bool open)
- {
- this.open = open;
- if (!this.open)
- {
- SetVisiable(false);
- }
- }
- public bool GetOpen()
- {
- return this.open;
- }
- public void SetOnlyShow(bool onlyShow)
- {
- this.onlyShow = onlyShow;
- Debug.Log("AimingCross_img.onlyShow :" + this.onlyShow);
- }
- public bool GetOnlyShow()
- {
- return this.onlyShow;
- }
- #endregion
- }
|