| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214 | 
							- using System.Collections;
 
- using System.Collections.Generic;
 
- using UnityEngine;
 
- using UnityEngine.SceneManagement;
 
- using UnityEngine.UI;
 
- namespace HyperspaceGame
 
- {
 
-     public class UIManager : MonoBehaviour
 
-     {
 
-         public static UIManager _ins;
 
-         /// <summary>
 
-         /// 记录一个总分
 
-         /// </summary>
 
-         public static int mHyperspaceScore { get; set; } = 0;
 
-         [SerializeField] Button _btnQuit;
 
-         [SerializeField] Button _btnReload;
 
-         [SerializeField] Button _btnCrosshair;
 
-         [SerializeField] Button _btnCalibrationOffset;
 
-         [SerializeField] Material outlight;
 
-         //准心部分
 
-         private bool open = false;
 
-         private bool visiable = false;
 
-         private bool onlyShow = true;
 
-         private Image image = null;
 
-         private void Awake()
 
-         {
 
-             if (_ins != null && _ins != this)
 
-             {
 
-                 //Destroy(this.gameObject); // 如果已经存在实例,则销毁当前对象
 
-                 return;
 
-             }
 
-             _ins = this;
 
-             //DontDestroyOnLoad(this.gameObject); // 保证对象在场景切换时不被销毁
 
-             //生成时候初始化一下状态
 
-             if (ShootCheck.ins) ShootCheck.ins.bluetoothDeviceStatus = SmartBowSDK.BluetoothDeviceStatus.MagazineLoading;
 
-         }
 
-         private void OnDestroy()
 
-         {
 
-             if (_ins == this)
 
-             {
 
-                 _ins = null; // 在销毁时释放单例
 
-             }
 
-             GlobalEventCenter.ins.onSimulateMouseAwakeChanged -= UpdateHideShow;
 
-         }
 
-         // Start is called before the first frame update
 
-         void Start()
 
-         {
 
-             //关闭原来准心
 
-             SimulateMouseController.ins?.RemoveOpenLocker("NotGame");
 
-             image = GeneratingTarget.gm.shootingEvent.GetComponent<Image>();
 
-             //b端单人
 
-             if (CommonConfig.StandaloneModeOrPlatformB) 
 
-             {
 
-                 _btnCrosshair.gameObject.SetActive(false);
 
-                 _btnCalibrationOffset.gameObject.SetActive(false);
 
-             } else {
 
-                 //获取设置值和一个存储值
 
-                 bool onInitOpen = InfraredDemo._ins ? InfraredDemo._ins.bInitCrosshairShow() : true;
 
-                 Image crossHairImage = _btnCrosshair.GetComponentInChildren<Image>();
 
-                 crossHairImage.material = onInitOpen ? outlight : null;
 
-                 _btnCrosshair.onClick.AddListener(delegate () {
 
-                     AudioMgr.ins.PlayBtn();
 
-                     bool onlyShow = !GetOnlyShow();
 
-                     SetOnlyShow(onlyShow);
 
-                     //记录准心值
 
-                     if (InfraredDemo._ins) InfraredDemo._ins.setCrosshairValue(onlyShow);
 
-                     if (onlyShow)
 
-                     {
 
-                         crossHairImage.material = outlight;
 
-                     }
 
-                     else
 
-                     {
 
-                         crossHairImage.material = null;
 
-                     }
 
-                 });
 
-                 //校准
 
-                 _btnCalibrationOffset.onClick.AddListener(delegate () {
 
-                     AudioMgr.ins.PlayBtn();
 
-                     AutoResetView.DoIdentity();
 
-                 });
 
-             }
 
-             _btnQuit.onClick.AddListener(OnShutDown);
 
-             _btnReload.onClick.AddListener(Reload);
 
-             SetOpen(UserSettings.ins.openCrossHair);
 
-             visiable = open;
 
-             OnValueChanged(visiable);
 
-             UpdateHideShow(SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked);
 
-             GlobalEventCenter.ins.onSimulateMouseAwakeChanged += UpdateHideShow;
 
-             //CrossHairOutBoundChecker1 outBoundChecker = Instantiate(Resources.Load<GameObject>("Prefabs/CrossHairOutBoundChecker1")).GetComponent<CrossHairOutBoundChecker1>();
 
-             //outBoundChecker.crossHair = transform as RectTransform;
 
-             //读取准心值
 
-             if (AimHandler.ins && !AimHandler.ins.bRuning9Axis() && InfraredDemo._ins) SetOnlyShow(InfraredDemo._ins.getCrosshairValue() == 1);
 
-         }
 
-         void UpdateHideShow(bool mouseAwaked)
 
-         {
 
-             //transform.Find("Image").GetComponent<Image>().enabled = !mouseAwaked;
 
-             SetOnlyShow(!mouseAwaked);
 
-         }
 
-         public void ShowQuit()
 
-         {
 
-             _btnQuit.gameObject.SetActive(true);
 
-         }
 
-         void OnShutDown()
 
-         {
 
-             //SceneManager.LoadScene("Home",LoadSceneMode.Single);
 
-             GeneratingTarget.gm.onUploadScore();
 
-             //结束游戏页面
 
-             GeneratingTarget.gm.userGameAnalyse1.showResultView(() =>
 
-             {
 
-                 SceneManager.LoadScene("Home", LoadSceneMode.Single);
 
-             });
 
-         }
 
-         public void Reload()
 
-         {
 
-             GeneratingTarget.gm.OnSeparation();
 
-             GeneratingTarget.gm.OnLoading();
 
-         }
 
-         public bool GetArrowBtnState()
 
-         {
 
-             if (open)
 
-                 return true;
 
-             return false;
 
-         }
 
-         // Update is called once per frame
 
-         void Update()
 
-         {
 
-             if (AutoResetView.ins != null)
 
-             {
 
-                 //进入校准时候,一定显示准心
 
-                 SetVisiable(true);
 
-             }
 
-             else
 
-             {
 
-                 if (open) 
 
-                     SetVisiable(onlyShow);
 
-                 else
 
-                     SetVisiable(false);
 
-             }
 
-         }
 
-         void SetVisiable(bool value)
 
-         {
 
-             if (this.visiable == value) return;
 
-             this.visiable = value;
 
-             OnValueChanged(this.visiable);
 
-         }
 
-         void OnValueChanged(bool isOn)
 
-         {
 
-             var color = image.color;
 
-             if (isOn)
 
-             {
 
-                 color.a = 1;
 
-                 image.color = color;
 
-                 //_togImge.sprite = _togSprites[0];
 
-         
 
-             }
 
-             else
 
-             {
 
-                 color.a = 0;
 
-                 image.color = color;
 
-                 //_togImge.sprite = _togSprites[1];
 
-             }
 
-         }
 
-         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;
 
-         }
 
-         public bool GetOnlyShow()
 
-         {
 
-             return this.onlyShow;
 
-         }
 
-     }
 
- }
 
 
  |