This commit is contained in:
parent
a306bcad2c
commit
184a763763
|
@ -7,6 +7,7 @@ public class ShellBoom : MonoBehaviour
|
|||
{
|
||||
public UnityEvent onShellAttack = new UnityEvent();
|
||||
public bool isPlayer = false;
|
||||
public Transform attackTarget;
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
Debug.Log(other.gameObject.name);
|
||||
|
@ -15,4 +16,11 @@ public class ShellBoom : MonoBehaviour
|
|||
onShellAttack?.Invoke();
|
||||
}
|
||||
}
|
||||
private void Update()
|
||||
{
|
||||
if (attackTarget != null)
|
||||
{
|
||||
transform.Translate(transform.forward * Time.deltaTime * 70f, Space.World);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,8 +210,8 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
if (wrjModel == WRJModel.光学无人机)
|
||||
{
|
||||
Debug.Log("光学无人机攻击");
|
||||
//StopCoroutine(RangedAttack());
|
||||
//StartCoroutine(RangedAttack());
|
||||
StopCoroutine(RangedAttack());
|
||||
StartCoroutine(RangedAttack());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -235,12 +235,11 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
{
|
||||
while (attackTarget)
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
yield return new WaitForSeconds(0.8f);
|
||||
GameObject obj = Instantiate(bulletPrefab, bulletPoint.position, bulletPoint.rotation);
|
||||
obj.SetActive(true);
|
||||
Rigidbody rb = obj.GetComponent<Rigidbody>();
|
||||
rb.AddForce(bulletPoint.forward * 20f, ForceMode.Impulse);
|
||||
ShellBoom sb = obj.AddComponent<ShellBoom>();
|
||||
sb.attackTarget = attackTarget;
|
||||
sb.isPlayer = unmannedAerialVehicleManage.equipmentCommon.isPlayer;
|
||||
sb.onShellAttack.AddListener(() =>
|
||||
{
|
||||
|
|
|
@ -305,7 +305,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
}
|
||||
if (unmannedAerialVehicles[0].attackTarget == null)
|
||||
{
|
||||
SendMsg(c.transform);
|
||||
if (c != null)
|
||||
SendMsg(c.transform);
|
||||
unmannedAerialVehicles[0].AttAck(c.transform);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue