This commit is contained in:
账号名 2024-01-21 14:56:10 +08:00
parent 38fbae20bf
commit 494cb4b9a7
3 changed files with 68 additions and 52 deletions

View File

@ -116,29 +116,31 @@ public class DeviceManager : MonoSingleton<DeviceManager>
return tempUAM; return tempUAM;
} }
public List<UnmannedAerialVehicleManage> unmannedAerialVehicleManages;
public void SetCollider4WRJ(List<Collider> attackColliders, ref Collider currentTarget) public void SetCollider4WRJ(List<Collider> attackColliders, ref Collider currentTarget)
{ {
if (attackColliders.Count > 0) if (attackColliders.Count > 0)
{ {
List<UnmannedAerialVehicleManage> temp = GetGXWRJAndZSWRJ(); unmannedAerialVehicleManages = GetGXWRJAndZSWRJ();
for (int i = 0; i < temp.Count; i++) for (int i = 0; i < unmannedAerialVehicleManages.Count; i++)
{ {
if (temp[i].unmannedAerialVehicles[0] != null && temp[i].unmannedAerialVehicles[0].gameObject.activeSelf) if (unmannedAerialVehicleManages[i].unmannedAerialVehicles[0] != null && unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].gameObject.activeSelf)
{ {
if (temp[i].unmannedAerialVehicles[0].attackTarget == null) if (unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].attackTarget == null)
{ {
for (int j = 0; j < attackColliders.Count; j++) unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].AttAck(attackColliders[0].transform);
{ //for (int j = 0; j < attackColliders.Count; j++)
Collider c = null; //{
if (attackColliders[i] != null) // Collider c = null;
{ // if (attackColliders[i] != null)
c = attackColliders[i]; // {
} // c = attackColliders[i];
if (attackColliders[j] != null) // }
{ // if (attackColliders[j] != null)
temp[i].unmannedAerialVehicles[0].AttAck(attackColliders[j].transform); // {
} // unmannedAerialVehicleManages[i].unmannedAerialVehicles[0].AttAck(attackColliders[j].transform);
} // }
//}
} }
} }
@ -168,7 +170,7 @@ public class DeviceManager : MonoSingleton<DeviceManager>
if(highPriorityTarget) if(highPriorityTarget)
{ {
Vector3 Pos=new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5])); Vector3 Pos=new Vector3(float.Parse(info[3]), float.Parse(info[4]), float.Parse(info[5]));
highPriorityTarget.BeAssaulted(Pos, false); highPriorityTarget.BeAssaulted(Pos, false, int.Parse(info[2]));
} }
} }
else else

View File

@ -68,10 +68,6 @@ public class HighPriorityTarget : MonoBehaviour
if (isSend) if (isSend)
{ {
HP -= 10; HP -= 10;
GameObject Bao = Instantiate(explodePrefab, transform);
Bao.transform.localPosition = Pos;
Bao.transform.SetParent(null);
Bao.SetActive(true);
string nowData = GetSyncDis(Pos); string nowData = GetSyncDis(Pos);
Debug.Log(nowData); Debug.Log(nowData);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData)); _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
@ -80,6 +76,10 @@ public class HighPriorityTarget : MonoBehaviour
{ {
HP = hp; HP = hp;
} }
GameObject Bao = Instantiate(explodePrefab, transform);
Bao.transform.localPosition = Pos;
Bao.transform.SetParent(null);
Bao.SetActive(true);
if (HP < 50) if (HP < 50)
{ {
ModerFull.SetActive(false); ModerFull.SetActive(false);

View File

@ -72,7 +72,9 @@ public class UnmannedAerialVehicle : MonoBehaviour
public GameObject explodePrefab; public GameObject explodePrefab;
public TextMesh tips; public TextMesh tips;
/// <summary>
/// 攻击目标
/// </summary>
public Transform attackTarget; public Transform attackTarget;
/// <summary> /// <summary>
@ -129,6 +131,44 @@ public class UnmannedAerialVehicle : MonoBehaviour
Destroy(gameObject); Destroy(gameObject);
} }
/// <summary>
/// 销毁蓝方设备
/// </summary>
/// <param name="_transform"></param>
void AddBao(Transform _transform)
{
//设备
EquipmentCommon _equipmentCommon = _transform.GetComponent<EquipmentCommon>();
if (_equipmentCommon)
{
string nowData = string.Format("{0},{1}", "SetToBeDestroyed", _equipmentCommon.deviceID);
//Debug.Log(nowData);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
string currentTime = System.DateTime.Now.ToString();
string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")"
+ "编号" + serialNumber + "子无人机" + "攻击摧毁了" + _equipmentCommon.equipmentType + "(" + _equipmentCommon.deviceID + ")";
UploadLog(_log);
WWWForm headers = new WWWForm();
headers.AddField("id", _equipmentCommon.deviceID);
StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data =>
{
//Debug.Log(data);
}));
}
//重点打击目标
HighPriorityTarget highPriorityTarget = _transform.GetComponent<HighPriorityTarget>();
if (highPriorityTarget )
{
highPriorityTarget.BeAssaulted(transform.position, true);
}
GameObject Bao = Instantiate(explodePrefab, _transform);
Bao.transform.localPosition = Vector3.zero;
Bao.transform.SetParent(null);
Bao.SetActive(true);
Destroy(_transform.gameObject);
}
/// <summary> /// <summary>
///上传日志 ///上传日志
/// </summary> /// </summary>
@ -153,33 +193,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
})); }));
} }
/// <summary>
/// 销毁蓝方设备
/// </summary>
/// <param name="_transform"></param>
void AddBao(Transform _transform)
{
EquipmentCommon _equipmentCommon = _transform.GetComponent<EquipmentCommon>();
string nowData = string.Format("{0},{1}", "SetToBeDestroyed", _equipmentCommon.deviceID);
//Debug.Log(nowData);
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
string currentTime = System.DateTime.Now.ToString();
string _log = currentTime + " " + unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicleManage.equipmentCommon.deviceID + ")"
+ "编号" + serialNumber + "子无人机" + "攻击摧毁了" + _equipmentCommon.equipmentType + "(" + _equipmentCommon.deviceID + ")";
UploadLog(_log);
WWWForm headers = new WWWForm();
headers.AddField("id", _equipmentCommon.deviceID);
StartCoroutine(PostString(Url_Deletepracticedevicedetail, headers, data =>
{
//Debug.Log(data);
}));
GameObject Bao = Instantiate(explodePrefab, _transform);
Bao.transform.localPosition = Vector3.zero;
Bao.transform.SetParent(null);
Bao.SetActive(true);
Destroy(_transform.gameObject);
}
private void OnBecameInvisible() private void OnBecameInvisible()
@ -210,8 +224,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,7 +249,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
{ {
while (attackTarget) while (attackTarget)
{ {
yield return new WaitForSeconds(0.5f); yield return new WaitForSeconds(5f);
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>(); Rigidbody rb = obj.GetComponent<Rigidbody>();