12121
This commit is contained in:
parent
4c944a7444
commit
19049e6860
|
@ -125,7 +125,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
+ "编号" + serialNumber + "子无人机" + "自杀式攻击自爆了";
|
||||
UploadLog(_log);
|
||||
}
|
||||
if(explodePrefab&&transform)
|
||||
if (explodePrefab && transform)
|
||||
{
|
||||
GameObject Bao = Instantiate(explodePrefab, transform);
|
||||
Bao.transform.localPosition = Vector3.zero;
|
||||
|
@ -258,14 +258,14 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
Vector3 _v3 = attackTarget.position;
|
||||
transform.DOLookAt(_v3, 0.1f).OnComplete(() =>
|
||||
{
|
||||
if (wrjModel == WRJModel.光学无人机)
|
||||
{
|
||||
Debug.Log("光学无人机攻击");
|
||||
StopCoroutine(RangedAttack());
|
||||
StartCoroutine(RangedAttack());
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (wrjModel == WRJModel.光学无人机)
|
||||
//{
|
||||
// //Debug.Log("光学无人机攻击");
|
||||
// //StopCoroutine(RangedAttack());
|
||||
// //StartCoroutine(RangedAttack());
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
string nowData = GetSyncData(attackTarget);
|
||||
Debug.Log(nowData);
|
||||
MyNetMQClient.instance.Send(nowData);
|
||||
|
@ -280,7 +280,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
// //BeAssaulted("没有攻击到目标");
|
||||
//}
|
||||
});
|
||||
}
|
||||
//}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -491,7 +491,13 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
|
||||
|
||||
|
||||
|
||||
private bool GetAttackTarget(GameObject c)
|
||||
{
|
||||
if (Vector3.Distance(transform.position, c.transform.position) < 500f)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 攻击打击
|
||||
|
@ -501,27 +507,31 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
//if (isEngagedTarget) return;
|
||||
//if (wrjModel == WRJModel.电子侦察无人机 || wrjModel == WRJModel.光学无人机)
|
||||
|
||||
List<GameObject> allColliders = GameObject.FindGameObjectsWithTag("AttackTarget").ToList().FindAll(GetAttackTarget);
|
||||
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++)
|
||||
{
|
||||
attackColliders1.Add(allColliders[i]);
|
||||
if (!attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
|
||||
attackColliders1.Add(allColliders[i].GetComponent<Collider>());
|
||||
}
|
||||
}
|
||||
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++)
|
||||
{
|
||||
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);
|
||||
bool ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
|
||||
if (ispcamera)
|
||||
{
|
||||
attackColliders1.Add(allColliders[i]);
|
||||
if (!attackColliders1.Contains(allColliders[i].GetComponent<Collider>()))
|
||||
attackColliders1.Add(allColliders[i].GetComponent<Collider>());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue