lvjincheng před 4 roky
rodič
revize
e4097fe0b6

+ 111 - 0
Assets/BowArrow/Resources/Prefabs/Views/DeviceCalibrateView.prefab

@@ -1,5 +1,115 @@
 %YAML 1.1
 %TAG !u! tag:unity3d.com,2011:
+--- !u!1 &3143278146965190397
+GameObject:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  serializedVersion: 6
+  m_Component:
+  - component: {fileID: 1611860986899252675}
+  - component: {fileID: 6731675575624031819}
+  - component: {fileID: 4710096192980780221}
+  - component: {fileID: 5249863965231648800}
+  - component: {fileID: 3696872205753952407}
+  m_Layer: 5
+  m_Name: TipFail
+  m_TagString: Untagged
+  m_Icon: {fileID: 0}
+  m_NavMeshLayer: 0
+  m_StaticEditorFlags: 0
+  m_IsActive: 0
+--- !u!224 &1611860986899252675
+RectTransform:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3143278146965190397}
+  m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+  m_LocalPosition: {x: 0, y: 0, z: 0}
+  m_LocalScale: {x: 1, y: 1, z: 1}
+  m_Children: []
+  m_Father: {fileID: 6984168368599178995}
+  m_RootOrder: 3
+  m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+  m_AnchorMin: {x: 0.5, y: 0.5}
+  m_AnchorMax: {x: 0.5, y: 0.5}
+  m_AnchoredPosition: {x: 0, y: -260}
+  m_SizeDelta: {x: 336, y: 32}
+  m_Pivot: {x: 0.5, y: 0.5}
+--- !u!222 &6731675575624031819
+CanvasRenderer:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3143278146965190397}
+  m_CullTransparentMesh: 1
+--- !u!114 &4710096192980780221
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3143278146965190397}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_Material: {fileID: 0}
+  m_Color: {r: 1, g: 0.2867924, b: 0.2867924, a: 1}
+  m_RaycastTarget: 1
+  m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
+  m_Maskable: 1
+  m_OnCullStateChanged:
+    m_PersistentCalls:
+      m_Calls: []
+  m_FontData:
+    m_Font: {fileID: 12800000, guid: 1ad2cf6c2f09744489d8c60b3fe3bab2, type: 3}
+    m_FontSize: 24
+    m_FontStyle: 0
+    m_BestFit: 0
+    m_MinSize: 2
+    m_MaxSize: 40
+    m_Alignment: 4
+    m_AlignByGeometry: 0
+    m_RichText: 1
+    m_HorizontalOverflow: 0
+    m_VerticalOverflow: 0
+    m_LineSpacing: 1
+  m_Text: "\u6821\u51C6\u6548\u679C\u4E0D\u7406\u60F3\uFF0C\u8BF7\u91CD\u65B0\u6821\u51C6\uFF01"
+--- !u!114 &5249863965231648800
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3143278146965190397}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: 3245ec927659c4140ac4f8d17403cc18, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  m_HorizontalFit: 2
+  m_VerticalFit: 2
+--- !u!114 &3696872205753952407
+MonoBehaviour:
+  m_ObjectHideFlags: 0
+  m_CorrespondingSourceObject: {fileID: 0}
+  m_PrefabInstance: {fileID: 0}
+  m_PrefabAsset: {fileID: 0}
+  m_GameObject: {fileID: 3143278146965190397}
+  m_Enabled: 1
+  m_EditorHideFlags: 0
+  m_Script: {fileID: 11500000, guid: b7cbfcb0916cf694fb3d059ea4b4c1da, type: 3}
+  m_Name: 
+  m_EditorClassIdentifier: 
+  textID: 120
+  layoutRebuildObject: {fileID: 0}
+  textFormatArgs: []
 --- !u!1 &3245592320226212658
 GameObject:
   m_ObjectHideFlags: 0
@@ -1344,6 +1454,7 @@ RectTransform:
   - {fileID: 6984168369480428192}
   - {fileID: 6984168368743123379}
   - {fileID: 6984168369897369987}
+  - {fileID: 1611860986899252675}
   m_Father: {fileID: 6984168368486957087}
   m_RootOrder: 2
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}

+ 1 - 1
Assets/BowArrow/Resources/Prefabs/Views/DeviceReconnectView.prefab

@@ -502,7 +502,7 @@ MonoBehaviour:
   m_Name: 
   m_EditorClassIdentifier: 
   m_Material: {fileID: 0}
