|
|
@@ -16,7 +16,7 @@ public enum BulletType
|
|
|
|
|
|
public class Bullet : MonoBehaviour
|
|
|
{
|
|
|
- public float stopTime;
|
|
|
+
|
|
|
public bool isBulletMove = true;
|
|
|
|
|
|
[Header("组件")]
|
|
|
@@ -25,8 +25,15 @@ public class Bullet : MonoBehaviour
|
|
|
public Rigidbody rb;
|
|
|
public List<BeHitTrigger> trigedObjs;
|
|
|
public BulletType bulletType;
|
|
|
+ [ShowIf("@bulletType == BulletType.Throw")]
|
|
|
+ public float stopTime;
|
|
|
[ShowIf("@bulletType == BulletType.Boomerang")]
|
|
|
- [LabelText("返回时间")] public float backDuration;
|
|
|
+ [LabelText("回旋镖移动时间")] public float backDuration;
|
|
|
+ [ShowIf("@bulletType == BulletType.Boomerang")]
|
|
|
+ [LabelText("停留时间")] public float stopDuration;
|
|
|
+ [ShowIf("@bulletType == BulletType.Boomerang")]
|
|
|
+ [DisplayOnly] public BoomerangWeaponController BoomerangWeaponController;
|
|
|
+ private Vector3 originalPos;
|
|
|
|
|
|
public bool isGetTarget = false;
|
|
|
public float speed;
|
|
|
@@ -59,6 +66,7 @@ public class Bullet : MonoBehaviour
|
|
|
[FoldoutGroup("条件")] [LabelText("是否能穿过地面")] public bool canPassGround;
|
|
|
|
|
|
public Vector3 originalScale;
|
|
|
+ private Vector3 dir;
|
|
|
|
|
|
private void Awake()
|
|
|
{
|
|
|
@@ -94,6 +102,24 @@ public class Bullet : MonoBehaviour
|
|
|
}
|
|
|
if (isTrack && trackTarget != null && !trackTarget.isDie && trackTarget.gameObject.activeInHierarchy)
|
|
|
{
|
|
|
+ if (bulletType == BulletType.Boomerang)
|
|
|
+ {
|
|
|
+ float addTime = backDuration + stopDuration;
|
|
|
+ if (flyTime >= addTime)
|
|
|
+ {
|
|
|
+ transform.position = Vector3.Lerp(originalPos, BoomerangWeaponController.transform.position, (flyTime - addTime) /(maxFlyTime - addTime));
|
|
|
+ }
|
|
|
+ else if(flyTime >= backDuration)
|
|
|
+ {
|
|
|
+ rb.velocity = Vector3.zero;
|
|
|
+ originalPos = transform.position;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ rb.velocity = dir * speed * ( 1 - flyTime / backDuration);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
if (canAlwaysTrack)
|
|
|
{
|
|
|
Vector3 tarDir = (trackTarget.beSearchTrigger.transform.position - transform.position).normalized;
|
|
|
@@ -118,6 +144,7 @@ public class Bullet : MonoBehaviour
|
|
|
|
|
|
isTrack = aim;
|
|
|
rb.velocity = dir * speed;
|
|
|
+ this.dir = dir;
|
|
|
trackTarget = target;
|
|
|
owner = own;
|
|
|
if (isTrack && trackTarget != null && !trackTarget.isDie && trackTarget.gameObject.activeInHierarchy)
|