|
|
@@ -12,7 +12,9 @@ public class ArrowSync : MonoBehaviour
|
|
|
|
|
|
void Update()
|
|
|
{
|
|
|
- UpdatePosAndRot(Time.deltaTime * 15);
|
|
|
+ if (!hasAttachAnything) {
|
|
|
+ UpdatePosAndRot(Time.deltaTime * 15);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
void UpdatePosAndRot(float t) {
|
|
|
@@ -57,7 +59,10 @@ public class ArrowSync : MonoBehaviour
|
|
|
float mySpeed;
|
|
|
bool hasPlayHitAudio = false;
|
|
|
bool hasPlayHitEffect = false;
|
|
|
+ string[] hitTargetAnimalInfo;
|
|
|
+ bool hasAttachAnything = false;//是否附着在什么东西上,比如动物身上,这时候其实就不需要通过同步状态更新坐标了
|
|
|
ArrowCamera arrowCameraComp;
|
|
|
+
|
|
|
|
|
|
[System.NonSerialized] public bool isHit;
|
|
|
[System.NonSerialized] public bool hasDoneNextShoot;
|
|
|
@@ -75,6 +80,7 @@ public class ArrowSync : MonoBehaviour
|
|
|
bool oldIsHit = isHit;
|
|
|
isHit = syncData.ih;
|
|
|
hasDoneNextShoot = syncData.dns;
|
|
|
+ hitTargetAnimalInfo = syncData.htai;
|
|
|
mySpeed = syncData.sp;
|
|
|
if (apply) {
|
|
|
transform.position = position;
|
|
|
@@ -108,6 +114,18 @@ public class ArrowSync : MonoBehaviour
|
|
|
}
|
|
|
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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -154,6 +172,7 @@ public class ArrowSync : MonoBehaviour
|
|
|
public float sp;
|
|
|
public bool dns; //hasDoneNextShoot
|
|
|
public string act3; // ArrowCameraTemplate3
|
|
|
+ public string[] htai;
|
|
|
public void SetData(Arrow arrow) {
|
|
|
Quaternion r = arrow.transform.rotation;
|
|
|
Vector3 p = arrow.Head().transform.position;
|
|
|
@@ -169,6 +188,7 @@ public class ArrowSync : MonoBehaviour
|
|
|
ht = arrow.hitType;
|
|
|
sp = arrow.mySpeed;
|
|
|
dns = arrow.hasDoneNextShoot;
|
|
|
+ htai = arrow.hitTargetAnimalInfo;
|
|
|
if (!inited) {
|
|
|
id = autoID++;
|
|
|
if (autoID > 1000) autoID = 0;
|