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