12121
This commit is contained in:
parent
4c944a7444
commit
19049e6860
|
@ -258,14 +258,14 @@ 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);
|
||||||
|
@ -280,7 +280,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
||||||
// //BeAssaulted("没有攻击到目标");
|
// //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>
|
/// <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