|
@@ -30,7 +30,7 @@ public class Bullet : MonoBehaviour
|
|
|
public bool isBack; //回旋镖,会回来
|
|
public bool isBack; //回旋镖,会回来
|
|
|
public float stayTime; //在极点处停留时长
|
|
public float stayTime; //在极点处停留时长
|
|
|
private bool isStay = false;
|
|
private bool isStay = false;
|
|
|
- private Vector3 curDir;
|
|
|
|
|
|
|
+ //private Vector3 curDir;
|
|
|
private bool hasBack = false; //已经回来了
|
|
private bool hasBack = false; //已经回来了
|
|
|
|
|
|
|
|
[Header("传送门")]
|
|
[Header("传送门")]
|
|
@@ -39,10 +39,11 @@ public class Bullet : MonoBehaviour
|
|
|
[HideInInspector]
|
|
[HideInInspector]
|
|
|
public float transmitTime; //传送CD
|
|
public float transmitTime; //传送CD
|
|
|
public PortalsController portalsController;
|
|
public PortalsController portalsController;
|
|
|
|
|
+
|
|
|
|
|
+ private bool isInVain; //击中光球,攻击无效
|
|
|
|
|
|
|
|
private void Awake()
|
|
private void Awake()
|
|
|
{
|
|
{
|
|
|
- //owner = GetComponentInParent<Character>();
|
|
|
|
|
rb = GetComponent<Rigidbody>();
|
|
rb = GetComponent<Rigidbody>();
|
|
|
}
|
|
}
|
|
|
private void Update()
|
|
private void Update()
|
|
@@ -61,36 +62,43 @@ public class Bullet : MonoBehaviour
|
|
|
private void FixedUpdate()
|
|
private void FixedUpdate()
|
|
|
{
|
|
{
|
|
|
flyTime += Time.deltaTime;
|
|
flyTime += Time.deltaTime;
|
|
|
- if (!isStay && flyTime >= maxFlyTime)
|
|
|
|
|
|
|
+ if(flyTime >= maxFlyTime)
|
|
|
{
|
|
{
|
|
|
- if (!isBack)
|
|
|
|
|
- {
|
|
|
|
|
- isGetTarget = true;
|
|
|
|
|
- gameObject.SetActive(false);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- else
|
|
|
|
|
- {
|
|
|
|
|
- isStay = true;
|
|
|
|
|
- flyTime = 0;
|
|
|
|
|
- rb.velocity = Vector3.zero;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if(isStay && flyTime >= stayTime)
|
|
|
|
|
- {
|
|
|
|
|
- isStay = false;
|
|
|
|
|
- hasBack = true;
|
|
|
|
|
- trackTarget = owner;
|
|
|
|
|
- }
|
|
|
|
|
- if (hasBack)
|
|
|
|
|
- {
|
|
|
|
|
- if (owner.gameObject.activeSelf == false)
|
|
|
|
|
- {
|
|
|
|
|
- isStay = true;
|
|
|
|
|
- flyTime = 0;
|
|
|
|
|
- rb.velocity = Vector3.zero;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ isGetTarget = true;
|
|
|
|
|
+ gameObject.SetActive(false);
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
|
|
+ //回旋镖
|
|
|
|
|
+ //if (!isStay && flyTime >= maxFlyTime)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // if (!isBack)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // isGetTarget = true;
|
|
|
|
|
+ // gameObject.SetActive(false);
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+ // else
|
|
|
|
|
+ // {
|
|
|
|
|
+ // isStay = true;
|
|
|
|
|
+ // flyTime = 0;
|
|
|
|
|
+ // rb.velocity = Vector3.zero;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //}
|
|
|
|
|
+ //if(isStay && flyTime >= stayTime)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // isStay = false;
|
|
|
|
|
+ // hasBack = true;
|
|
|
|
|
+ // trackTarget = owner;
|
|
|
|
|
+ //}
|
|
|
|
|
+ //if (hasBack)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // if (owner.gameObject.activeSelf == false)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // isStay = true;
|
|
|
|
|
+ // flyTime = 0;
|
|
|
|
|
+ // rb.velocity = Vector3.zero;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //}
|
|
|
if (isTrack && trackTarget != null && !trackTarget.isDie && trackTarget.gameObject.activeInHierarchy)
|
|
if (isTrack && trackTarget != null && !trackTarget.isDie && trackTarget.gameObject.activeInHierarchy)
|
|
|
{
|
|
{
|
|
|
Vector3 tarDir = (trackTarget.beSearchTrigger.transform.position - transform.position).normalized;
|
|
Vector3 tarDir = (trackTarget.beSearchTrigger.transform.position - transform.position).normalized;
|
|
@@ -114,24 +122,34 @@ public class Bullet : MonoBehaviour
|
|
|
isTrack = track;
|
|
isTrack = track;
|
|
|
trackTarget = target;
|
|
trackTarget = target;
|
|
|
flyTime = 0;
|
|
flyTime = 0;
|
|
|
- curDir = dir;
|
|
|
|
|
|
|
+ //curDir = dir;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
private void OnTriggerEnter(Collider other)
|
|
|
{
|
|
{
|
|
|
- if (other.GetComponentInParent<Character>() == owner)
|
|
|
|
|
|
|
+
|
|
|
|
|
+ if (isGetTarget || isInVain)
|
|
|
{
|
|
{
|
|
|
- if (hasBack)
|
|
|
|
|
- {
|
|
|
|
|
- isGetTarget = true;
|
|
|
|
|
- gameObject.SetActive(false);
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
- if (isGetTarget)
|
|
|
|
|
|
|
+ Photosphere photosphere = other.GetComponentInParent<Photosphere>();
|
|
|
|
|
+ if (photosphere && Util.CheckCanHit(owner.tag, "Player"))
|
|
|
{
|
|
{
|
|
|
|
|
+ isInVain = true;
|
|
|
|
|
+ photosphere.Reflex(owner.beHitTrigger);
|
|
|
|
|
+ gameObject.SetActive(false);
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
|
|
+ //回旋镖
|
|
|
|
|
+ //if (other.GetComponentInParent<Character>() == owner)
|
|
|
|
|
+ //{
|
|
|
|
|
+ // if (hasBack)
|
|
|
|
|
+ // {
|
|
|
|
|
+ // isGetTarget = true;
|
|
|
|
|
+ // gameObject.SetActive(false);
|
|
|
|
|
+ // return;
|
|
|
|
|
+ // }
|
|
|
|
|
+ //}
|
|
|
BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
|
|
BeHitTrigger hitTrigger = other.GetComponent<BeHitTrigger>();
|
|
|
if (hitTrigger != null)
|
|
if (hitTrigger != null)
|
|
|
{
|
|
{
|