This commit is contained in:
账号名 2024-01-21 16:21:36 +08:00
parent 271977ab25
commit ab43740c90
3 changed files with 19 additions and 5 deletions

View File

@ -262,7 +262,7 @@ public class EquipmentCommon : MonoBehaviour
break;
case "SingleDronePosition"://无人机攻击目标锁定
UnmannedAerialVehicleManage unmannedAerialVehicleManage = GetComponent<UnmannedAerialVehicleManage>();
if (unmannedAerialVehicleManage)
if (unmannedAerialVehicleManage&& unmannedAerialVehicleManage.wrjModel== WRJModel.)
{
for (int i = 0; i < unmannedAerialVehicleManage.unmannedAerialVehicles.Count; i++)
{

View File

@ -230,6 +230,9 @@ public class UnmannedAerialVehicle : MonoBehaviour
}
else
{
string nowData = GetSyncData(attackTarget);
Debug.Log(nowData);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
float distance = Vector3.Distance(transform.position, attackTarget.position);
transform.DOMove(attackTarget.position, distance / FireSpeed).SetEase(Ease.Linear).OnComplete(() =>
{
@ -243,6 +246,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
}
}
/// <summary>
/// 远程攻击
/// </summary>
@ -253,8 +257,9 @@ public class UnmannedAerialVehicle : MonoBehaviour
yield return new WaitForSeconds(5f);
GameObject obj = Instantiate(bulletPrefab, bulletPoint.position, bulletPoint.rotation);
obj.SetActive(true);
Rigidbody rb = obj.GetComponent<Rigidbody>();
rb.AddForce(bulletPoint.forward * 20f, ForceMode.Impulse);
//Rigidbody rb = obj.GetComponent<Rigidbody>();
//rb.AddForce(bulletPoint.forward * 20f, ForceMode.Impulse);
obj.transform.DOMove(attackTarget.position, 2).SetEase(Ease.Linear);
ShellBoom sb = obj.AddComponent<ShellBoom>();
sb.isPlayer = unmannedAerialVehicleManage.equipmentCommon.isPlayer;
sb.onShellAttack.AddListener(() =>
@ -294,5 +299,14 @@ public class UnmannedAerialVehicle : MonoBehaviour
return string.Format("{0},{1},{2}", "DroneWasDestroyed", unmannedAerialVehicleManage.equipmentCommon.deviceID, serialNumber);
}
/// <summary>
/// 无人机攻击目标传递
/// </summary>
/// <returns></returns>
protected string GetSyncData(Transform attackTarget)
{
return string.Format("{0},{1},{2},{3},{4}", "SingleDronePosition", unmannedAerialVehicleManage.equipmentCommon.deviceID,
attackTarget.position.x, attackTarget.position.y, attackTarget.position.z);
}
}

View File

@ -304,11 +304,11 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
var highPriorityTargets = attackColliders1.FindAll(x => x.transform.GetComponent<HighPriorityTarget>());
if (highPriorityTargets.Count > 0)
{
SendMsg(highPriorityTargets[0].transform);
//SendMsg(highPriorityTargets[0].transform);
unmannedAerialVehicles[0].AttAck(highPriorityTargets[0].transform);
}
else{
SendMsg(attackColliders1[0].transform);
//SendMsg(attackColliders1[0].transform);
unmannedAerialVehicles[0].AttAck(attackColliders1[0].transform);
}