lvjincheng 3 gadi atpakaļ
vecāks
revīzija
655fca4619

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

@@ -11,7 +11,7 @@ public class Arrow : MonoBehaviour
     //标识—是否击中了什么
     [NonSerialized] public bool isHit = false;
     //箭的初速度(私用)    
-    private float mySpeed = 0;
+    [NonSerialized] public float mySpeed = 0;
     //箭的初速度(公用)
     public static float speed = GameMgr.RealSizeToGameSize(60);
 
@@ -236,7 +236,7 @@ public class Arrow : MonoBehaviour
             if (flyTime > 14) {
                 FlyTimeOut();
             }
-            this.UpdateRotate();
+            // this.UpdateRotate();
         }
     }
     public ArrowSync.SyncData outputSyncData;

+ 2 - 0
Assets/BowArrow/Scripts/Game/ArrowCamera.cs

@@ -190,6 +190,8 @@ class ArrowCameraTemplate1 : ArrowCameraTemplate
     public ArrowCameraTemplate1(ArrowCamera arrowCamera)  : base(arrowCamera) {
         if (!arrowCamera.isArrowSync) {
             this.arrowCamera.arrow.activeEffectCyclone(true);
+        } else {
+            this.arrowCamera.arrowSync.activeEffectCyclone(true);
         }
     }
     

+ 56 - 7
Assets/BowArrow/Scripts/Manager/GameMode/OnlineObject/ArrowSync.cs

@@ -1,6 +1,7 @@
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
+using DG.Tweening;
 
 public class ArrowSync : MonoBehaviour
 {
@@ -20,9 +21,38 @@ public class ArrowSync : MonoBehaviour
         return transform.Find("Head");
     }
 
+    #region ---------箭矢特效---------
+        public void activeEffectCyclone(bool value)
+        {
+            this.transform.Find("Head/EF_kuosanquan").gameObject.SetActive(value);
+            if (!value) return;
+            ParticleSystemRenderer ps = this.transform.Find("Head/EF_kuosanquan/kuosan").GetComponent<ParticleSystemRenderer>();
+            ParticleSystemRenderer ps1 = this.transform.Find("Head/EF_kuosanquan/kuosan (1)").GetComponent<ParticleSystemRenderer>();
+            DOTween.To(() => ps.minParticleSize, value => {
+                ps.minParticleSize = value;
+                ps.maxParticleSize = value;
+            }, 0.4f, 0.6f);
+            DOTween.To(() => ps1.minParticleSize, value => {
+                ps1.minParticleSize = value;
+                ps1.maxParticleSize = value;
+            }, 0.8f, 0.6f);
+        }
+        void activeEffectBomb(bool value) 
+        {
+            this.transform.Find("Head/EF_baodian").gameObject.SetActive(value);
+        }
+        void activeEffectTrail(bool value)
+        {
+            this.transform.Find("EF_tuowei").gameObject.SetActive(value);
+            this.transform.Find("EF_tuowei/Trail").GetComponent<TrailRenderer>().time = 1.6f / mySpeed;
+        }
+    #endregion
+
     Quaternion rotation;
     Vector3 position;
+    float mySpeed;
     bool hasPlayHitAudio = false;
+    bool hasPlayHitEffect = false;
     [System.NonSerialized] public bool isHit;
     [System.NonSerialized] public bool canUseSideCamera;
     [System.NonSerialized] public bool hasSetSyncData = false; //外部运算用的
@@ -36,16 +66,27 @@ public class ArrowSync : MonoBehaviour
         position.z = syncData.pz;
         canUseSideCamera = syncData.cs;
         isHit = syncData.ih;
+        mySpeed = syncData.sp;
         if (apply) {
             transform.position = position;
             transform.rotation = rotation;
-            //激活镜头
-            Transform cameraTF = this.transform.Find("Camera");
-            cameraTF.gameObject.SetActive(true);
-            ArrowCamera arrowCameraComp = cameraTF.gameObject.AddComponent<ArrowCamera>();
-            arrowCameraComp.SetArrowSync(this);
-            //射出的声音
-            AudioMgr.ins.PlayShoot(AudioMgr.GetAudioSource(this.gameObject));
+            if (!isHit) {
+                //激活镜头
+                Transform cameraTF = this.transform.Find("Camera");
+                cameraTF.gameObject.SetActive(true);
+                ArrowCamera arrowCameraComp = cameraTF.gameObject.AddComponent<ArrowCamera>();
+                arrowCameraComp.SetArrowSync(this);
+                //射出的声音
+                AudioMgr.ins.PlayShoot(AudioMgr.GetAudioSource(this.gameObject));
+                //拖尾
+                activeEffectTrail(true);
+            }
+            else if (isHit) {
+                hasPlayHitAudio = true;
+                hasPlayHitEffect = true;
+                activeEffectCyclone(false);
+                activeEffectTrail(false);
+            }
         }
         if (isHit && !hasPlayHitAudio) {
             hasPlayHitAudio = true;
@@ -59,6 +100,12 @@ public class ArrowSync : MonoBehaviour
                 AudioMgr.ins.PlayCheer(false);
             }
         }
+        if (isHit && !hasPlayHitEffect) {
+            hasPlayHitEffect = true;
+            activeEffectBomb(true);
+            activeEffectCyclone(false);
+            activeEffectTrail(false);
+        }
     }
 
     public class SyncData {
@@ -75,6 +122,7 @@ public class ArrowSync : MonoBehaviour
         public bool cs;
         public bool ih;
         public int ht;
+        public float sp;
         public void SetData(Arrow arrow) {
             Quaternion r = arrow.transform.rotation;
             Vector3 p = arrow.Head().transform.position;
@@ -88,6 +136,7 @@ public class ArrowSync : MonoBehaviour
             cs = arrow.canUseSideCamera;
             ih = arrow.isHit;
             ht = arrow.hitType;
+            sp = arrow.mySpeed;
             if (!inited) {
                 id = autoID++;
                 if (autoID > 1000) autoID = 0;