|
@@ -1,3 +1,4 @@
|
|
|
|
|
+using System.Collections;
|
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class FireBallController : MonoBehaviour
|
|
public class FireBallController : MonoBehaviour
|
|
@@ -20,17 +21,20 @@ public class FireBallController : MonoBehaviour
|
|
|
private float journeyTime; // 总飞行时间
|
|
private float journeyTime; // 总飞行时间
|
|
|
private float startTime; // 开始时间
|
|
private float startTime; // 开始时间
|
|
|
private Vector3 initialVelocity; // 初始速度
|
|
private Vector3 initialVelocity; // 初始速度
|
|
|
|
|
+ public GameObject fx;
|
|
|
|
|
|
|
|
private void Awake()
|
|
private void Awake()
|
|
|
{
|
|
{
|
|
|
// 确保组件存在
|
|
// 确保组件存在
|
|
|
if (rb == null)
|
|
if (rb == null)
|
|
|
rb = GetComponent<Rigidbody>();
|
|
rb = GetComponent<Rigidbody>();
|
|
|
|
|
+ gameObject.GetComponent<Bullet>().OnBulletHit += PushMe;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
private void OnEnable()
|
|
|
{
|
|
{
|
|
|
isFlying = false;
|
|
isFlying = false;
|
|
|
|
|
+ fx.SetActive(true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 初始化发射
|
|
// 初始化发射
|
|
@@ -153,4 +157,16 @@ public class FireBallController : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
gravity = newGravity;
|
|
gravity = newGravity;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public void PushMe()
|
|
|
|
|
+ {
|
|
|
|
|
+ StartCoroutine(PushBullet());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ IEnumerator PushBullet()
|
|
|
|
|
+ {
|
|
|
|
|
+ fx.SetActive(false);
|
|
|
|
|
+ yield return new WaitForSeconds(1);
|
|
|
|
|
+ gameObject.SetActive(false);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|