瀏覽代碼

电量和游戏靶子超距离提示

lvjincheng 4 年之前
父節點
當前提交
da3d35c34a

+ 5 - 5
Assets/BowArrow/Scenes/Home.unity

@@ -311,7 +311,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchoredPosition: {x: 80, y: -260}
-  m_SizeDelta: {x: 0, y: 50}
+  m_SizeDelta: {x: 160, y: 50}
   m_Pivot: {x: 0, y: 0.5}
 --- !u!114 &151032534
 MonoBehaviour:
@@ -787,7 +787,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchoredPosition: {x: 80, y: -80}
-  m_SizeDelta: {x: 0, y: 50}
+  m_SizeDelta: {x: 160, y: 50}
   m_Pivot: {x: 0, y: 0.5}
 --- !u!114 &551154240
 MonoBehaviour:
@@ -1035,7 +1035,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchoredPosition: {x: 80, y: -140}
-  m_SizeDelta: {x: 0, y: 50}
+  m_SizeDelta: {x: 160, y: 50}
   m_Pivot: {x: 0, y: 0.5}
 --- !u!114 &739433371
 MonoBehaviour:
@@ -1725,7 +1725,7 @@ RectTransform:
   m_AnchorMin: {x: 0, y: 1}
   m_AnchorMax: {x: 0, y: 1}
   m_AnchoredPosition: {x: 80, y: -200}
-  m_SizeDelta: {x: 0, y: 50}
+  m_SizeDelta: {x: 160, y: 50}
   m_Pivot: {x: 0, y: 0.5}
 --- !u!114 &1215898870
 MonoBehaviour:
@@ -3077,7 +3077,7 @@ GameObject:
   m_Icon: {fileID: 0}
   m_NavMeshLayer: 0
   m_StaticEditorFlags: 0
-  m_IsActive: 1
+  m_IsActive: 0
 --- !u!114 &2012199174
 MonoBehaviour:
   m_ObjectHideFlags: 0

+ 4 - 3
Assets/BowArrow/Scripts/Bluetooth/BluetoothAim.cs

@@ -122,8 +122,9 @@ public class BluetoothAim : MonoBehaviour
                         }
                     }
                 }