-  m_Color: {r: 0, g: 0, b: 0, a: 0.60784316}
+  m_Color: {r: 0.2960484, g: 0.38679036, b: 0.5283019, a: 1}
   m_RaycastTarget: 1
   m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
   m_Maskable: 1

+ 3 - 3
Assets/BowArrow/Scenes/Game.unity

@@ -22119,13 +22119,13 @@ Transform:
   m_PrefabInstance: {fileID: 0}
   m_PrefabAsset: {fileID: 0}
   m_GameObject: {fileID: 1589823736}
-  m_LocalRotation: {x: -0.059020862, y: 0.76563114, z: 0.6365386, w: -0.07172234}
-  m_LocalPosition: {x: 0.306, y: -2.05, z: 0.252}
+  m_LocalRotation: {x: 0, y: 0.7466382, z: 0.6652304, w: 0}
+  m_LocalPosition: {x: -0.001, y: -2.432, z: 0.165}
   m_LocalScale: {x: 1, y: 1, z: 1}
   m_Children: []
   m_Father: {fileID: 1277689752}
   m_RootOrder: 5
-  m_LocalEulerAnglesHint: {x: -75.07, y: 225.883, z: -44.845}
+  m_LocalEulerAnglesHint: {x: -96.6, y: 0, z: 180}
 --- !u!20 &1589823738
 Camera:
   m_ObjectHideFlags: 0

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

@@ -42,7 +42,7 @@ public class AimHandler : MonoBehaviour
     Vector3 cMaxVector = new Vector3(0,0,0);
     Vector3 cMinVector = new Vector3(0, 0, 0);
 
-    o0MagneticCalibraterEllipsoidFitting MagCalibrater;
+    public o0MagneticCalibraterEllipsoidFitting MagCalibrater;
     o0GyrCalibrater GyrCalibrater;
 
     //陀螺仪校准进度记录

+ 4 - 0
Assets/BowArrow/Scripts/Components/TextAutoLanguage.cs

