|
|
@@ -64,6 +64,7 @@ public class ArrowSync : MonoBehaviour
|
|
|
bool hasPlayHitAudio = false;
|
|
|
bool hasPlayHitEffect = false;
|
|
|
string[] hitTargetAnimalInfo;
|
|
|
+ bool needCheckHitAnimal = false;//需要检测是否击中了动物?
|
|
|
bool hasAttachAnything = false;//是否附着在什么东西上,比如动物身上,这时候其实就不需要通过同步状态更新坐标了
|
|
|
ArrowCamera arrowCameraComp;
|
|
|
|
|
|
@@ -81,7 +82,6 @@ public class ArrowSync : MonoBehaviour
|
|
|
position.y = syncData.py;
|
|
|
position.z = syncData.pz;
|
|
|
canUseSideCamera = syncData.cs;
|
|
|
- bool oldIsHit = isHit;
|
|
|
isHit = syncData.ih;
|
|
|
hasDoneNextShoot = syncData.dns;
|
|
|
hitTargetAnimalInfo = syncData.htai;
|
|
|
@@ -90,6 +90,7 @@ public class ArrowSync : MonoBehaviour
|
|
|
transform.position = position;
|
|
|
transform.rotation = rotation;
|
|
|
if (!isHit || !hasDoneNextShoot) {
|
|
|
+ needCheckHitAnimal = true;
|
|
|
//激活镜头
|
|
|
Transform cameraTF = this.transform.Find("Camera");
|
|
|
cameraTF.gameObject.SetActive(true);
|
|
|
@@ -107,28 +108,27 @@ public class ArrowSync : MonoBehaviour
|
|
|
activeEffectTrail(false);
|
|
|
}
|
|
|
} else {
|
|
|
- if (!oldIsHit && isHit) {
|
|
|
- if (arrowCameraComp) {
|
|
|
- if (arrowCameraComp.arrowCameraTemplate == null) {
|
|
|
- isHit = false;
|
|
|
- } else if (arrowCameraComp.arrowCameraTemplate.GetType().Equals(typeof(ArrowCameraTemplate3))) {
|
|
|
- bool hasBlockByTree = false;
|
|
|
- if (syncData.HasArrowCameraTemplate3()) {
|
|
|
- hasBlockByTree = syncData.GetArrowCameraTemplate3().Item1;
|
|
|
- }
|
|
|
- UpdatePosAndRot(1f);
|
|
|
- ((ArrowCameraTemplate3) arrowCameraComp.arrowCameraTemplate).beforHitWhenSync(hasBlockByTree);
|
|
|
- if (hitTargetAnimalInfo != null) {
|
|
|
- int onlineID = int.Parse(hitTargetAnimalInfo[0]);
|
|
|
- int partIndex = int.Parse(hitTargetAnimalInfo[1]);
|
|
|
- TargetAnimal[] targetAnimals = GameObject.FindObjectsOfType<TargetAnimal>();
|
|
|
- foreach (var item in targetAnimals) {
|
|
|
- if (item.GetOnlineID() == onlineID) {
|
|
|
- this.transform.SetParent(item.targetAnimalParts[partIndex]);
|
|
|
- hasAttachAnything = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
+ if (arrowCameraComp && isHit && needCheckHitAnimal) {
|
|
|
+ needCheckHitAnimal = false;
|
|
|
+ if (arrowCameraComp.arrowCameraTemplate == null) {
|
|
|
+ isHit = false;
|
|
|
+ } else if (arrowCameraComp.arrowCameraTemplate.GetType().Equals(typeof(ArrowCameraTemplate3))) {
|
|
|
+ bool hasBlockByTree = false;
|
|
|
+ if (syncData.HasArrowCameraTemplate3()) {
|
|
|
+ hasBlockByTree = syncData.GetArrowCameraTemplate3().Item1;
|
|
|
+ }
|
|
|
+ UpdatePosAndRot(1f);
|
|
|
+ ((ArrowCameraTemplate3) arrowCameraComp.arrowCameraTemplate).beforHitWhenSync(hasBlockByTree);
|
|
|
+ if (hitTargetAnimalInfo != null) {
|
|
|
+ int onlineID = int.Parse(hitTargetAnimalInfo[0]);
|
|
|
+ int partIndex = int.Parse(hitTargetAnimalInfo[1]);
|
|
|
+ TargetAnimal[] targetAnimals = GameObject.FindObjectsOfType<TargetAnimal>();
|
|
|
+ foreach (var item in targetAnimals) {
|
|
|
+ if (item.GetOnlineID() == onlineID) {
|
|
|
+ this.transform.SetParent(item.targetAnimalParts[partIndex]);
|
|
|
+ hasAttachAnything = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|