-                CallDelay(1, OpenInfrared);
-                CallDelay(2, OpenReceiveData);
+                CallDelay(1, OpenReceiveData);
+                // CallDelay(1, OpenInfrared);
+                // CallDelay(2, OpenReceiveData);
             };
             bluetoothHelper.OnConnectionFailed += (BluetoothHelper helper) =>
             {
@@ -135,7 +136,7 @@ public class BluetoothAim : MonoBehaviour
                 hasData = true;
                 byte[] bytes = value;
                 // Log(String.Join(",", bytes));
-                DebugForDevice.OnDataReceived(bytes);
+                // DebugForDevice.OnDataReceived(bytes);
                 BluetoothClient.UploadData(0, bytes);
                 if (AimHandler.ins)
                 {

+ 60 - 34
Assets/BowArrow/Scripts/Game/AimLoadChecker.cs

@@ -2,49 +2,75 @@ using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
+using DG.Tweening;
 
 /**瞄准器负载检测 */
 public class AimLoadChecker : MonoBehaviour
 {
     [SerializeField] GameObject outTip;
 
-    void Update()
-    {
-        bool needActiveOutTip = false;
-        if (ArmBow.ins && ArmBow.ins.IsCanShoot() && TargetBody.ins) {
-            RaycastHit ray = CrossHair.ins.GetRaycastHit();
-            if (ray.transform && ray.transform.gameObject.name == "TargetBody") {
-                float mySpeed = Arrow.speed;
-                if (GameAssistUI.ins) {
-                    mySpeed *= GameAssistUI.ins.shootScaleValue;
-                } 
-                Vector3 destination = ray.point;
-                Vector3 startPoint = BowCamera.ins.transform.position;
-                float deltaX = Mathf.Sqrt(
-                    Mathf.Pow(destination.x - startPoint.x, 2) +
-                    Mathf.Pow(destination.z - startPoint.z,2)
-                );
-                float deltaY = destination.y - startPoint.y;
-                float a = 0.5f * Physics.gravity.y * Mathf.Pow(deltaX, 2) / Mathf.Pow(mySpeed, 2);
-                float b = deltaX;
-                float c = a - deltaY;
-                bool hasParabolaAngle = Mathf.Pow(b, 2) - 4 * a * c >= 0;
-                if (hasParabolaAngle) {
-                    float res1 = (-b + Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
-                    float res2 = (-b - Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
-                    float parabolaAngle = Mathf.Min(Mathf.Atan(res1), Mathf.Atan(res2)) / Mathf.PI * 180;
+    // void Update()
+    // {
+    //     bool needActiveOutTip = false;
+    //     if (ArmBow.ins && ArmBow.ins.IsCanShoot() && TargetBody.ins) {
+    //         RaycastHit ray = CrossHair.ins.GetRaycastHit();
+    //         if (ray.transform && ray.transform.gameObject.name == "TargetBody") {
+    //             float mySpeed = Arrow.speed;
+    //             if (GameAssistUI.ins) {
+    //                 mySpeed *= GameAssistUI.ins.shootScaleValue;
+    //             } 
+    //             Vector3 destination = ray.point;
+    //             Vector3 startPoint = BowCamera.ins.transform.position;
+    //             float deltaX = Mathf.Sqrt(
+    //                 Mathf.Pow(destination.x - startPoint.x, 2) +
+    //                 Mathf.Pow(destination.z - startPoint.z,2)
+    //             );
+    //             float deltaY = destination.y - startPoint.y;
+    //             float a = 0.5f * Physics.gravity.y * Mathf.Pow(deltaX, 2) / Mathf.Pow(mySpeed, 2);
+    //             float b = deltaX;
+    //             float c = a - deltaY;
+    //             bool hasParabolaAngle = Mathf.Pow(b, 2) - 4 * a * c >= 0;
+    //             if (hasParabolaAngle) {
+    //                 float res1 = (-b + Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
+    //                 float res2 = (-b - Mathf.Pow(Mathf.Pow(b, 2) - 4*a*c, 0.5f)) / (2 * a);
+    //                 float parabolaAngle = Mathf.Min(Mathf.Atan(res1), Mathf.Atan(res2)) / Mathf.PI * 180;
 
-                    needActiveOutTip = parabolaAngle > 5;               
-                }
-            }
-        }
-        ActiveOutTip(needActiveOutTip);
+    //                 needActiveOutTip = parabolaAngle > 5;               
+    //             }
+    //         }
+    //     }
+    //     ActiveOutTip(needActiveOutTip);
+    // }
+
+    // public void ActiveOutTip(bool value) 
+    // {
+    //     if (outTip.activeSelf != value) {
+    //         outTip.SetActive(value);
+    //     }
+    // }
+
+    public static AimLoadChecker ins;
+    
+    void Awake() {
+        ins = this;
     }
 
-    public void ActiveOutTip(bool value) 
-    {
-        if (outTip.activeSelf != value) {
-            outTip.SetActive(value);
+    Sequence outTipSeq;
+    public void ShowOutTip() {
+        if (outTipSeq != null) {
+            outTipSeq.Kill(true);
         }
+        outTip.SetActive(true);
+        Text text = outTip.GetComponent<Text>();
+        Sequence seq = DOTween.Sequence();
+        seq.Append(text.DOFade(1, 0f));
+        seq.AppendInterval(3f);
+        seq.Append(text.DOFade(0, 1f));
+        seq.AppendCallback(delegate() {
+            outTip.SetActive(false);
+            outTipSeq = null;
+        });
+        seq.SetUpdate(true);
+        outTipSeq = seq;
     }
 }

+ 1 - 0
Assets/BowArrow/Scripts/Game/Arrow.cs

@@ -76,6 +76,7 @@ public class Arrow : MonoBehaviour
         if (Mathf.Abs(deltaAngleX) > maxDeltaAngleX) {
             finalAngleX += baseAngleX;
             finalAngleX += deltaAngleX > 0 ? maxDeltaAngleX : -maxDeltaAngleX;
+            if (AimLoadChecker.ins) AimLoadChecker.ins.ShowOutTip(); 
         } else {
             finalAngleX += absoluteAngleX;
         }

+ 12 - 4
Assets/BowArrow/Scripts/View/DeviceBatteryView.cs

@@ -35,10 +35,14 @@ public class DeviceBatteryView : MonoBehaviour
             countingTime2 = 0;
             bool activeBow = BluetoothAim.ins && BluetoothAim.ins.status == BluetoothStatusEnum.ConnectSuccess;
             bool activeArrow = BluetoothShoot.ins && BluetoothShoot.ins.status == BluetoothStatusEnum.ConnectSuccess;
-            this.transform.Find("Layout/Label1").gameObject.SetActive(activeBow);
-            this.transform.Find("Layout/Frame1").gameObject.SetActive(activeBow);
-            this.transform.Find("Layout/Label2").gameObject.SetActive(activeArrow);
-            this.transform.Find("Layout/Frame2").gameObject.SetActive(activeArrow);
+            if (!activeBow) {
+                this.transform.Find("Layout/Label1").gameObject.SetActive(false);
+                this.transform.Find("Layout/Frame1").gameObject.SetActive(false);
+            }
+            if (!activeArrow) {
+                this.transform.Find("Layout/Label2").gameObject.SetActive(false);
+                this.transform.Find("Layout/Frame2").gameObject.SetActive(false);
+            }
         }
     }
 
@@ -62,8 +66,12 @@ public class DeviceBatteryView : MonoBehaviour
 
     public void RenderBattery(int deviceID, float value)
     {
+        bool active = true;
+        if (value == 0) active = false;
         Image img = this.transform.Find($"Layout/Frame{deviceID}/Bar").GetComponent<Image>();
         Text txt =this.transform.Find($"Layout/Frame{deviceID}/Value").GetComponent<Text>();
+        img.transform.parent.gameObject.SetActive(active);
+        txt.transform.parent.gameObject.SetActive(active);
         img.fillAmount = value / 100f;
         txt.text = ((int) value) + "%";
     }

+ 5 - 5
ProjectSettings/EditorBuildSettings.asset

@@ -6,15 +6,15 @@ EditorBuildSettings:
   serializedVersion: 2
   m_Scenes:
   - enabled: 1
-    path: Assets/BowArrow/Scenes/Home.unity
-    guid: 8aa5affa1b256294a8c908dbab6122d0
-  - enabled: 0
     path: Assets/BowArrow/Scenes/Entry.unity
     guid: 14a16d0455f1bf44a8cf4e02c0550a99
-  - enabled: 0
+  - enabled: 1
     path: Assets/BowArrow/Scenes/Login.unity
     guid: 200a793b1fc5aac438c87e1b342a939a
-  - enabled: 0
+  - enabled: 1
+    path: Assets/BowArrow/Scenes/Home.unity
+    guid: 8aa5affa1b256294a8c908dbab6122d0
+  - enabled: 1
     path: Assets/BowArrow/Scenes/Game.unity
     guid: 3ee64920a7ce6dd4782fcc656bb2b337
   m_configObjects: {}