Merge branch 'master' of http://git.umayle.com:2023/yulong/NewN_UAVPlane
This commit is contained in:
commit
35d33f127e
|
@ -380,7 +380,114 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 1326529938}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 13
|
||||
m_RootOrder: 14
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &131091531
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 131091536}
|
||||
- component: {fileID: 131091535}
|
||||
- component: {fileID: 131091534}
|
||||
- component: {fileID: 131091533}
|
||||
- component: {fileID: 131091532}
|
||||
m_Layer: 12
|
||||
m_Name: Cube
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!65 &131091532
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 131091531}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 1
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &131091533
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 131091531}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!23 &131091534
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 131091531}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
--- !u!33 &131091535
|
||||
MeshFilter:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 131091531}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!4 &131091536
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 131091531}
|
||||
m_LocalRotation: {x: -0, y: -0.7071068, z: -0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 422.99, y: 30, z: 80.41}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 12
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &144713087
|
||||
GameObject:
|
||||
|
@ -411,6 +518,10 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 014683e72ff868e4c9c0d3eec7d87a26, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
equipmentCommons:
|
||||
- {fileID: 727490127}
|
||||
- {fileID: 2041579131}
|
||||
- {fileID: 1611173771}
|
||||
unmannedAerialVehicleManages:
|
||||
- {fileID: 1156703774}
|
||||
radarMangers:
|
||||
|
@ -656,7 +767,7 @@ PrefabInstance:
|
|||
- target: {fileID: 625513913607457920, guid: 121324ce722bdb944a7cc1c7c3a5077f,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 0
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 121324ce722bdb944a7cc1c7c3a5077f, type: 3}
|
||||
|
@ -684,6 +795,18 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 8d431a7d95f5da7448bc421314544f20, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &727490127 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: -7238547075891962512, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 1446243674}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0afac659d8be281448f9ecd22f828b72, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &742343356
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -762,7 +885,7 @@ Transform:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 742343356}
|
||||
m_LocalRotation: {x: 0.30070576, y: 0, z: 0, w: 0.953717}
|
||||
m_LocalPosition: {x: 26, y: 190, z: -443}
|
||||
m_LocalPosition: {x: 170.9, y: 190, z: -443}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
|
@ -916,7 +1039,7 @@ PrefabInstance:
|
|||
- target: {fileID: 3977472425108262603, guid: 2b2524df6b4053a4aa08b1f5fe4d62f5,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 2b2524df6b4053a4aa08b1f5fe4d62f5, type: 3}
|
||||
|
@ -1325,12 +1448,12 @@ PrefabInstance:
|
|||
- target: {fileID: 6865737300552731159, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
value: 434.09
|
||||
value: 429.4
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6865737300552731159, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: 0
|
||||
value: 30
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6865737300552731159, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
|
@ -1360,7 +1483,7 @@ PrefabInstance:
|
|||
- target: {fileID: 6865737300552731159, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
value: 12
|
||||
value: 13
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 6865737300552731159, guid: 8425122cf585dcc47bbf3eff95ecf176,
|
||||
type: 3}
|
||||
|
@ -1379,6 +1502,18 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: 8425122cf585dcc47bbf3eff95ecf176, type: 3}
|
||||
--- !u!114 &1611173771 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 1145900336322340155, guid: 2b2524df6b4053a4aa08b1f5fe4d62f5,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 747100775}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0afac659d8be281448f9ecd22f828b72, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &1687255089
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -1871,7 +2006,7 @@ PrefabInstance:
|
|||
- target: {fileID: 7615181139496386322, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7615181139496386328, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
|
@ -1950,7 +2085,7 @@ PrefabInstance:
|
|||
- target: {fileID: 7615181139496386322, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
propertyPath: m_IsActive
|
||||
value: 1
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7615181139496386328, guid: 7abae14e48a106d4c8120d0eba515162,
|
||||
type: 3}
|
||||
|
@ -2075,3 +2210,15 @@ PrefabInstance:
|
|||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: ecdd96beb7f93494880c052dfccf9dc1, type: 3}
|
||||
--- !u!114 &2041579131 stripped
|
||||
MonoBehaviour:
|
||||
m_CorrespondingSourceObject: {fileID: 7287081401534477579, guid: 121324ce722bdb944a7cc1c7c3a5077f,
|
||||
type: 3}
|
||||
m_PrefabInstance: {fileID: 407575141}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 0}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0afac659d8be281448f9ecd22f828b72, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
|
|
|
@ -28,13 +28,15 @@ public class DeviceManager : MonoSingleton<DeviceManager>
|
|||
{
|
||||
data = data.Replace("send2room", "");
|
||||
string[] info = data.Split(',');
|
||||
EquipmentCommon equipmentCommon = devices.Find(x => x.deviceID == info[0]);
|
||||
EquipmentCommon equipmentCommon = devices.Find(x => x.deviceID == info[1]);
|
||||
if (equipmentCommon)
|
||||
{
|
||||
equipmentCommon.ReceivingPositionAngle(info);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void OnDisalbe()
|
||||
{
|
||||
SyncCreateRoom.send2roomRequset -= GetSend2roomMsg;
|
||||
|
|
|
@ -60,6 +60,10 @@ public class EquipmentCommon : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 爆炸预制体
|
||||
/// </summary>
|
||||
public GameObject explodePrefab;
|
||||
|
||||
void Start()
|
||||
{
|
||||
|
@ -75,7 +79,10 @@ public class EquipmentCommon : MonoBehaviour
|
|||
if (newValue && equipmentType == "无人机List" && isOnlyOne)
|
||||
{
|
||||
isOnlyOne = false;
|
||||
StartCoroutine(SendMsg());
|
||||
latestData = GetSyncData();
|
||||
InvokeRepeating("SendMsg", 0, 0.01f);
|
||||
UnmannedAerialVehicleManage unmannedAerialVehicleManage = GetComponent<UnmannedAerialVehicleManage>();
|
||||
unmannedAerialVehicleManage.unmannedAerialVehicles.ForEach(x => x.AddSendMsg());//每个无人机位置传递开启
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
|
@ -161,28 +168,23 @@ public class EquipmentCommon : MonoBehaviour
|
|||
//位置实时传送
|
||||
private string latestData = "";
|
||||
private bool isOnlyOne = true;
|
||||
public IEnumerator SendMsg()
|
||||
public void SendMsg()
|
||||
{
|
||||
while (true)
|
||||
var nowData = GetSyncData();
|
||||
if (!nowData.Equals(latestData))
|
||||
{
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
|
||||
var nowData = GetSyncData();
|
||||
if (!nowData.Equals(latestData))
|
||||
{
|
||||
latestData = nowData;
|
||||
//Debug.Log(latestData);
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
}
|
||||
latestData = nowData;
|
||||
Debug.Log(latestData);
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 无人机
|
||||
/// 无人机整体位置传递
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetSyncData()
|
||||
{
|
||||
return string.Format("{0},{1},{2},{3},{4},{5},{6}", equipmentCommon.deviceID, transform.position.x, transform.position.y, transform.position.z, transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z);
|
||||
return string.Format("{0},{1},{2},{3},{4},{5},{6},{7}", "DronePosition", equipmentCommon.deviceID, transform.position.x, transform.position.y, transform.position.z, transform.eulerAngles.x, transform.eulerAngles.y, transform.eulerAngles.z);
|
||||
}
|
||||
|
||||
|
||||
|
@ -192,30 +194,65 @@ public class EquipmentCommon : MonoBehaviour
|
|||
/// <param name="data"></param>
|
||||
public void ReceivingPositionAngle(string[] data)
|
||||
{
|
||||
switch (equipmentType)
|
||||
switch (data[0])
|
||||
{
|
||||
case "无人机List":
|
||||
case "DronePosition"://无人机位置信息传递
|
||||
Vector3 pos = new Vector3(float.Parse(data[1]), float.Parse(data[2]), float.Parse(data[3]));
|
||||
Vector3 rot = new Vector3(float.Parse(data[4]), float.Parse(data[5]), float.Parse(data[6]));
|
||||
transform.position = pos;
|
||||
transform.eulerAngles = rot;
|
||||
break;
|
||||
case "激光火控平台":
|
||||
case "Lasing"://激光发射位置传递
|
||||
LaserFireControlPlatformManger laserFireControlPlatformManger = GetComponent<LaserFireControlPlatformManger>();
|
||||
if (laserFireControlPlatformManger)
|
||||
laserFireControlPlatformManger.NonSelfGeneratedEmissionLaser(data);
|
||||
break;
|
||||
case "探测雷达":
|
||||
|
||||
case "SingleDronePosition"://单个无人机位置信息传递
|
||||
UnmannedAerialVehicleManage unmannedAerialVehicleManage = GetComponent<UnmannedAerialVehicleManage>();
|
||||
if (unmannedAerialVehicleManage)
|
||||
{
|
||||
UnmannedAerialVehicle unmannedAerialVehicle = unmannedAerialVehicleManage.unmannedAerialVehicles.Find(x => x.serialNumber == data[2]);
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
Vector3 localPos = new Vector3(float.Parse(data[3]), float.Parse(data[4]), float.Parse(data[5]));
|
||||
Vector3 localRot = new Vector3(float.Parse(data[6]), float.Parse(data[7]), float.Parse(data[8]));
|
||||
unmannedAerialVehicle.transform.localPosition = localPos;
|
||||
unmannedAerialVehicle.transform.localEulerAngles = localRot;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "地面无线电干扰":
|
||||
|
||||
case "DroneWasDestroyed"://单个无人机被销毁
|
||||
UnmannedAerialVehicleManage _unmannedAerialVehicleManage = GetComponent<UnmannedAerialVehicleManage>();
|
||||
if (_unmannedAerialVehicleManage)
|
||||
{
|
||||
UnmannedAerialVehicle unmannedAerialVehicle = _unmannedAerialVehicleManage.unmannedAerialVehicles.Find(x => x.serialNumber == data[2]);
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
unmannedAerialVehicle.AddBao(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "SetToBeDestroyed"://设备被销毁
|
||||
GameObject Bao = Instantiate(explodePrefab, transform);
|
||||
Bao.transform.localPosition = Vector3.zero;
|
||||
Bao.transform.SetParent(null);
|
||||
Bao.SetActive(true);
|
||||
Destroy(transform.gameObject);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
// 订阅布尔值变化事件
|
||||
OnActivationChanged -= OnActivationChangedHandler;
|
||||
//
|
||||
OnActivationIsPlayer -= OnActivationChangedIsPlayer;
|
||||
}
|
||||
}
|
||||
|
||||
public enum SelectedSide
|
||||
|
|
|
@ -216,14 +216,12 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
/// </summary>
|
||||
private void StrikeDrone(Transform hit)
|
||||
{
|
||||
if(hit.transform.tag== "WRJ")
|
||||
UnmannedAerialVehicle unmannedAerialVehicle = hit.GetComponent<UnmannedAerialVehicle>();
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
UnmannedAerialVehicle unmannedAerialVehicle = hit.GetComponent<UnmannedAerialVehicle>();
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
unmannedAerialVehicle.BeAssaulted("激光打击");
|
||||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
unmannedAerialVehicle.BeAssaulted("激光打击");
|
||||
|
||||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -256,7 +254,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
protected string GetSyncData()
|
||||
{
|
||||
Debug.Log("目标点位..:" + targetPoint.position);
|
||||
return string.Format("{0},{1},{2},{3}", equipmentCommon.deviceID, targetPoint.position.x, targetPoint.position.y, targetPoint.position.z);
|
||||
return string.Format("{0},{1},{2},{3},{4}", "Lasing", equipmentCommon.deviceID, targetPoint.position.x, targetPoint.position.y, targetPoint.position.z);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -278,4 +276,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
|
|||
}
|
||||
StartCoroutine(LaserExtinction());
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
OnActivationChanged -= OnActivationChangedHandler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ public class RadarManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public void StartTimer()
|
||||
{
|
||||
if (timerCoroutine == null)
|
||||
if (equipmentCommon.isPlayer && timerCoroutine == null)
|
||||
{
|
||||
timerCoroutine = StartCoroutine(Timer());
|
||||
isTimerRunning = true;
|
||||
|
@ -181,7 +181,7 @@ public class RadarManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public void StopTimer()
|
||||
{
|
||||
if (timerCoroutine != null)
|
||||
if (equipmentCommon.isPlayer && timerCoroutine != null)
|
||||
{
|
||||
StopCoroutine(timerCoroutine);
|
||||
timerCoroutine = null;
|
||||
|
@ -319,5 +319,9 @@ public class RadarManger : MonoBehaviour
|
|||
Debug.Log("鼠标离开");
|
||||
RadarUi.transform.localScale = Vector3.zero;
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
OnActivationChanged -= OnActivationChangedHandler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ using UnityEngine;
|
|||
/// </summary>
|
||||
public class SingleMachineTest : MonoBehaviour
|
||||
{
|
||||
|
||||
public List<EquipmentCommon> equipmentCommons = new List<EquipmentCommon>();
|
||||
/// <summary>
|
||||
/// 无人机
|
||||
/// </summary>
|
||||
|
@ -65,8 +67,6 @@ public class SingleMachineTest : MonoBehaviour
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[ContextMenu("Add")]
|
||||
|
@ -105,7 +105,8 @@ public class SingleMachineTest : MonoBehaviour
|
|||
if (timerCoroutine == null)
|
||||
{
|
||||
timerCoroutine = StartCoroutine(Timer());
|
||||
|
||||
|
||||
equipmentCommons.ForEach(x => x.isPlayer = true);
|
||||
unmannedAerialVehicleManages.ForEach(x => x.isStartRehearsing = true);
|
||||
radarMangers.ForEach(x => x.isStartRehearsing = true);
|
||||
laserFireControlPlatformMangers.ForEach(x => x.isStartRehearsing = true);
|
||||
|
@ -122,7 +123,6 @@ public class SingleMachineTest : MonoBehaviour
|
|||
{
|
||||
StopCoroutine(timerCoroutine);
|
||||
timerCoroutine = null;
|
||||
|
||||
unmannedAerialVehicleManages.ForEach(x => x.isStartRehearsing = false);
|
||||
radarMangers.ForEach(x => x.isStartRehearsing = false);
|
||||
laserFireControlPlatformMangers.ForEach(x => x.isStartRehearsing = false);
|
||||
|
|
|
@ -118,7 +118,7 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public void StartTimer()
|
||||
{
|
||||
if (timerCoroutine == null)
|
||||
if (equipmentCommon.isPlayer && timerCoroutine == null)
|
||||
{
|
||||
timerCoroutine = StartCoroutine(Timer());
|
||||
isTimerRunning = true;
|
||||
|
@ -129,7 +129,7 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
|||
/// </summary>
|
||||
public void StopTimer()
|
||||
{
|
||||
if (timerCoroutine != null)
|
||||
if (equipmentCommon.isPlayer && timerCoroutine != null)
|
||||
{
|
||||
StopCoroutine(timerCoroutine);
|
||||
timerCoroutine = null;
|
||||
|
@ -192,7 +192,7 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
|||
UnmannedAerialVehicle unmannedAerialVehicle = col.GetComponent<UnmannedAerialVehicle>();
|
||||
if (unmannedAerialVehicle)
|
||||
{
|
||||
Debug.Log(col.name+"数据链通信频点...:" + unmannedAerialVehicle.dataLinkCommunicationFrequency);
|
||||
//Debug.Log(col.name+"数据链通信频点...:" + unmannedAerialVehicle.dataLinkCommunicationFrequency);
|
||||
if (unmannedAerialVehicle.dataLinkCommunicationFrequency == "" || InterferingFrequency == "") return;//无数据不执行
|
||||
if(unmannedAerialVehicle.dataLinkCommunicationFrequency== InterferingFrequency)
|
||||
{
|
||||
|
@ -204,4 +204,9 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
OnActivationChanged -= OnActivationChangedHandler;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using System.Linq;
|
||||
using AdamSync;
|
||||
|
||||
/// <summary>
|
||||
/// 无人机
|
||||
|
@ -13,6 +14,10 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
/// 所属无人机蜂群
|
||||
/// </summary>
|
||||
public UnmannedAerialVehicleManage unmannedAerialVehicleManage;
|
||||
/// <summary>
|
||||
/// 序列编号
|
||||
/// </summary>
|
||||
public string serialNumber = "";
|
||||
|
||||
#region 无人机数据
|
||||
/// <summary>
|
||||
|
@ -59,7 +64,7 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
/// <summary>
|
||||
/// 是否正在攻击目标
|
||||
/// </summary>
|
||||
private bool isEngagedTarget = false;
|
||||
public bool isEngagedTarget = false;
|
||||
/// <summary>
|
||||
/// 爆炸预制体
|
||||
/// </summary>
|
||||
|
@ -68,13 +73,13 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (unmannedAerialVehicleManage && unmannedAerialVehicleManage.isStartRehearsing)
|
||||
if (unmannedAerialVehicleManage && unmannedAerialVehicleManage.equipmentCommon.isPlayer && unmannedAerialVehicleManage.isStartRehearsing)
|
||||
{
|
||||
switch (unmannedAerialVehicleManage.pattern)
|
||||
{
|
||||
|
@ -95,13 +100,15 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
/// </summary>
|
||||
public void AttackATarget()
|
||||
{
|
||||
|
||||
if (!isEngagedTarget)
|
||||
{
|
||||
List<Collider> colliders = Physics.OverlapSphere(transform.position, detectionRadius).ToList(); // 检索范围内的所有碰撞体
|
||||
List<Collider> colliders1 = colliders.FindAll(x => x.transform.tag == "AttackTarget");
|
||||
if (colliders1.Count>0)
|
||||
if (colliders1.Count > 0)
|
||||
{
|
||||
int _number= Random.Range(0, colliders1.Count-1);
|
||||
colliders1.ForEach(x => Debug.Log(x.transform.name));
|
||||
int _number = Random.Range(0, colliders1.Count - 1);
|
||||
isEngagedTarget = true;
|
||||
Debug.Log(colliders1[_number].transform.name);
|
||||
AttAck(colliders1[_number].transform);
|
||||
|
@ -116,9 +123,11 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
{
|
||||
Debug.Log("开始攻击目标..:" + target.name);
|
||||
Vector3 _v3 = target.position;
|
||||
transform.DOLookAt(_v3, 0.1f).OnComplete(() => {
|
||||
transform.DOLookAt(_v3, 0.1f).OnComplete(() =>
|
||||
{
|
||||
float distance = Vector3.Distance(transform.position, target.position);
|
||||
transform.DOMove(target.position, distance / FireSpeed).SetEase(Ease.Linear).OnComplete(()=> {
|
||||
transform.DOMove(target.position, distance / FireSpeed).SetEase(Ease.Linear).OnComplete(() =>
|
||||
{
|
||||
if (!target)
|
||||
{
|
||||
BeAssaulted("没有攻击到目标");
|
||||
|
@ -130,77 +139,152 @@ public class UnmannedAerialVehicle : MonoBehaviour
|
|||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (other.tag == "AttackTarget")
|
||||
if (unmannedAerialVehicleManage.equipmentCommon.isPlayer && other.tag == "AttackTarget")
|
||||
{
|
||||
AddBao(other.transform);
|
||||
// 销毁objectToDestroy对象
|
||||
BeAssaulted("攻击到目标");
|
||||
GameObject Bao = Instantiate(explodePrefab, other.transform);
|
||||
Bao.transform.localPosition = Vector3.zero;
|
||||
Bao.transform.SetParent(null);
|
||||
Bao.SetActive(true);
|
||||
Destroy(other.gameObject);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//[]
|
||||
//public void AddBeAssaulted()
|
||||
//{
|
||||
// BeAssaulted("无线电干扰");
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 被攻击
|
||||
/// </summary>
|
||||
/// <param name="type"></param>
|
||||
public void BeAssaulted(string type)
|
||||
{
|
||||
switch (type) {
|
||||
switch (type)
|
||||
{
|
||||
case "激光打击":
|
||||
GameObject Bao1 = Instantiate(explodePrefab, transform);
|
||||
Bao1.transform.localPosition = Vector3.zero;
|
||||
Bao1.transform.SetParent(null);
|
||||
Bao1.SetActive(true);
|
||||
DistroyThis();
|
||||
Debug.Log(transform.name+"被激光打击销毁了");
|
||||
AddBao(true);
|
||||
//Debug.Log(transform.name+"被激光打击销毁了");
|
||||
break;
|
||||
case "无线电干扰":
|
||||
Vector3 _pos = transform.position - new Vector3(0, 30, 0);
|
||||
transform.LookAt(_pos);
|
||||
transform.DOMove(_pos, 1).OnComplete(() => {
|
||||
GameObject Bao2 = Instantiate(explodePrefab, transform);
|
||||
Bao2.transform.localPosition = Vector3.zero;
|
||||
Bao2.transform.SetParent(null);
|
||||
Bao2.SetActive(true);
|
||||
DistroyThis();
|
||||
transform.DOMove(_pos, 1).OnComplete(() =>
|
||||
{
|
||||
AddBao(true);
|
||||
});
|
||||
Debug.Log(transform.name + "无人机被无线电干扰销毁了");
|
||||
//Debug.Log(transform.name + "无人机被无线电干扰销毁了");
|
||||
break;
|
||||
case "攻击到目标":
|
||||
GameObject Bao3 = Instantiate(explodePrefab, transform);
|
||||
Bao3.transform.localPosition = Vector3.zero;
|
||||
Bao3.transform.SetParent(null);
|
||||
Bao3.SetActive(true);
|
||||
DistroyThis();
|
||||
Debug.Log(transform.name + "无人机自杀式攻击销毁了");
|
||||
AddBao(true);
|
||||
//Debug.Log(transform.name + "无人机自杀式攻击销毁了");
|
||||
break;
|
||||
case "没有攻击到目标":
|
||||
GameObject Bao4 = Instantiate(explodePrefab, transform);
|
||||
Bao4.transform.localPosition = Vector3.zero;
|
||||
Bao4.transform.SetParent(null);
|
||||
Bao4.SetActive(true);
|
||||
DistroyThis();
|
||||
Debug.Log(transform.name + "无人机自杀式销毁了");
|
||||
AddBao(true);
|
||||
//Debug.Log(transform.name + "无人机自杀式没有攻击到目标撞击地面销毁了");
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DistroyThis()
|
||||
/// <summary>
|
||||
/// 销毁单体无人机
|
||||
/// </summary>
|
||||
public void AddBao(bool isPassMessage)
|
||||
{
|
||||
|
||||
if (isPassMessage)
|
||||
{
|
||||
string nowData = GetSyncDis();
|
||||
Debug.Log(nowData);
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
}
|
||||
GameObject Bao = Instantiate(explodePrefab, transform);
|
||||
Bao.transform.localPosition = Vector3.zero;
|
||||
Bao.transform.SetParent(null);
|
||||
Bao.SetActive(true);
|
||||
|
||||
Destroy(gameObject);
|
||||
// 获取组件
|
||||
//Component component = gameObject.GetComponent<BoxCollider>();
|
||||
//// 移除组件
|
||||
//if (component != null)
|
||||
//{
|
||||
// Destroy(component);
|
||||
// transform.localScale = Vector3.zero;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <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));
|
||||
GameObject Bao = Instantiate(explodePrefab, _transform);
|
||||
Bao.transform.localPosition = Vector3.zero;
|
||||
Bao.transform.SetParent(null);
|
||||
Bao.SetActive(true);
|
||||
Destroy(_transform.gameObject);
|
||||
}
|
||||
|
||||
|
||||
private void OnBecameInvisible()
|
||||
{
|
||||
Debug.Log("测试");
|
||||
}
|
||||
|
||||
void OnDestroy()
|
||||
{
|
||||
|
||||
transform.DOKill();
|
||||
//
|
||||
}
|
||||
//位置实时传送
|
||||
private string latestData = "";
|
||||
|
||||
public void AddSendMsg()
|
||||
{
|
||||
latestData = GetSyncData();
|
||||
InvokeRepeating("SendMsg", 0, 0.01f);
|
||||
}
|
||||
public void SendMsg()
|
||||
{
|
||||
var nowData = GetSyncData();
|
||||
if (!nowData.Equals(latestData))
|
||||
{
|
||||
latestData = nowData;
|
||||
Debug.Log(latestData);
|
||||
_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 单个无人机位置传递
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetSyncData()
|
||||
{
|
||||
return string.Format("{0},{1},{2},{3},{4},{5},{6},{7},{8}", "SingleDronePosition", unmannedAerialVehicleManage.equipmentCommon.deviceID, serialNumber,
|
||||
transform.localPosition.x, transform.localPosition.y, transform.localPosition.z,
|
||||
transform.localEulerAngles.x, transform.localEulerAngles.y, transform.localEulerAngles.z);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单个无人机被销毁
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
protected string GetSyncDis()
|
||||
{
|
||||
return string.Format("{0},{1},{2}", "DroneWasDestroyed", unmannedAerialVehicleManage.equipmentCommon.deviceID, serialNumber);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -46,18 +46,6 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
|
||||
public EquipmentCommon equipmentCommon;
|
||||
|
||||
/// <summary>
|
||||
/// 测试用
|
||||
/// </summary>
|
||||
public string msg;
|
||||
/// <summary>
|
||||
/// 测试接受数据
|
||||
/// </summary>
|
||||
private List<Weaponitem> weaponitems;
|
||||
/// <summary>
|
||||
/// 设备通用脚本
|
||||
/// </summary>
|
||||
private Weaponitemone weaponitemones;
|
||||
|
||||
/// <summary>
|
||||
/// 无人机预制体
|
||||
|
@ -130,10 +118,12 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
for (int i = 0; i < unmannedAerialVehicles.Count; i++)
|
||||
{
|
||||
unmannedAerialVehicles[i].serialNumber = (i + 1).ToString();
|
||||
}
|
||||
unmannedAerialVehicleManages.Add(this);
|
||||
equipmentCommon = GetComponent<EquipmentCommon>();
|
||||
//weaponitemones = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(msg);
|
||||
//FillInTheData(weaponitemones);//测试写入
|
||||
Formation(1);//默认阵型
|
||||
// 订阅布尔值变化事件
|
||||
OnActivationChanged += OnActivationChangedHandler;
|
||||
|
@ -150,6 +140,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
StartMoveObjectAlongPath();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -257,15 +249,18 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
yield return new WaitForSeconds(0.1f);
|
||||
for (int i = 0; i < unmannedAerialVehicles.Count; i++)
|
||||
{
|
||||
unmannedAerialVehicles[i].batteryLife = batteryLife;
|
||||
unmannedAerialVehicles[i].classificationWindResistance = classificationWindResistance;
|
||||
unmannedAerialVehicles[i].maximumFlyingSpeed = maximumFlyingSpeed;
|
||||
unmannedAerialVehicles[i].RCS = RCS;
|
||||
unmannedAerialVehicles[i].satellitePositioningFrequency = satellitePositioningFrequency;
|
||||
unmannedAerialVehicles[i].dataLinkCommunicationFrequency = dataLinkCommunicationFrequency;
|
||||
unmannedAerialVehicles[i].electronicReconnaissanceCapability = electronicReconnaissanceCapability;
|
||||
unmannedAerialVehicles[i].opticalReconnaissanceCapability = opticalReconnaissanceCapability;
|
||||
unmannedAerialVehicles[i].unmannedAerialVehicleManage = this;
|
||||
if (unmannedAerialVehicles[i] != null)
|
||||
{
|
||||
unmannedAerialVehicles[i].batteryLife = batteryLife;
|
||||
unmannedAerialVehicles[i].classificationWindResistance = classificationWindResistance;
|
||||
unmannedAerialVehicles[i].maximumFlyingSpeed = maximumFlyingSpeed;
|
||||
unmannedAerialVehicles[i].RCS = RCS;
|
||||
unmannedAerialVehicles[i].satellitePositioningFrequency = satellitePositioningFrequency;
|
||||
unmannedAerialVehicles[i].dataLinkCommunicationFrequency = dataLinkCommunicationFrequency;
|
||||
unmannedAerialVehicles[i].electronicReconnaissanceCapability = electronicReconnaissanceCapability;
|
||||
unmannedAerialVehicles[i].opticalReconnaissanceCapability = opticalReconnaissanceCapability;
|
||||
unmannedAerialVehicles[i].unmannedAerialVehicleManage = this;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
@ -316,7 +311,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
if (currentCount < totalObjects)
|
||||
{
|
||||
Vector3 _vector3 = startPos + new Vector3(j * 2, 0, 0);
|
||||
unmannedAerialVehicles[currentCount].transform.localPosition = _vector3;
|
||||
if (unmannedAerialVehicles[currentCount])
|
||||
unmannedAerialVehicles[currentCount].transform.localPosition = _vector3;
|
||||
currentCount++;
|
||||
}
|
||||
else
|
||||
|
@ -350,7 +346,8 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
if (currentCount < totalObjects)
|
||||
{
|
||||
Vector3 position = new Vector3(col * offsetX, 0, -row * offsetZ);
|
||||
unmannedAerialVehicles[currentCount].transform.localPosition = position;
|
||||
if (unmannedAerialVehicles[currentCount])
|
||||
unmannedAerialVehicles[currentCount].transform.localPosition = position;
|
||||
currentCount++;
|
||||
}
|
||||
}
|
||||
|
@ -431,7 +428,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
|
||||
IEnumerator MoveObjectAlongPath(Vector3 positions) // 协程:按路线移动物体
|
||||
{
|
||||
Vector3 targetPosition = positions + new Vector3(0, 10, 0);// 目标位置为当前顶点坐标
|
||||
Vector3 targetPosition = new Vector3(positions.x, 10, positions.z);// 目标位置为当前顶点坐标
|
||||
float _distance = Vector3.Distance(transform.position, targetPosition);
|
||||
float _time = _distance / FireSpeed;
|
||||
transform.LookAt(endPosition);
|
||||
|
@ -439,6 +436,11 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
|
|||
yield return new WaitForSeconds(_time); // 等待一帧时间
|
||||
isMove = true;
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
OnActivationChanged -= OnActivationChangedHandler;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public enum Pattern
|
||||
|
|
Loading…
Reference in New Issue