@@ -218,6 +218,8 @@ class LanguageDefault {
     public string text85 = "开始校准";
     public string text86 = "校准时需要将瞄准模块静止放在桌面上。";
     public string text116 = "重新校准";
+    public string text120 = "校准效果不理想,请重新校准!";
+    public string text121 = "取消校准";
     //游戏场景通用UI信息
     public string text200 = "引导";
     public string text201 = "开镜";
@@ -387,6 +389,8 @@ class LanguageEnglish : LanguageDefault {
     public new string text85 = "Calibrate";
     public new string text86 = "During calibration, the aiming module needs to be placed on the desktop.";
     public new string text116 = "Redo";
+    public new string text120 = "The calibration effect is not ideal, please recalibrate!";
+    public new string text121 = "Cancel";
     //游戏场景通用UI信息
     public new string text200 = "Guide";
     public new string text201 = "Scope";

+ 102 - 1
Assets/BowArrow/Scripts/Game/GameAssistUI.cs

@@ -12,9 +12,12 @@ public class GameAssistUI : MonoBehaviour
     [SerializeField] Text text2;
     public static GameAssistUI ins;
 
+    void Awake() {
+        ins = this;
+    }
+
     void Start()
     {
-        ins = this;
         this.transform.Find("Button0").GetComponent<Button>().onClick.AddListener(delegate(){
             AudioMgr.ins.PlayBtn();
             SceneManager.LoadScene("Home", LoadSceneMode.Single);
@@ -64,6 +67,8 @@ public class GameAssistUI : MonoBehaviour
             targetView.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 30);
             btnViewTarget.transform.GetComponent<RectTransform>().anchoredPosition = new Vector2(45, 195);
         }
+        //看看是不是双人游戏的再次对战
+        applyPlayerRecordsWhenGameTryAgain();
     }
 
     // ------ 开镜瞄准功能 ------
@@ -72,6 +77,7 @@ public class GameAssistUI : MonoBehaviour
     float[] scaleAimFieldOfViews = {30, 20, 12, 6, 3};
     float[] scaleAimScopeScales = {150, 98, 58, 29, 14.5f};
     Sequence seq1 = null;
+    bool scaleAimOn = false; //该功能是否处于打开状态
     bool openScaleAim()
     {   
         int scaleValue = GetPropScaleAimValue();
@@ -87,6 +93,8 @@ public class GameAssistUI : MonoBehaviour
             scope = bowCamera.transform.Find("Scope");
             float scopeScale = scaleAimScopeScales[scaleValue - 1];
             scope.localScale = new Vector3(scopeScale, scopeScale, scopeScale);
+            scaleAimOn = true;
+            onOpenScaleAimSuccess();
             return true;
         }
         if (seq1 != null && !seq1.IsComplete()) {
@@ -109,6 +117,8 @@ public class GameAssistUI : MonoBehaviour
         ArmBow.ins.transform.localPosition = localPosition;
         scope.localScale = new Vector3(0, 0, 0);
         scope = null;
+        scaleAimOn = false;
+        onCloseScaleAimSuccess();
     }
 
     int GetPropScaleAimValue()
@@ -128,6 +138,7 @@ public class GameAssistUI : MonoBehaviour
 
     public int shootScaleValue = 1;
     Sequence seq2 = null;
+    bool scaleShootOn = false; //该功能是否处于打开状态
 
     bool openScaleShoot()
     {   
@@ -138,6 +149,8 @@ public class GameAssistUI : MonoBehaviour
                 PropScaleShoot config = prop.config as PropScaleShoot;
                 shootScaleValue = config.scaleValue;
                 if (GameDebug.ins) GameDebug.ins.caluculateAbsoluteAngle();
+                scaleShootOn = true;
+                onOpenScaleShootSuccess();
                 return true;
             }
         }
@@ -154,5 +167,93 @@ public class GameAssistUI : MonoBehaviour
     {
         shootScaleValue = 1;
         if (GameDebug.ins) GameDebug.ins.caluculateAbsoluteAngle();
+        scaleShootOn = false;
+        onCloseScaleShootSuccess();
+    }
+
+    //------ 以下给双人模式分别记录提供的接口 ------
+
+    //两位玩家的开镜情况
+    bool[] playerScaleAimRecords = {false, false};
+    //两位玩家的加速情况
+    bool[] playerScaleShootRecords = {false, false};
+
+    private void onOpenScaleAimSuccess() {
+        if (GameMgr.gameType == 2) {
+            playerScaleAimRecords[getPlayerIndex()] = true;
+        }
+    }
+
+    private void onCloseScaleAimSuccess() {
+        if (GameMgr.gameType == 2) {
+            playerScaleAimRecords[getPlayerIndex()] = false;
+        }
+    }
+
+    private void onOpenScaleShootSuccess() {
+        if (GameMgr.gameType == 2) {
+            playerScaleShootRecords[getPlayerIndex()] = true;
+        }
+    }
+
+    private void onCloseScaleShootSuccess() {
+        if (GameMgr.gameType == 2) {
+            playerScaleShootRecords[getPlayerIndex()] = false;
+        }
+    }
+
+    private int getPlayerIndex() {
+        return ((PKGameMode) GameMgr.ins.gameMode).currentPlayerIndex;
+    }
+
+    private void updateFunctionByPlayerRecords() {
+        if (GameMgr.gameType != 2) return;
+        int playerIndex = getPlayerIndex();
+        if (scaleAimOn != playerScaleAimRecords[playerIndex]) {
+            Button btnScaleAim = this.transform.Find("Button2").GetComponent<Button>();
+            if (playerScaleAimRecords[playerIndex]) {
+                if (openScaleAim()) {
+                    btnScaleAim.GetComponentInChildren<Image>().material = outlight;
+                }
+            } else {
+                btnScaleAim.GetComponentInChildren<Image>().material = null;
+                closeScaleAim();
+            }
+        }
+        if (scaleShootOn != playerScaleShootRecords[playerIndex]) {
+            Button btnScaleShoot = this.transform.Find("Button3").GetComponent<Button>();
+            if (playerScaleShootRecords[playerIndex]) {
+                if (openScaleShoot()) {
+                    btnScaleShoot.GetComponentInChildren<Image>().material = outlight;
+                }
+            } else {
+                btnScaleShoot.GetComponentInChildren<Image>().material = null;
+                closeScaleShoot();
+            }
+        }
+    }
+
+    private static bool[] playerRecords = null; 
+
+    public void recordPlayerRecordsWhenGameTryAgain() {
+        if (GameMgr.gameType != 2) return;
+        playerRecords = new bool[] {
+            playerScaleAimRecords[0], playerScaleAimRecords[1],  
+            playerScaleShootRecords[0], playerScaleShootRecords[1]  
+        };
+    }
+
+    private void applyPlayerRecordsWhenGameTryAgain() {
+        if (playerRecords != null) {
+            playerScaleAimRecords[0] = playerRecords[0];
+            playerScaleAimRecords[1] = playerRecords[1];
+            playerScaleShootRecords[0] = playerRecords[2];
+            playerScaleShootRecords[1] = playerRecords[3];
+            playerRecords = null;
+        }
+    }
+
+    void Update() {
+        updateFunctionByPlayerRecords();
     }
 }

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

