激光打击
This commit is contained in:
parent
e092e99ad4
commit
ba63fc2cb4
|
@ -1176,7 +1176,6 @@ RectTransform:
|
|||
- {fileID: 5433276239701250115}
|
||||
- {fileID: 8129871292636694300}
|
||||
- {fileID: 9020723963205404447}
|
||||
- {fileID: 571368241678502618}
|
||||
m_Father: {fileID: 8500453589301871558}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -1452,6 +1451,7 @@ Transform:
|
|||
- {fileID: 5659378436633015230}
|
||||
- {fileID: 7407999243263411690}
|
||||
- {fileID: 7180026123191704634}
|
||||
- {fileID: 571368241678502618}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -2703,7 +2703,7 @@ PrefabInstance:
|
|||
m_ObjectHideFlags: 0
|
||||
serializedVersion: 2
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 7180026123191704634}
|
||||
m_TransformParent: {fileID: 8500453589301871558}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
|
@ -2718,7 +2718,7 @@ PrefabInstance:
|
|||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.z
|
||||
value: 1.28
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
|
@ -2763,22 +2763,22 @@ PrefabInstance:
|
|||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.x
|
||||
value: -960
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
propertyPath: m_AnchoredPosition.y
|
||||
value: -537.51
|
||||
value: 5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.x
|
||||
value: 120
|
||||
value: 150
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
propertyPath: m_SizeDelta.y
|
||||
value: 20
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 2477564191442231658, guid: ba4a837ca06ca3f4f96d140b7e44a3c5,
|
||||
type: 3}
|
||||
|
|
|
@ -304,19 +304,29 @@ public class EquipmentCommon : MonoBehaviour
|
|||
switch (data[0])
|
||||
{
|
||||
case "DronePosition"://无人机位置信息传递
|
||||
Vector3 pos = new Vector3(float.Parse(data[2]), float.Parse(data[3]), float.Parse(data[4]));
|
||||
positions.Enqueue(pos);
|
||||
if (!isPlayer)
|
||||
{
|
||||
Vector3 pos = new Vector3(float.Parse(data[2]), float.Parse(data[3]), float.Parse(data[4]));
|
||||
positions.Enqueue(pos);
|
||||
}
|
||||
|
||||
break;
|
||||
case "Lasing"://激光发射位置传递
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = GetComponent<LaserFireControlPlatformManger>();
|
||||
if (laserFireControlPlatformManger)
|
||||
laserFireControlPlatformManger.NonSelfGeneratedEmissionLaser(data);
|
||||
case "Lasing"://
|
||||
if (!isPlayer)
|
||||
{
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = GetComponent<LaserFireControlPlatformManger>();
|
||||
if (laserFireControlPlatformManger)
|
||||
laserFireControlPlatformManger.NonSelfGeneratedEmissionLaser(data);
|
||||
}
|
||||
|
||||
break;
|
||||
case "Micow"://微波武器发射位置
|
||||
Microwaveweapon microwaveweapon = GetComponent<Microwaveweapon>();
|
||||
if (microwaveweapon)
|
||||
{
|
||||
microwaveweapon.Microwavetransmission(data);
|
||||
if (!isPlayer) {
|
||||
Microwaveweapon microwaveweapon = GetComponent<Microwaveweapon>();
|
||||
if (microwaveweapon)
|
||||
{
|
||||
microwaveweapon.Microwavetransmission(data);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "SingleDronePosition"://无人机攻击目标锁定
|
||||
|
|
|
@ -88,6 +88,15 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// 计时器
|
||||
/// </summary>
|
||||
public float timepiece = 5;
|
||||
|
||||
/// <summary>
|
||||
/// 毁伤时间_记录
|
||||
/// </summary>
|
||||
public float destructionTime;
|
||||
/// <summary>
|
||||
/// 毁伤时间_使用
|
||||
/// </summary>
|
||||
public float destructionTimeMy;
|
||||
#endregion
|
||||
|
||||
|
||||
|
@ -97,7 +106,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// 是否这在攻击无人机
|
||||
/// </summary>
|
||||
public bool isLasing = false;//判断看向无人机
|
||||
public bool isLasings = false;//判断时候需要攻击
|
||||
public bool isLasings = true;//判断时候需要攻击
|
||||
public GameObject LaserModer;
|
||||
public GameObject LaserPoint;
|
||||
public Transform targetPoint; // 锁定目标点的Transform组件
|
||||
|
@ -158,7 +167,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// 判断物体是否在相机里面
|
||||
/// </summary>
|
||||
public bool ispcamera;
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
equipmentCommon = GetComponent<EquipmentCommon>();
|
||||
|
@ -190,7 +199,40 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
|
||||
void Update()
|
||||
{
|
||||
lasertime -= Time.deltaTime;
|
||||
if (isStartRehearsing && !targetPoint)
|
||||
{
|
||||
lasertime -= Time.deltaTime;
|
||||
}
|
||||
if (isLasings && destructionTimeMy > 0 && targetPoint != null)
|
||||
{
|
||||
destructionTimeMy -= Time.deltaTime;
|
||||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
|
||||
}
|
||||
Debug.LogError(destructionTimeMy);
|
||||
Debug.LogError("1");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, LaserPoint.transform.position); // 设置线段终点为目标点
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, LaserPoint.transform.position); // 设置线段终点为目标点
|
||||
}
|
||||
isLasing = false;
|
||||
}
|
||||
if (onlyOne && equipmentCommon.deviceID.Length > 10)
|
||||
{
|
||||
onlyOne = false;
|
||||
|
@ -229,6 +271,8 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
break;
|
||||
case "毁伤目标累积作用时间:":
|
||||
CumulativeActionTimeOfDamageTarget = weaponitemone[i].para_value;
|
||||
destructionTime = float.Parse(CumulativeActionTimeOfDamageTarget);
|
||||
destructionTimeMy = float.Parse(CumulativeActionTimeOfDamageTarget);
|
||||
break;
|
||||
case "干扰距离:":
|
||||
InterferenceDistance = weaponitemone[i].para_value;
|
||||
|
@ -253,7 +297,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
if (targetPoint != null)
|
||||
{
|
||||
LaserModer.transform.DOLookAt(targetPoint.position, 0.5f).OnComplete(() =>
|
||||
LaserModer.transform.DOLookAt(targetPoint.position, 0.3f).OnComplete(() =>
|
||||
{
|
||||
Launchanattack();
|
||||
});
|
||||
|
@ -271,10 +315,15 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
{
|
||||
if (targetPoint != null && Receivingdistance > 0)
|
||||
{
|
||||
if (targetPoint.GetComponent<UnmannedAerialVehicle>())
|
||||
equipmentCommonDeviceID = targetPoint.GetComponent<UnmannedAerialVehicle>().unmannedAerialVehicleManage.equipmentCommon.deviceID;
|
||||
|
||||
Vector3 pos = camera.WorldToViewportPoint(targetPoint.position);
|
||||
Debug.Log("攻击目标距离" + Vector3.Distance(targetPoint.position, transform.position));
|
||||
ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
|
||||
if (Vector3.Distance(targetPoint.position, transform.position) < Receivingdistance && ispcamera)
|
||||
float dis = Vector3.Distance(targetPoint.position, transform.position);
|
||||
Debug.Log(dis);
|
||||
if (dis < Receivingdistance && ispcamera)
|
||||
{
|
||||
Debug.Log("出现在摄像机视角里面了");
|
||||
Vector3 cector = targetPoint.position - transform.position;
|
||||
|
@ -284,10 +333,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
Debug.Log("角度合适进行打击");
|
||||
var nowData = GetSyncData();
|
||||
MyNetMQClient.instance.Send(nowData);
|
||||
//_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
//DeviceManager.Instance.send2roomStr.Enqueue(nowData);
|
||||
//MQTTManager.instance.SendData(MQTTManager.instance.Lasing, nowData);
|
||||
CastRayAndRender();
|
||||
StartCoroutine(CastRayAndRender1());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -303,25 +349,14 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 激光显示
|
||||
/// </summary>
|
||||
public void CastRayAndRender()
|
||||
public IEnumerator CastRayAndRender1()
|
||||
{
|
||||
|
||||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
|
||||
}
|
||||
isLasings = true;
|
||||
yield return new WaitForSeconds(destructionTime);
|
||||
isLasings = false;
|
||||
StrikeDrone(targetPoint);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 打击无人机
|
||||
/// </summary>
|
||||
|
@ -330,8 +365,8 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
UnmannedAerialVehicle unmannedAerialVehicle = hit.GetComponent<UnmannedAerialVehicle>();
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
//unmannedAerialVehicle.BeAssaulted("激光打击");
|
||||
AddBao(unmannedAerialVehicle);
|
||||
destructionTimeMy = destructionTime;
|
||||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
}
|
||||
|
@ -345,8 +380,6 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
string nowData = GetSyncDis(unmannedAerialVehicle);
|
||||
Debug.Log(nowData);
|
||||
MyNetMQClient.instance.Send(nowData);
|
||||
//DeviceManager.Instance.send2roomStr.Enqueue(nowData);
|
||||
//MQTTManager.instance.SendData(MQTTManager.instance.DroneWasDestroyed, nowData);
|
||||
string currentTime = System.DateTime.Now.ToString();
|
||||
string _log = currentTime + " " + equipmentCommon.equipmentType + "(" + equipmentCommon.deviceID + ")" +
|
||||
"攻击了销毁了" + unmannedAerialVehicle.unmannedAerialVehicleManage.equipmentCommon.equipmentType + "(" + unmannedAerialVehicle.unmannedAerialVehicleManage.equipmentCommon.deviceID + ")"
|
||||
|
@ -356,7 +389,6 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
Bao.transform.localPosition = Vector3.zero;
|
||||
Bao.transform.SetParent(null);
|
||||
Bao.SetActive(true);
|
||||
Destroy(unmannedAerialVehicle.gameObject);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -399,7 +431,8 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public IEnumerator LaserExtinction()
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
isLasings = false;
|
||||
yield return new WaitForSeconds(0.0f);
|
||||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
|
@ -415,7 +448,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
|
||||
#endregion
|
||||
|
||||
|
||||
public string equipmentCommonDeviceID = "";
|
||||
/// <summary>
|
||||
/// 激光发射点位
|
||||
/// </summary>
|
||||
|
@ -423,10 +456,11 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
protected string GetSyncData()
|
||||
{
|
||||
Debug.Log("目标点位..:" + targetPoint.position);
|
||||
return string.Format("{0},{1},{2},{3},{4}", "Lasing", equipmentCommon.deviceID, targetPoint.position.x, targetPoint.position.y, targetPoint.position.z);
|
||||
return string.Format("{0},{1},{2},{3},{4},{5}", "Lasing", equipmentCommon.deviceID ,
|
||||
targetPoint.position.x, targetPoint.position.y, targetPoint.position.z , equipmentCommonDeviceID);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <summary>q
|
||||
/// 非自生成激光发射台发射激光发射激光
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
|
@ -436,19 +470,41 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
Vector3 vector3 = new Vector3(float.Parse(data[2]), float.Parse(data[3]), float.Parse(data[4]));
|
||||
LaserModer.transform.DOLookAt(vector3, 0.1f).OnComplete(() =>
|
||||
{
|
||||
if (InnerLaserlineRenderer)
|
||||
EquipmentCommon _equipmentCommon = DeviceManager.Instance.devices.Find(x => x.deviceID == data[5]);
|
||||
if (_equipmentCommon)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, vector3); // 设置线段终点为目标点
|
||||
UnmannedAerialVehicleManage _unmannedAerialVehicleManage = _equipmentCommon.transform.GetComponent<UnmannedAerialVehicleManage>();
|
||||
if (_unmannedAerialVehicleManage&& _unmannedAerialVehicleManage.unmannedAerialVehicles.Count>0)
|
||||
{
|
||||
UnmannedAerialVehicle _unmannedAerialVehicle = _unmannedAerialVehicleManage.unmannedAerialVehicles[0];
|
||||
if (_unmannedAerialVehicle != null)
|
||||
{
|
||||
isLasings = true;
|
||||
targetPoint = _unmannedAerialVehicle.transform;
|
||||
destructionTimeMy = destructionTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (InnerLaserlineRenderer)
|
||||
{
|
||||
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
InnerLaserlineRenderer.SetPosition(1, vector3); // 设置线段终点为目标点
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, vector3); // 设置线段终点为目标点
|
||||
}
|
||||
}
|
||||
Invoke("LaserExtinction1", destructionTime);
|
||||
}
|
||||
}
|
||||
if (OuterLaserlineRenderer)
|
||||
{
|
||||
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
|
||||
OuterLaserlineRenderer.SetPosition(1, vector3); // 设置线段终点为目标点
|
||||
}
|
||||
StartCoroutine(LaserExtinction());
|
||||
});
|
||||
}
|
||||
private void LaserExtinction1()
|
||||
{
|
||||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
void OnMouseDown()
|
||||
{
|
||||
|
||||
|
|
|
@ -348,11 +348,12 @@ public class RadarManger : MonoBehaviour
|
|||
bool isnearBlindArea = Vector3.Distance(transform.position, unmannedAerialVehicle.transform.position) > nearBlindArea;
|
||||
if (!isnearBlindArea)
|
||||
continue;
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false && x.lasertime <= 0));
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.
|
||||
Find(x => (x != null && x.isLasing == false && x.lasertime <= 0));
|
||||
Microwaveweapon microwaveweapon = Microwaveweapon.MicrowaveweaponList.Find(x => x != null && x.ismicow == false);
|
||||
if (laserFireControlPlatformManger&& targets!=null)
|
||||
{
|
||||
laserFireControlPlatformManger.lasertime = laserFireControlPlatformManger.storageIntervalTime + 1.5f;
|
||||
laserFireControlPlatformManger.lasertime = laserFireControlPlatformManger.storageIntervalTime /*+ 1.5f*/;
|
||||
laserFireControlPlatformManger.isLasing = true;
|
||||
laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
|
||||
laserFireControlPlatformManger.Lasing();
|
||||
|
|
|
@ -8,6 +8,7 @@ using static InterfaceManager;
|
|||
using System;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
using System.Linq;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -413,9 +414,9 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public void RadioDisturbance()
|
||||
{
|
||||
Collider[] colliders = Physics.OverlapSphere(transform.position, detectionRadius * 1000 / 5);// 检索范围内的所有碰撞体
|
||||
|
||||
for (int i = 0; i < colliders.Length; i++)
|
||||
List<GameObject> colliders = GameObject.FindGameObjectsWithTag("WRJ").ToList().FindAll(Search);
|
||||
//Collider[] colliders = Physics.OverlapSphere(transform.position, detectionRadius * 1000 / 5);// 检索范围内的所有碰撞体
|
||||
for (int i = 0; i < colliders.Count; i++)
|
||||
{
|
||||
if (colliders[i].transform.tag == "WRJ")
|
||||
{
|
||||
|
@ -460,7 +461,17 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private bool Search(GameObject game)
|
||||
{
|
||||
if (Vector3.Distance(transform.position,game.transform.position)< detectionRadius * 1000 / 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///上传日志
|
||||
|
|
Loading…
Reference in New Issue