瀏覽代碼

视角归位

lvjincheng 3 年之前
父節點
當前提交
d5f076caa9

+ 1 - 2
Assets/BowArrow/Scripts/Bluetooth/AimHandler.cs

@@ -111,8 +111,7 @@ public class AimHandler : MonoBehaviour
                     if (SB_EventSystem.ins) {
                     // if (SB_EventSystem.ins && !CommonConfig.SpecialVersion1) {
                         //唤起/隐藏虚拟鼠标
-                        if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().name != "DuckHunter")
-                            SB_EventSystem.ins.AwakenSimulateMouse(); 
+                        SB_EventSystem.ins.AwakenSimulateMouse(); 
                     }
                 } else if (bytes[1] == 10) {
                     //显示电量

+ 1 - 1
Assets/BowArrow/Scripts/Manager/AudioMgr.cs

@@ -20,7 +20,7 @@ public class AudioMgr : MonoBehaviour
         this.audioSource = this.gameObject.AddComponent<AudioSource>();
     }
 
-    private void Play(string path, AudioSource audioSource) {
+    public void Play(string path, AudioSource audioSource) {
         AudioClip audioClip = Resources.Load<AudioClip>(path);
         if (audioSource == null) {
             audioSource = this.audioSource;

+ 2 - 10
Assets/DuckHunter/Scripts/AudioManager.cs

@@ -6,7 +6,6 @@ namespace DuckHunter
 {
     public class AudioManager : MonoBehaviour
     {
-        private AudioSource _audioSource;
         private static AudioManager _Instance;
         public static AudioManager Instance
         {
@@ -20,7 +19,6 @@ namespace DuckHunter
         void Awake()
         {
             _Instance = this;
-            _audioSource = gameObject.AddComponent<AudioSource>();
         }
 
         void OnDestroy()
@@ -71,23 +69,17 @@ namespace DuckHunter
         public void PlayBtn()
         {
             AudioMgr.ins.PlayBtn();
-            // PlayAudio("DuckHunter/Audios/Btn", null);
         }
 
         private void PlayAudio(string audioPath, AudioSource audioSource)
         {
-            AudioClip audioClip = Resources.Load<AudioClip>(audioPath);
-            if (audioSource == null) audioSource = _audioSource;
-            audioSource.clip = audioClip;
-            audioSource.Play();
+            AudioMgr.ins.Play(audioPath, audioSource);
         }
 
         private AudioSource GetAudioSource(GameObject target)
         {
             if (target == null) return null;
-            AudioSource audioSource = target.GetComponent<AudioSource>();
-            if (audioSource == null) audioSource = target.AddComponent<AudioSource>();
-            return audioSource;
+            return AudioMgr.GetAudioSource(target);
         }
     }
 }

+ 9 - 0
Assets/DuckHunter/Scripts/CrossHair.cs

@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using UnityEngine.UI;
 using DG.Tweening;
 
 namespace DuckHunter
@@ -13,11 +14,19 @@ namespace DuckHunter
         {
             Instance = this;
             InitRotateRangeVH();
+            UpdateHideShow(SB_EventSystem.ins && SB_EventSystem.ins.simulateMouseIsAwaked);
+            GlobalEventCenter.ins.onSimulateMouseAwakeChanged += UpdateHideShow;
         }
 
         void OnDestroy()
         {
             if (Instance == this) Instance = null;
+            GlobalEventCenter.ins.onSimulateMouseAwakeChanged -= UpdateHideShow;
+        }
+
+        void UpdateHideShow(bool mouseAwaked)
+        {
+            transform.Find("Image").GetComponent<Image>().enabled = !mouseAwaked;
         }
 
         Vector2 mapPosition;

+ 6 - 0
Assets/DuckHunter/Scripts/GameUI.cs

@@ -32,9 +32,15 @@ namespace DuckHunter
             });
             btnAim.onClick.AddListener(() =>
             {
+                if (btnAim.GetComponent<LongPressMonitor>().isLongPress) return;
                 AudioManager.Instance.PlayBtn();
                 SmartBowController.Instance.ResetAim();
             });
+            btnAim.gameObject.AddComponent<LongPressMonitor>().onLongPress += () => 
+            {
+                AudioManager.Instance.PlayBtn();
+                if (SB_EventSystem.ins) SB_EventSystem.ins.AwakenSimulateMouse(); 
+            };
             btnBack.onClick.AddListener(() => {
                 AudioManager.Instance.PlayBtn();
                 UnityEngine.SceneManagement.SceneManager.LoadScene("Home", UnityEngine.SceneManagement.LoadSceneMode.Single);