@@ -53,7 +53,7 @@ public class GameMgr : MonoBehaviour
     }
 
     public void StopGame() {
-        Destroy(GameObject.FindObjectOfType<BowCamera>());
+        if (BowCamera.ins) BowCamera.ins.enabled = false;
         Arrow[] arrows = GameObject.FindObjectsOfType<Arrow>();
         foreach(var arrow in arrows)
         {

+ 75 - 22
Assets/BowArrow/Scripts/View/DeviceCalibrateView.cs

@@ -53,20 +53,20 @@ public class DeviceCalibrateView : MonoBehaviour
     void OnDestroy()
     {
         BluetoothHolder.ins.HideMagEllipse(this);
-        if (gyrCalibrating) {
-            AimHandler.ins.CalibrateGyr(false);
-        }
-        if (magCalibrating) {
-            AimHandler.ins.CalibrateMag(false);
-        }
+        // if (gyrCalibrating) {
+        //     AimHandler.ins.CalibrateGyr(false);
+        // }
+        // if (magCalibrating) {
+        //     AimHandler.ins.CalibrateMag(false);
+        // }
     }
 
     bool canUpdateGyrCalibrateProgress = false;
     void Update()
     {   
         if (canUpdateGyrCalibrateProgress) {
-            int progress = (int) ((float) AimHandler.ins.gyrCalibrateCompleteCount * 100 / (float) AimHandler.ins.gyrCalibrateTotalCount);
-             progressGyrCalibrate.text = progress + "%";
+            int progress = AimHandler.ins.gyrCalibrateCompleteCount * 100 / AimHandler.ins.gyrCalibrateTotalCount;
+            progressGyrCalibrate.text = progress + "%";
             if (progress >= 100) {
                 FinishGyrCalibrate();
             }
@@ -103,31 +103,48 @@ public class DeviceCalibrateView : MonoBehaviour
     bool gyrCalibrating = false;
     void ClickGyrCalibrate() 
     {
-        Button btn = btnGyrCalibrate.GetComponent<Button>();
+        //Logic
         gyrCalibrating = !gyrCalibrating;
-        if (btn.enabled) {
-            btn.enabled = false;
-            btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGray");
-            btn.GetComponentInChildren<Text>().color = Color.gray;
+        interactableAllSkipBtns(!gyrCalibrating);
+        if (gyrCalibrating) {
             AimHandler.ins.gyrCalibrateCompleteCount = 0;
             canUpdateGyrCalibrateProgress = true;
-            AimHandler.ins.CalibrateGyr(true);
+        } else {
+            canUpdateGyrCalibrateProgress = false;
+        }
+        AimHandler.ins.CalibrateGyr(gyrCalibrating);
+        //UI
+        Button btn = btnGyrCalibrate.GetComponent<Button>();
+        if (gyrCalibrating) {
+            btn.GetComponentInChildren<TextAutoLanguage>().SetText(121);
+            btn.GetComponentInChildren<Text>().color = Color.red;
+        } else {
+            btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
+            Color outColor;
+            ColorUtility.TryParseHtmlString("#005AB6", out outColor);
+            btn.GetComponentInChildren<Text>().color = outColor;
         }
     }
 
     void FinishGyrCalibrate()
     {   
+        //Logic
+        gyrCalibrating = false;
+        interactableAllSkipBtns(true);
         canUpdateGyrCalibrateProgress = false;
-        if (!guide) {
-            Button btn = btnGyrCalibrate.GetComponent<Button>();
-            btn.enabled = true;
+        AimHandler.ins.CalibrateGyr(false);
+        //UI
+        Button btn = btnGyrCalibrate.GetComponent<Button>();
+        if (guide) {
+            btn.enabled = false;
+            btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGray");
+            btn.GetComponentInChildren<Text>().color = Color.gray;
+        } else {
             btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
-            btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonBlue");
             Color outColor;
             ColorUtility.TryParseHtmlString("#005AB6", out outColor);
             btn.GetComponentInChildren<Text>().color = outColor;
         }
-        AimHandler.ins.CalibrateGyr(false);
     }
 
     // ------ 地磁计校准 ------
@@ -136,12 +153,35 @@ public class DeviceCalibrateView : MonoBehaviour
     {
         Button btn = btnMagCalibrate.GetComponent<Button>();
         magCalibrating = !magCalibrating;
+        interactableAllSkipBtns(!magCalibrating);
         if (magCalibrating) {
+            activeMagTipFail(false);
             btn.GetComponentInChildren<TextAutoLanguage>().SetText(83);
             btn.GetComponentInChildren<Text>().color = Color.red;
             AimHandler.ins.CalibrateMag(true);
         } else {
-            if (guide) {
+            AimHandler.ins.CalibrateMag(false);
+            //检测校准完成时的圆是否理想
+            bool circleIsOk = true;
+            if (AimHandler.ins) {
+                Vector3 radius = AimHandler.ins.MagCalibrater._Radius;
+                if (radius.Equals(Vector3.zero)) {
+                    circleIsOk = false;
+                } else if (radius.x == 0 || radius.y == 0 || radius.z == 0) {
+                    circleIsOk = false;
+                } else if (
+                    Mathf.Abs(1f - radius.x / radius.y) > 0.2f ||
+                    Mathf.Abs(1f - radius.x / radius.z) > 0.2f ||
+                    Mathf.Abs(1f - radius.y / radius.z) > 0.2f
+                ) {
+                    circleIsOk = false;
+                }
+            }
+            //提示校准效果不理想
+            if (!circleIsOk) activeMagTipFail(true);
+            //调整校准按钮
+            if (guide && circleIsOk) {
+                //关闭按钮
                 btn.enabled = false;
                 btn.GetComponentInChildren<TextAutoLanguage>().SetText(82);
                 btn.GetComponent<Image>().sprite = Resources.Load<Sprite>("Textures/Common/ButtonGray");
@@ -150,9 +190,15 @@ public class DeviceCalibrateView : MonoBehaviour
                 btn.GetComponentInChildren<TextAutoLanguage>().SetText(116);
                 Color outColor;
                 ColorUtility.TryParseHtmlString("#005AB6", out outColor);
-                btn.GetComponentInChildren<Text>().color = outColor;
+                btn.GetComponentInChildren<Text>().color = outColor;    
             }
-            AimHandler.ins.CalibrateMag(false);
+        }
+    }
+
+    private void activeMagTipFail(bool value) {
+        Transform tipFail_T = this.transform.Find("Mag/TipFail");
+        if (tipFail_T.gameObject) {
+            tipFail_T.gameObject.SetActive(value);
         }
     }
 
@@ -164,6 +210,13 @@ public class DeviceCalibrateView : MonoBehaviour
         btn.GetComponentInChildren<Text>().color = Color.gray;
         btn.enabled = false;
     }
+
+    //设置所有跳转按钮是否可交互
+    private void interactableAllSkipBtns(bool value) {
+        this.btnBack.interactable = value;
+        this.btnNext.interactable = value;
+        this.btnFinish.interactable = value;
+    }
 }
 public enum  DeviceCalibrateItem
 {

+ 5 - 5
Assets/BowArrow/Scripts/View/DeviceReconnectView.cs

@@ -38,11 +38,11 @@ public class DeviceReconnectView : MonoBehaviour
         RenderDeviceNames();
         GameMgr.ins.addLockerForGamePause(this);
 
-        //测试阶段,暂时屏蔽该页面
-        Destroy(this.gameObject);
-        if (onComplete != null) {
-            onComplete();   
-        }
+        //用于测试阶段,暂时屏蔽该页面
+        // Destroy(this.gameObject);
+        // if (onComplete != null) {
+        //     onComplete();   
+        // }
     }
 
     void OnDestroy()

+ 1 - 0
Assets/BowArrow/Scripts/View/PKGameSettleView.cs

@@ -34,6 +34,7 @@ public class PKGameSettleView : MonoBehaviour
 
     public void TryAgain() {
         AudioMgr.ins.PlayBtn();
+        if (GameAssistUI.ins) GameAssistUI.ins.recordPlayerRecordsWhenGameTryAgain();
         SceneManager.LoadScene("Game", LoadSceneMode.Single);
     }
 }