|
|
@@ -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;
|