lvjincheng 4 gadi atpakaļ
vecāks
revīzija
45939ac6dd

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

@@ -2192,7 +2192,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 30, y: 0}
+  m_AnchoredPosition: {x: 29.5, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &226891916
@@ -9315,7 +9315,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 50, y: 0}
+  m_AnchoredPosition: {x: 49, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1516138248
@@ -9613,7 +9613,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 80, y: 0}
+  m_AnchoredPosition: {x: 79, y: 0}
   m_SizeDelta: {x: 0, y: 40}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1571292484
@@ -9860,7 +9860,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 30, y: 0}
+  m_AnchoredPosition: {x: 29.5, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1679843226
@@ -10793,7 +10793,7 @@ RectTransform:
   m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
   m_AnchorMin: {x: 0, y: 0}
   m_AnchorMax: {x: 0, y: 0}
-  m_AnchoredPosition: {x: 30, y: 0}
+  m_AnchoredPosition: {x: 29.5, y: 0}
   m_SizeDelta: {x: 0, y: 33}
   m_Pivot: {x: 0.5, y: 0.5}
 --- !u!114 &1905554419
@@ -11853,7 +11853,7 @@ Camera:
     y: 0
     width: 1
     height: 1
-  near clip plane: 0.3
+  near clip plane: 0.01
   far clip plane: 1000
   field of view: 45
   orthographic: 0

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

@@ -9,7 +9,7 @@ public class Arrow : MonoBehaviour
     public float flyTime = 0;
     public bool isHit = false;
     public ArmBow armBow;
-    public static float speed = GameMgr.RealSizeToGameSize(140);
+    public static float speed = GameMgr.RealSizeToGameSize(60);
 
     void Awake()
     {

+ 56 - 9
Assets/BowArrow/Scripts/Game/ArrowCamera.cs

@@ -6,17 +6,56 @@ using DG.Tweening;
 public class ArrowCamera : MonoBehaviour
 {
     public Arrow arrow;
+    ArrowCameraTemplate arrowCameraTemplate;
 
     void Start()
     {
-        
+        if (Random.value < 0.5) arrowCameraTemplate = new ArrowCameraTemplate1(this);    
+        else arrowCameraTemplate = new ArrowCameraTemplate2(this);
+        // arrowCameraTemplate = new ArrowCameraTemplate2(this);
     }
 
     void FixedUpdate()
     {
-        updateMoveCamera(); 
+        arrowCameraTemplate.Update(); 
+    }
+}
+
+class ArrowCameraTemplate2 : ArrowCameraTemplate 
+{
+    public ArrowCameraTemplate2(ArrowCamera arrowCamera)  : base(arrowCamera) {
+        this.arrowCamera.transform.parent = null;
+        arrowCamera.transform.localPosition = new Vector3(9.94f, 2.24f, 1.74f);
+        arrowCamera.transform.localEulerAngles = new Vector3(0, -52.32f, 0);
     }
 
+    bool isHit = false;
+    public override void Update() {
+        if (!isHit) {
+            isHit = arrowCamera.arrow.isHit;
+            if (isHit) {
+                this.arrowCamera.transform.SetParent(this.arrowCamera.arrow.transform);
+                arrowCamera.transform.localPosition = new Vector3(-0.6f, 0.1f, -0.8f);
+                arrowCamera.transform.LookAt(this.arrowCamera.arrow.transform.Find("Head"));
+                Sequence seq = DOTween.Sequence();
+                seq.PrependInterval(1f);
+                seq.AppendCallback(delegate() {
+                    this.arrowCamera.arrow.nextShoot();
+                    this.arrowCamera.arrow.enabled = false;
+                    GameObject.Destroy(this.arrowCamera.gameObject);
+                });
+                return;
+            }
+        }
+        if (!arrowCamera.arrow) {
+            GameObject.Destroy(this.arrowCamera.gameObject);
+        }
+    }
+}
+class ArrowCameraTemplate1 : ArrowCameraTemplate 
+{
+    public ArrowCameraTemplate1(ArrowCamera arrowCamera)  : base(arrowCamera) {}
+    
     /**相机移动 */
     private bool cameraMoveFinish = false;
     //相机的位置xyz变化 【每秒变化量,最小值,最大值】
@@ -31,13 +70,13 @@ public class ArrowCamera : MonoBehaviour
         30, -1 - Mathf.Clamp(Arrow.speed / 20 * 6, 0, 6), -0.8f
     };
 
-    private void updateMoveCamera() {
+    public override void Update() {
         if (cameraMoveFinish) {
             return;
         }
-        Transform cameraT = this.transform;
+        Transform cameraT = this.arrowCamera.transform;
         Vector3 cameraPosition = cameraT.localPosition;
-        if (arrow.isHit) {
+        if (this.arrowCamera.arrow.isHit) {
             cameraPosition.x = Mathf.Clamp(cameraPosition.x + this.cpcs[9] * Time.deltaTime, this.cpcs[10], this.cpcs[11]);
             cameraPosition.y = Mathf.Clamp(cameraPosition.y + this.cpcs[12] * Time.deltaTime, this.cpcs[13], this.cpcs[14]);
             cameraPosition.z = Mathf.Clamp(cameraPosition.z + this.cpcs[15] * Time.deltaTime, this.cpcs[16], this.cpcs[17]);
@@ -51,9 +90,9 @@ public class ArrowCamera : MonoBehaviour
                 Sequence seq = DOTween.Sequence();
                 seq.AppendInterval(1.0f);
                 seq.AppendCallback(delegate() {
-                    arrow.nextShoot();
-                    Destroy(cameraT.gameObject);
-                    this.enabled = false;
+                    this.arrowCamera.arrow.nextShoot();
+                    this.arrowCamera.arrow.enabled = false;
+                    GameObject.Destroy(this.arrowCamera.gameObject);
                 });
             }
         } else {
@@ -62,8 +101,16 @@ public class ArrowCamera : MonoBehaviour
             cameraPosition.z = Mathf.Clamp(cameraPosition.z + this.cpcs[6] * Time.deltaTime, this.cpcs[7], this.cpcs[8]);
         }
         cameraT.localPosition = cameraPosition;
-        cameraT.LookAt(arrow.transform.Find("Head"));
+        cameraT.LookAt(this.arrowCamera.arrow.transform.Find("Head"));
+    }
+}
+class ArrowCameraTemplate {
+    public ArrowCamera arrowCamera;
+    public ArrowCameraTemplate(ArrowCamera arrowCamera)
+    {
+        this.arrowCamera = arrowCamera;
     }
+    public virtual void Update() {}
 }
 
 // public class ArrowCamera : MonoBehaviour