12121
This commit is contained in:
parent
4c944a7444
commit
19049e6860
|
@ -125,7 +125,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
||||||
+ "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了";
|
+ "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了";
|
||||||
UploadLog(_log);
|
UploadLog(_log);
|
||||||
}
|
}
|
||||||
if(explodePrefab&&transform)
|
if (explodePrefab && transform)
|
||||||
{
|
{
|
||||||
GameObject Bao = Instantiate(explodePrefab, transform);
|
GameObject Bao = Instantiate(explodePrefab, transform);
|
||||||
Bao.transform.localPosition = Vector3.zero;
|
Bao.transform.localPosition = Vector3.zero;
|
||||||
|
@ -258,29 +258,29 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
||||||
Vector3 _v3 = attackTarget.position;
|
Vector3 _v3 = attackTarget.position;
|
||||||
transform.DOLookAt(_v3, 0.1f).OnComplete(() =>
|
transform.DOLookAt(_v3, 0.1f).OnComplete(() =>
|
||||||
{
|
{
|
||||||
if (wrjModel == WRJModel.光学无人机)
|
//if (wrjModel == WRJModel.光学无人机)
|
||||||
{
|
//{
|
||||||
Debug.Log("光学无人机攻击");
|
// //Debug.Log("光学无人机攻击");
|
||||||
StopCoroutine(RangedAttack());
|
// //StopCoroutine(RangedAttack());
|
||||||
StartCoroutine(RangedAttack());
|
// //StartCoroutine(RangedAttack());
|
||||||
}
|
//}
|
||||||
else
|
//else
|
||||||
{
|
//{
|
||||||
string nowData = GetSyncData(attackTarget);
|
string nowData = GetSyncData(attackTarget);
|
||||||
Debug.Log(nowData);
|
Debug.Log(nowData);
|
||||||
MyNetMQClient.instance.Send(nowData);
|
MyNetMQClient.instance.Send(nowData);
|
||||||
//_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
//_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||||
//DeviceManager.Instance.send2roomStr.Enqueue(nowData);
|
//DeviceManager.Instance.send2roomStr.Enqueue(nowData);
|
||||||
//MQTTManager.instance.SendData(MQTTManager.instance.SingleDronePosition, nowData);
|
//MQTTManager.instance.SendData(MQTTManager.instance.SingleDronePosition, nowData);
|
||||||
float distance = Vector3.Distance(transform.position, attackTarget.position);
|
float distance = Vector3.Distance(transform.position, attackTarget.position);
|
||||||
transform.DOMove(attackTarget.position, distance / FireSpeed).SetEase(Ease.Linear).OnComplete(() =>
|
transform.DOMove(attackTarget.position, distance / FireSpeed).SetEase(Ease.Linear).OnComplete(() =>
|
||||||
{
|
{
|
||||||
//if (!attackTarget)
|
//if (!attackTarget)
|
||||||
//{
|
//{
|
||||||
// //BeAssaulted("没有攻击到目标");
|
// //BeAssaulted("没有攻击到目标");
|
||||||
//}
|
//}
|
||||||
});
|
});
|
||||||
}
|
//}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -489,9 +489,15 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
||||||
|
|
||||||
public List<Collider> attackColliders1 = new List<Collider>();
|
public List<Collider> attackColliders1 = new List<Collider>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private bool GetAttackTarget(GameObject c)
|
||||||
|
{
|
||||||
|
if (Vector3.Distance(transform.position, c.transform.position) < 500f)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 攻击打击
|
/// 攻击打击
|
||||||
|
@ -501,27 +507,31 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
||||||
//if (isEngagedTarget) return;
|
//if (isEngagedTarget) return;
|
||||||
//if (wrjModel == WRJModel.电子侦察无人机 || wrjModel == WRJModel.光学无人机)
|
//if (wrjModel == WRJModel.电子侦察无人机 || wrjModel == WRJModel.光学无人机)
|
||||||
|
|
||||||
|
List<GameObject> allColliders = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetAttackTarget);
|
||||||
if (wrjModel == WRJModel.电子侦察无人机)
|
if (wrjModel == WRJModel.电子侦察无人机)
|
||||||
{
|
{
|
||||||
List<Collider> allColliders = Physics.OverlapSphere(transform.position,500).ToList(); // 检索范围内的所有碰撞体
|
//List<Collider> allColliders = Physics.OverlapSphere(transform.position,500).ToList(); // 检索范围内的所有碰撞体
|
||||||
|
|
||||||
for (int i = 0; i < allColliders.Count; i++)
|
for (int i = 0; i < allColliders.Count; i++)
|
||||||
{
|
{
|
||||||
attackColliders1.Add(allColliders[i]);
|
if (!attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
|
||||||
|
attackColliders1.Add(allColliders[i].GetComponent<Collider>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (wrjModel == WRJModel.光学无人机)
|
else if (wrjModel == WRJModel.光学无人机)
|
||||||
{
|
{
|
||||||
List<Collider> allColliders = Physics.OverlapSphere(transform.position,500).ToList(); // 检索范围内的所有碰撞体
|
//List<Collider> allColliders = Physics.OverlapSphere(transform.position, 500).ToList(); // 检索范围内的所有碰撞体
|
||||||
|
//List<GameObject> allColliders = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetAttackTarget);
|
||||||
|
|
||||||
for (int i = 0; i < allColliders.Count; i++)
|
for (int i = 0; i < allColliders.Count; i++)
|
||||||
{
|
{
|
||||||
if (allColliders[i].gameObject.tag == "AttackTarget" && !allColliders[i].isTrigger && !attackColliders1.Contains(allColliders[i]))
|
if (!allColliders[i].GetComponent<Collider>().isTrigger && !attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
|
||||||
{
|
{
|
||||||
Vector3 pos = gxWRJCamera.WorldToViewportPoint(allColliders[i].transform.position);
|
Vector3 pos = gxWRJCamera.WorldToViewportPoint(allColliders[i].transform.position);
|
||||||
bool ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
|
bool ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
|
||||||
if (ispcamera)
|
if (ispcamera)
|
||||||
{
|
{
|
||||||
attackColliders1.Add(allColliders[i]);
|
if (!attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
|
||||||
|
attackColliders1.Add(allColliders[i].GetComponent<Collider>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue