From cddd86a5adb5222e94604f6f0f46241a545064d4 Mon Sep 17 00:00:00 2001
From: YangHua <1475658476@qq.com>
Date: Thu, 18 Jan 2024 15:50:23 +0800
Subject: [PATCH 1/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A9=B1=E7=A6=BB?=
=?UTF-8?q?=E5=92=8C=E8=BF=AB=E9=99=8D=E9=80=BB=E8=BE=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ElectronicReconnaissanceDrone.cs | 20 +++
.../ElectronicReconnaissanceDrone.cs.meta | 11 ++
.../Zion/Scripts/Adam/Components/UAVBase.cs | 27 ++++
.../Scripts/Adam/Components/UAVBase.cs.meta | 11 ++
Assets/Zion/Scripts/Adam/GameManager.cs | 17 +--
.../TerrestrialRadioInterferenceManger.cs | 86 +-----------
.../UAV/UnmannedAerialVehicleManage.cs | 131 +++++++++++++++++-
7 files changed, 210 insertions(+), 93 deletions(-)
create mode 100644 Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs
create mode 100644 Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs.meta
create mode 100644 Assets/Zion/Scripts/Adam/Components/UAVBase.cs
create mode 100644 Assets/Zion/Scripts/Adam/Components/UAVBase.cs.meta
diff --git a/Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs b/Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs
new file mode 100644
index 00000000..1fd5fd96
--- /dev/null
+++ b/Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs
@@ -0,0 +1,20 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+///
+/// 电子侦察无人机
+///
+public class ElectronicReconnaissanceDrone : UAVBase
+{
+ // Start is called before the first frame update
+ void Start()
+ {
+
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+}
diff --git a/Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs.meta b/Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs.meta
new file mode 100644
index 00000000..e749e8f8
--- /dev/null
+++ b/Assets/Zion/Scripts/Adam/Components/ElectronicReconnaissanceDrone.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ddc1db5913d56ec47ac93953631c9a82
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Zion/Scripts/Adam/Components/UAVBase.cs b/Assets/Zion/Scripts/Adam/Components/UAVBase.cs
new file mode 100644
index 00000000..03084082
--- /dev/null
+++ b/Assets/Zion/Scripts/Adam/Components/UAVBase.cs
@@ -0,0 +1,27 @@
+using PData;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+///
+/// 无人机基类
+///
+public class UAVBase : MonoBehaviour
+{
+ public void GetWeatherAttachUAV()
+ {
+
+ }
+ public void SetWeatherValue()
+ {
+ SenceInfo currentSceneInfo = new SenceInfo();
+ currentSceneInfo = UIBootstrap.Instance.currentSceneInfo.data;
+
+ //tenkokuModule.weather_RainAmt = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvRain));
+ //tenkokuModule.weather_SnowAmt = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvSnow));
+ //tenkokuModule.weather_WindAmt = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvWindSpeed));
+ //tenkokuModule.weather_WindDir = Mathf.Lerp(0f, 360f, float.Parse(currentSceneInfo.EnvWindDir));
+ //tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0f, 1f, 1 - (float.Parse(currentSceneInfo.EnvLight) / 10));
+ //tenkokuModule.weather_humidity = Mathf.Lerp(0f, 1f, 1 - (float.Parse(currentSceneInfo.EnvWu) / 100));
+ }
+}
diff --git a/Assets/Zion/Scripts/Adam/Components/UAVBase.cs.meta b/Assets/Zion/Scripts/Adam/Components/UAVBase.cs.meta
new file mode 100644
index 00000000..91a4131e
--- /dev/null
+++ b/Assets/Zion/Scripts/Adam/Components/UAVBase.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 1acac6355624a274ea601506c5f2a3ff
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Zion/Scripts/Adam/GameManager.cs b/Assets/Zion/Scripts/Adam/GameManager.cs
index a07ca385..58d555b0 100644
--- a/Assets/Zion/Scripts/Adam/GameManager.cs
+++ b/Assets/Zion/Scripts/Adam/GameManager.cs
@@ -1,5 +1,6 @@
using AdamSync;
using AdamThinkDevicesData;
+using PData;
using RDate;
using System;
using System.Collections;
@@ -419,14 +420,14 @@ public class GameManager : MonoSingleton
public void SetWeatherValue()
{
- tenkokuModule.weather_RainAmt = Mathf.Lerp(0f, 1f, float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvRain));
- tenkokuModule.weather_SnowAmt = Mathf.Lerp(0f, 1f, float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvSnow));
- tenkokuModule.weather_WindAmt = Mathf.Lerp(0f, 1f, float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvWindSpeed));
- tenkokuModule.weather_WindDir = Mathf.Lerp(0f, 360f, float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvWindDir));
- tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0f, 1f, 1 - (float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvLight) / 10));
- tenkokuModule.weather_humidity = Mathf.Lerp(0f, 1f, 1 - (float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvWu) / 100));
- Debug.LogError(tenkokuModule.weather_humidity);
- Debug.LogError(tenkokuModule.weather_OvercastAmt);
+ SenceInfo currentSceneInfo = new SenceInfo();
+ currentSceneInfo = UIBootstrap.Instance.currentSceneInfo.data;
+ tenkokuModule.weather_RainAmt = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvRain));
+ tenkokuModule.weather_SnowAmt = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvSnow));
+ tenkokuModule.weather_WindAmt = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvWindSpeed));
+ tenkokuModule.weather_WindDir = Mathf.Lerp(0f, 360f, float.Parse(currentSceneInfo.EnvWindDir));
+ tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0f, 1f, 1 - (float.Parse(currentSceneInfo.EnvLight) / 10));
+ tenkokuModule.weather_humidity = Mathf.Lerp(0f, 1f, 1 - (float.Parse(currentSceneInfo.EnvWu) / 100));
}
diff --git a/Assets/Zion/Scripts/ModelFunction/TerrestrialRadioInterference/TerrestrialRadioInterferenceManger.cs b/Assets/Zion/Scripts/ModelFunction/TerrestrialRadioInterference/TerrestrialRadioInterferenceManger.cs
index 26e9e95a..121fbb8a 100644
--- a/Assets/Zion/Scripts/ModelFunction/TerrestrialRadioInterference/TerrestrialRadioInterferenceManger.cs
+++ b/Assets/Zion/Scripts/ModelFunction/TerrestrialRadioInterference/TerrestrialRadioInterferenceManger.cs
@@ -150,7 +150,7 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
}
}
-
+
#region 启动暂停
///
/// 导条变化调用
@@ -305,91 +305,13 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
{
if (colliders[i].transform.tag == "WRJ")
{
- UnmannedAerialVehicle unmannedAerialVehicle = null;
- if (colliders[i].GetComponent())
- {
- unmannedAerialVehicle = colliders[i].GetComponent();
- }
UnmannedAerialVehicleManage unmannedAerialVehicleManage = null;
if (colliders[i].GetComponent())
{
unmannedAerialVehicleManage = colliders[i].GetComponent();
}
- if (TransmittedPower == "10~30W" || TransmittedPower == "30~50W" && unmannedAerialVehicleManage != null)
- {
- Debug.LogError("发射功率进来了1");
- Debug.LogError(unmannedAerialVehicleManage.satellitePositioningFrequency);
- Debug.LogError(InterferingFrequency);
- if (unmannedAerialVehicleManage.satellitePositioningFrequency == InterferingFrequency && unmannedAerialVehicleManage != null)
- {
- Debug.LogError("相同频率进来了1");
- Debug.LogError(InterferenceMode);
- Debug.LogError(unmannedAerialVehicleManage != null);
-
- if (InterferenceMode == "驱离" && unmannedAerialVehicleManage != null)
- {
- Debug.LogError("驱离");
-
- unmannedAerialVehicleManage.transform.DOKill();
- unmannedAerialVehicleManage.transform.LookAt(new Vector3(-500, 160, 1600));
- unmannedAerialVehicleManage.transform.DOMove(new Vector3(-500, 160, 1600), 60);
-
- }
- else if (InterferenceMode == "迫降" && unmannedAerialVehicleManage != null)
- {
- Debug.LogError("迫降");
- unmannedAerialVehicleManage.transform.DOKill();
- //unmannedAerialVehicle.transform.DOKill();
- //Debug.LogError(unmannedAerialVehicle.name);
- RaycastHit hit;
- if (Physics.Raycast(unmannedAerialVehicleManage.transform.position, Vector3.down, out hit, Mathf.Infinity, ground))
- {
- if (hit.distance > 1f)
- {
- Debug.LogError(hit.distance);
-
- hit.point = new Vector3(hit.point.x, hit.point.y + 3, hit.point.z);
-
- unmannedAerialVehicleManage.transform.DOMove(hit.point, 6);
-
- }
- else
- {
- speed = 0;
- }
- }
- }
-
- }
- }
- if (TransmittedPower == "50~100W" && unmannedAerialVehicleManage != null)
- {
- Debug.LogError("功率进来了2");
- if (unmannedAerialVehicleManage.dataLinkCommunicationFrequency == InterferingFrequency && unmannedAerialVehicleManage != null)
- {
- Debug.LogError("频率进来了");
- if (unmannedAerialVehicleManage != null)
- {
- Vector3 one = unmannedAerialVehicleManage.transform.position - transform.position;
- float angue = Vector3.Angle(one, transform.forward);
- if (float.Parse(InterferenceAngle) >= angue)
- {
- //unmannedAerialVehicleManage.transform.DOKill();
- Debug.LogError("目标出现在范围内");
- Debug.LogError(unmannedAerialVehicleManage.maximumFlyingSpeed);
- unmannedAerialVehicleManage.maximumFlyingSpeed = (float.Parse(unmannedAerialVehicleManage.maximumFlyingSpeed) - 5).ToString();
- Debug.LogError(unmannedAerialVehicleManage.maximumFlyingSpeed);
- }
- else
- {
-
- Debug.LogError("目标没有出现在范围里面");
-
-
- }
- }
- }
- }
+ if (unmannedAerialVehicleManage != null)
+ unmannedAerialVehicleManage.CheckSatellitePositioningFrequency(this.transform, InterferenceMode, TransmittedPower, InterferingFrequency, InterferenceAngle, ground);
}
}
}
@@ -399,7 +321,7 @@ public class TerrestrialRadioInterferenceManger : MonoBehaviour
///
private void Angularrange()
{
- Collider[] collider = Physics.OverlapSphere(transform.position,300);
+ Collider[] collider = Physics.OverlapSphere(transform.position, 300);
for (int i = 0; i < collider.Length; i++)
{
if (collider[i].transform.tag == "WRJ")
diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
index 2ab43d6a..cc5973db 100644
--- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
+++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
@@ -8,6 +8,8 @@ using AdamSync;
using System.Linq;
using static InterfaceManager;
using Newtonsoft.Json;
+using PData;
+
public enum WRJModel
{
无人机,
@@ -98,6 +100,11 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
///
public bool isEngagedTarget = false;
+ ///
+ /// 光学无人机
+ ///
+ public Camera gxWRJCamera;
+
#region 无人机数据
///
/// 续航时间
@@ -178,7 +185,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
break;
}
-
+
}
var _unmannedAerialVehicle = unmannedAerialVehicles.FindAll(x => x != null && x.gameObject.activeSelf);
@@ -246,6 +253,22 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
}
+ public void SwitchWRJModel()
+ {
+ gxWRJCamera.gameObject.SetActive(false);
+ switch (wrjModel)
+ {
+ case WRJModel.光学无人机:
+ gxWRJCamera.gameObject.SetActive(true);
+ break;
+ case WRJModel.电子侦察无人机:
+ break;
+ case WRJModel.自杀式无人机:
+ break;
+ }
+ }
+
+
///
/// 攻击打击
///
@@ -264,7 +287,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
isEngagedTarget = true;
colliders1.ForEach(x => Debug.Log(x.transform.name));
int _number = UnityEngine.Random.Range(0, colliders1.Count - 1);
- List _unmannedAerialVehicles = unmannedAerialVehicles.FindAll(x => x != null&&x.gameObject.activeSelf);
+ List _unmannedAerialVehicles = unmannedAerialVehicles.FindAll(x => x != null && x.gameObject.activeSelf);
SendMsg(colliders1[_number].transform);
for (int i = 0; i < _unmannedAerialVehicles.Count; i++)
{
@@ -325,6 +348,9 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
// Debug.Log(msg);
// _ = SyncCreateRoom.SendMessageAsync(msg);
//}
+ SenceInfo currentSceneInfo = new SenceInfo();
+ currentSceneInfo = UIBootstrap.Instance.currentSceneInfo.data;
+ //int windSpeed = Mathf.Lerp(0f, 1f, float.Parse(currentSceneInfo.EnvWindSpeed));
for (int i = 0; i < weaponitemone.Count; i++)
{
switch (weaponitemone[i].para_name)
@@ -337,7 +363,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
break;
case "最大飞行速度:":
maximumFlyingSpeed = weaponitemone[i].para_value;
- FireSpeed = float.Parse(maximumFlyingSpeed);
+
break;
case "RCS:":
RCS = weaponitemone[i].para_value;
@@ -422,12 +448,107 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
default:
break;
}
+
+ ///根据风得速度改变无人机得速度
+ FireSpeed = float.Parse(maximumFlyingSpeed) / int.Parse(currentSceneInfo.EnvWindSpeed);
+ ///如果风速大于6级,无人机停止飞行
+ if (int.Parse(currentSceneInfo.EnvWindSpeed) > 6)
+ {
+ FireSpeed = 0;
+ }
+ CheckRSC();
if (i == (weaponitemone.Count - 1))
{
StartCoroutine(WeaponitemoneDataAddition());
}
}
}
+ ///
+ /// 雷达检测无人机身上得RSC
+ ///
+ public void CheckRSC()
+ {
+ float rcs = float.Parse(RCS);
+ if (rcs <= 0.5 && rcs >= 0.1)
+ {
+ StartCoroutine(ShowRadarTips(0.8f, 2));
+ }
+ else if (rcs >= 0.5f && rcs <= 1)
+ {
+ StartCoroutine(ShowRadarTips(0.4f, 1));
+ }
+ }
+ ///
+ /// 多少时间在对方雷达界面上显示红色标记
+ ///
+ ///
+ ///
+ ///
+ private IEnumerator ShowRadarTips(float minTime, float maxTime)
+ {
+ GameObject tips = transform.Find("Minimapwrj").gameObject;
+ while (true)
+ {
+ tips.gameObject.SetActive(false);
+ float time = UnityEngine.Random.Range(minTime, maxTime);
+ yield return new WaitForSeconds(time);
+ tips.gameObject.SetActive(true);
+ }
+ }
+
+ ///
+ /// 检测无线电频率
+ ///
+ /// 无线电数据
+ /// 驱离或者迫降
+ public void CheckSatellitePositioningFrequency(Transform target, string interferenceMode, string transmittedPower, string interferingFrequency, string interferenceAngle, LayerMask ground)
+ {
+ if (transmittedPower == "10~30W" || transmittedPower == "30~50W")
+ {
+ if (satellitePositioningFrequency == interferingFrequency)
+ {
+ if (interferenceMode == "驱离")
+ {
+ transform.DOKill();
+ transform.LookAt(new Vector3(-500, 160, 1600));
+ transform.DOMove(new Vector3(-500, 160, 1600), 60);
+
+ }
+ else if (interferenceMode == "迫降")
+ {
+ transform.DOKill();
+ RaycastHit hit;
+ if (Physics.Raycast(transform.position, Vector3.down, out hit, Mathf.Infinity, ground))
+ {
+ if (hit.distance > 1f)
+ {
+ hit.point = new Vector3(hit.point.x, hit.point.y + 3, hit.point.z);
+ transform.DOMove(hit.point, 6);
+
+ }
+ }
+ }
+
+ }
+ }
+ if (transmittedPower == "50~100W")
+ {
+ if (dataLinkCommunicationFrequency == interferingFrequency)
+ {
+ Vector3 one = transform.position - target.transform.position;
+ float angue = Vector3.Angle(one, target.transform.forward);
+ if (float.Parse(interferenceAngle) >= angue)
+ {
+ maximumFlyingSpeed = (float.Parse(maximumFlyingSpeed) - 5).ToString();
+ }
+
+ }
+ }
+ }
+
+
+
+
///
/// 单个无人机数据写入
@@ -455,6 +576,9 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
}
#endregion
+
+
+
#region 阵型编队
///
/// 阵型选择
@@ -694,6 +818,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
}
private void OnDestroy()
{
+ StopAllCoroutines();
Destroy(airRoute.gameObject);
OnActivationChanged -= OnActivationChangedHandler;
}
From f97495d7124bc6b5cd17559c24a911e572146fcd Mon Sep 17 00:00:00 2001
From: yulong <1838206582@qq.com>
Date: Thu, 18 Jan 2024 15:55:41 +0800
Subject: [PATCH 2/4] =?UTF-8?q?=E4=BF=AE=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Prefebs/Models/moder/激光火控平台.prefab | 2 +-
.../LaserFireControlPlatformManger.cs | 170 +++++++++---------
.../ModelFunction/Radar/RadarManger.cs | 30 +++-
3 files changed, 112 insertions(+), 90 deletions(-)
diff --git a/Assets/GameAssets/Prefebs/Models/moder/激光火控平台.prefab b/Assets/GameAssets/Prefebs/Models/moder/激光火控平台.prefab
index 028c9381..22cd2770 100644
--- a/Assets/GameAssets/Prefebs/Models/moder/激光火控平台.prefab
+++ b/Assets/GameAssets/Prefebs/Models/moder/激光火控平台.prefab
@@ -10104,7 +10104,7 @@ MonoBehaviour:
FireSpeed: 20
explodePrefab: {fileID: 1000013462590818, guid: ecdd96beb7f93494880c052dfccf9dc1,
type: 3}
- Camera: {fileID: 0}
+ camera: {fileID: 0}
RawImage: {fileID: 6102700022742998670, guid: b2cb817bb62743a4194cd9d89f07e27d,
type: 3}
crosshair: {fileID: 0}
diff --git a/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs b/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs
index 5459a2e9..b3a9f2b2 100644
--- a/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs
+++ b/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs
@@ -120,7 +120,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
///
/// 十字准星架视角
///
- public Camera Camera;
+ public Camera camera;
///
/// 十字准星架视角UI显示
///
@@ -137,12 +137,23 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 点击空白处碰撞器
///
public GameObject Detection;
-
+ ///
+ /// 摄像机视角开关
+ ///
+ public bool isplaser = true;
+ ///
+ /// 激光火炮打击时间
+ ///
+ public static float lasertime;
+ ///
+ /// 判断物体是否在相机里面
+ ///
+ public bool ispcamera;
void Start()
{
equipmentCommon = GetComponent();
laserFireControlPlatformMangers.Add(this);
- Camera = transform.GetChild(1).GetComponent();
+ camera = transform.GetChild(1).GetComponent();
//weaponitemones = Newtonsoft.Json.JsonConvert.DeserializeObject(msg);
//FillInTheData(weaponitemones);//测试写入
// 订阅布尔值变化事件
@@ -184,9 +195,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
// Front = true;
// }
//}
- if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId)!="0"&&Input.GetMouseButtonDown(0))
+ if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) != "0" && Input.GetMouseButtonDown(0))
{
- Ray ray=Camera.main.ScreenPointToRay(Input.mousePosition);
+ Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
@@ -194,7 +205,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
{
return;
}
- if (hit.transform.gameObject.tag == "AttackTarget"&&hit.transform.gameObject.name == "激光火控平台(Clone)")
+ if (hit.transform.gameObject.tag == "AttackTarget" && hit.transform.gameObject.name == "激光火控平台(Clone)")
{
Transform canvas = GameObject.Find("Canvas").transform;
if (canvas)
@@ -203,9 +214,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
}
}
}
-
+
}
- }
+ }
///
/// 开启暂停激光发射武器
@@ -254,16 +265,20 @@ public class LaserFireControlPlatformManger : MonoBehaviour
{
while (true)
{
- yield return new WaitForSeconds(timepiece);
- if (timepiece!=0)
+ yield return new WaitForSeconds(lasertime);
+ if (lasertime != 0)
{
- Laserattack();
+ //Laserattack();
}
}
}
void LateUpdate()
{
-
+ if (Receivingdistance > 0 && isplaser == true)
+ {
+ camera.farClipPlane = Receivingdistance;
+ isplaser = false;
+ }
}
@@ -282,7 +297,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
{
case "储能间隔时间:":
StorageIntervalTime = weaponitemone[i].para_value;
- timepiece = float.Parse(StorageIntervalTime);
+ lasertime = float.Parse(StorageIntervalTime);
break;
case "毁伤目标累积作用时间:":
CumulativeActionTimeOfDamageTarget = weaponitemone[i].para_value;
@@ -306,10 +321,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
///
public void Laserattack()
{
- if (Receivingdistance > 0 && targetPoint!=null)
+ if (Receivingdistance > 0 && targetPoint != null)
{
Collider[] colliders = Physics.OverlapSphere(transform.position, Receivingdistance);//检查是否在打击的范围内
- Debug.LogError("范围打击距离:" + Receivingdistance);
for (int i = 0; i < colliders.Length; i++)
{
if (colliders[i].gameObject.tag == "WRJ")
@@ -328,17 +342,17 @@ public class LaserFireControlPlatformManger : MonoBehaviour
{
Debug.LogError("角度没有问题进来了" + InterferenceAngle);
- if (Receivingposin==null)
+ if (Receivingposin == null)
{
//if (Random.value>0.5f)
//{
- Receivingposin = unmannedAerialVehicle.transform;
- Debug.LogError("接收无人机的位置" + Receivingposin.position);
- var nowData = GetSyncData();
- _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
- isLasings = true;
- CastRayAndRender();
- break;
+ Receivingposin = unmannedAerialVehicle.transform;
+ Debug.LogError("接收无人机的位置" + Receivingposin.position);
+ var nowData = GetSyncData();
+ _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
+ isLasings = true;
+ CastRayAndRender();
+ break;
//}
//else
//{
@@ -358,9 +372,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
}
}
- private string GetSyncData1()
+ private string GetSyncData1()
{
- return string.Format("{0},{1},{2},{3}" + equipmentCommon.deviceID, Receivingposin.position.x+3,Receivingposin.position.y+3,Receivingposin.position.z);
+ return string.Format("{0},{1},{2},{3}" + equipmentCommon.deviceID, Receivingposin.position.x + 3, Receivingposin.position.y + 3, Receivingposin.position.z);
}
@@ -371,11 +385,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
{
if (targetPoint != null)
{
- LaserModer.transform.DOLookAt(targetPoint.position, 1.5f).OnComplete(() =>
+ LaserModer.transform.DOLookAt(targetPoint.position,0.5f).OnComplete(() =>
{
- isLasing = false;
- //CastRayAndRender();
+
});
//var nowData = GetSyncData();
//_ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
@@ -389,11 +402,47 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 十字准星架视角
///
public void Crosshair()
- {
+ {
if (targetPoint != null)
{
- Camera.transform.DOLookAt(targetPoint.position, 1.5f).SetEase(Ease.Linear);
- //isLasing = false;
+ camera.transform.DOLookAt(targetPoint.position,0.5f).SetEase(Ease.Linear).OnComplete(() =>
+ {
+ Debug.LogError("看向进来了");
+ Launchanattack();
+ });
+ }
+
+ }
+ ///
+ /// 激光显示
+ ///
+ public void Launchanattack()
+ {
+ if (targetPoint != null)
+ {
+ Vector3 pos = camera.WorldToViewportPoint(targetPoint.position);
+ ispcamera = (pos.x > 0 && pos.x < 1 && pos.y > 0 && pos.y < 1 && pos.z > 0);
+ if (ispcamera)
+ {
+ Debug.LogError("出现在摄像机视角里面了");
+ Vector3 cector = targetPoint.position - transform.position;
+ float angle = Vector3.Angle(cector, transform.forward);
+ if (float.Parse(InterferenceAngle) > angle)
+ {
+ Debug.Log("角度合适进行打击");
+ var nowData = GetSyncData();
+ _ = SyncCreateRoom.SendMessageAsync(string.Format("send2room {0}", nowData));
+ CastRayAndRender();
+ }
+ else
+ {
+ Debug.LogError("超出了角度不进行攻击");
+ }
+ }
+ else
+ {
+ Debug.LogError("飞机不在摄像机范围内");
+ }
}
}
@@ -406,14 +455,14 @@ public class LaserFireControlPlatformManger : MonoBehaviour
if (InnerLaserlineRenderer)
{
InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
- InnerLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
+ InnerLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
}
if (OuterLaserlineRenderer)
{
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
- OuterLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
+ OuterLaserlineRenderer.SetPosition(1, targetPoint.position); // 设置线段终点为目标点
}
- StrikeDrone(Receivingposin);
+ StrikeDrone(targetPoint);
}
///
@@ -429,46 +478,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
StartCoroutine(LaserExtinction());
}
}
- ///
- /// 激光打击位置未打中
- ///
- public void Lasering()
- {
- if (targetPoint != null)
- {
- targetPoint.position = new Vector3(targetPoint.position.x + 5, targetPoint.position.y, transform.position.z);
- LaserModer.transform.DOLookAt(targetPoint.position, 0.5f);
- //CastRayAndRender1();
- }
- }
- ///
- /// 十字准星架为打中视角
- ///
- public void Crosshair1()
- {
- if (targetPoint != null)
- {
- targetPoint.position = new Vector3(targetPoint.position.x + 5, targetPoint.position.y, transform.position.z);
- Camera.transform.DOLookAt(targetPoint.position, 0.1f).SetEase(Ease.Linear);
- }
- }
- ///
- /// 激光显示为打中
- ///
- public void CastRayAndRender1()
- {
- if (InnerLaserlineRenderer)
- {
- InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
- InnerLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
- }
- if (OuterLaserlineRenderer)
- {
- InnerLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
- InnerLaserlineRenderer.SetPosition(1, Receivingposin.position); // 设置线段终点为目标点
- }
- StartCoroutine(LaserExtinction());
- }
+
///
/// 销毁单体无人机
@@ -519,7 +529,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 单个无人机被销毁
///
///
- protected string GetSyncDis(UnmannedAerialVehicle unmannedAerialVehicle)
+ protected string GetSyncDis(UnmannedAerialVehicle unmannedAerialVehicle)
{
return string.Format("{0},{1},{2}", "DroneWasDestroyed", unmannedAerialVehicle.unmannedAerialVehicleManage.equipmentCommon.deviceID, unmannedAerialVehicle.serialNumber);
}
@@ -539,7 +549,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
OuterLaserlineRenderer.SetPosition(1, LaserPoint.transform.position); // 设置线段终点为目标点
}
- isLasings = false;
+ isLasing = false;
}
#endregion
@@ -551,10 +561,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
///
protected string GetSyncData()
{
-
- Debug.Log("目标点位..:" + Receivingposin.position);
- return string.Format("{0},{1},{2},{3},{4}", "Lasing", equipmentCommon.deviceID, Receivingposin.position.x, Receivingposin.position.y, Receivingposin.position.z);
-
+
+ Debug.Log("目标点位..:" + targetPoint.position);
+ return string.Format("{0},{1},{2},{3},{4}", "Lasing", equipmentCommon.deviceID, targetPoint.position.x, targetPoint.position.y, targetPoint.position.z);
+
}
diff --git a/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs b/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs
index 0c7e45e5..d67be88a 100644
--- a/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs
+++ b/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs
@@ -118,6 +118,10 @@ public class RadarManger : MonoBehaviour
/// 渲染小地图摄像机
///
public Camera Mincamera;
+ ///
+ /// 计时火炮蓄能时间
+ ///
+ public float radartime;
void Start()
{
Mincamera = GameObject.Find("Minimap Camera").GetComponent();
@@ -163,7 +167,7 @@ public class RadarManger : MonoBehaviour
while (true)
{
//Debug.Log("Timer fired at: " + Time.time);
- yield return new WaitForSeconds(interval); // 等待一段时间后继续执行
+ yield return new WaitForSeconds(5); // 等待一段时间后继续执行
//RetrievalUAV();
}
}
@@ -186,9 +190,11 @@ public class RadarManger : MonoBehaviour
{
if (equipmentCommon.isPlayer && timerCoroutine != null)
{
+
StopCoroutine(timerCoroutine);
timerCoroutine = null;
isTimerRunning = false;
+
}
}
#endregion
@@ -299,20 +305,26 @@ public class RadarManger : MonoBehaviour
UnmannedAerialVehicle unmannedAerialVehicle = colliders2[i].GetComponent();
if (unmannedAerialVehicle)
{
- LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false));
- if (laserFireControlPlatformManger)
+ radartime += Time.deltaTime;
+ if (radartime>=LaserFireControlPlatformManger.lasertime)
{
- laserFireControlPlatformManger.isLasing=true;
- //Debug.Log(laserFireControlPlatformManger.transform.name + "攻击无人机: " + unmannedAerialVehicle.transform.name);
- laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
- laserFireControlPlatformManger.Crosshair();
- laserFireControlPlatformManger.Lasing();
+ Debug.Log("今来了");
+ LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false));
+ radartime = 0;
+ if (laserFireControlPlatformManger)
+ {
+ laserFireControlPlatformManger.isLasing = true;
+ //Debug.Log(laserFireControlPlatformManger.transform.name + "攻击无人机: " + unmannedAerialVehicle.transform.name);
+ laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
+ laserFireControlPlatformManger.Crosshair();
+ laserFireControlPlatformManger.Lasing();
+ }
}
number++;
}
}
-
+
}
}
From b5a888998ce9a11ec945aad20c43e882f29e8ede Mon Sep 17 00:00:00 2001
From: YangHua <1475658476@qq.com>
Date: Thu, 18 Jan 2024 16:50:37 +0800
Subject: [PATCH 3/4] re
---
Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs | 3 ++-
.../ModelFunction/UAV/UnmannedAerialVehicleManage.cs | 6 +++---
2 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs b/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs
index 83569447..abf4c5d5 100644
--- a/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs
+++ b/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs
@@ -133,7 +133,8 @@ public class EquipmentCommon : MonoBehaviour
replaceInfoDic.Add("device_name", equipmentCommon.equipmentType);
replaceInfoDic.Add("para_list", paraListJson);
replaceInfoDic.Add("r1", $"{transform.position.x},{transform.position.y},{transform.position.z},{transform.eulerAngles.x},{transform.eulerAngles.y},{transform.eulerAngles.z}");
- replaceInfoDic.Add("r2", ((int)gameObject.GetComponent().wrjModel).ToString());
+ if (gameObject.GetComponent())
+ replaceInfoDic.Add("r2", ((int)gameObject.GetComponent().wrjModel).ToString());
StartCoroutine(AsyncWebReq.PostData2(Url_AddDeviceAndGetDeviceId, replaceInfoDic, ResultsInfo =>
{
ReturnDeviceID returnID = JsonConvert.DeserializeObject(ResultsInfo);
diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
index cc5973db..c2a1e220 100644
--- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
+++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
@@ -450,9 +450,9 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
}
///根据风得速度改变无人机得速度
- FireSpeed = float.Parse(maximumFlyingSpeed) / int.Parse(currentSceneInfo.EnvWindSpeed);
- ///如果风速大于6级,无人机停止飞行
- if (int.Parse(currentSceneInfo.EnvWindSpeed) > 6)
+ FireSpeed = float.Parse(maximumFlyingSpeed) / float.Parse(currentSceneInfo.EnvWindSpeed);
+ /////如果风速大于6级,无人机停止飞行
+ if (float.Parse(currentSceneInfo.EnvWindSpeed) * 10 > 6)
{
FireSpeed = 0;
}
From d9113871404bb4bff4f329cd38f8b50ece56afcc Mon Sep 17 00:00:00 2001
From: yulong <1838206582@qq.com>
Date: Thu, 18 Jan 2024 16:52:22 +0800
Subject: [PATCH 4/4] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Zion/Scripts/ModelFunction/EquipmentCommon.cs | 3 ++-
.../LaserFireControlPlatformManger.cs | 11 +++++++++++
.../Scripts/ModelFunction/Radar/RadarManger.cs | 9 ++++-----
.../UAV/UnmannedAerialVehicleManage.cs | 14 +++++++-------
4 files changed, 24 insertions(+), 13 deletions(-)
diff --git a/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs b/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs
index 83569447..abf4c5d5 100644
--- a/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs
+++ b/Assets/Zion/Scripts/ModelFunction/EquipmentCommon.cs
@@ -133,7 +133,8 @@ public class EquipmentCommon : MonoBehaviour
replaceInfoDic.Add("device_name", equipmentCommon.equipmentType);
replaceInfoDic.Add("para_list", paraListJson);
replaceInfoDic.Add("r1", $"{transform.position.x},{transform.position.y},{transform.position.z},{transform.eulerAngles.x},{transform.eulerAngles.y},{transform.eulerAngles.z}");
- replaceInfoDic.Add("r2", ((int)gameObject.GetComponent().wrjModel).ToString());
+ if (gameObject.GetComponent())
+ replaceInfoDic.Add("r2", ((int)gameObject.GetComponent().wrjModel).ToString());
StartCoroutine(AsyncWebReq.PostData2(Url_AddDeviceAndGetDeviceId, replaceInfoDic, ResultsInfo =>
{
ReturnDeviceID returnID = JsonConvert.DeserializeObject(ResultsInfo);
diff --git a/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs b/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs
index b3a9f2b2..6cfafd6c 100644
--- a/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs
+++ b/Assets/Zion/Scripts/ModelFunction/LaserFireControlPlatform/LaserFireControlPlatformManger.cs
@@ -145,6 +145,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 激光火炮打击时间
///
public static float lasertime;
+ public float lasertimes;
///
/// 判断物体是否在相机里面
///
@@ -187,6 +188,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
void Update()
{
+ if (lasertime>0)
+ {
+ lasertime -= Time.deltaTime;
+ }
//if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) != "0"&&Input.GetMouseButtonDown(0))
//{
// if (!EventSystem.current.IsPointerOverGameObject())
@@ -195,6 +200,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
// Front = true;
// }
//}
+
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) != "0" && Input.GetMouseButtonDown(0))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
@@ -298,6 +304,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
case "储能间隔时间:":
StorageIntervalTime = weaponitemone[i].para_value;
lasertime = float.Parse(StorageIntervalTime);
+ lasertimes = float.Parse(StorageIntervalTime);
break;
case "毁伤目标累积作用时间:":
CumulativeActionTimeOfDamageTarget = weaponitemone[i].para_value;
@@ -549,6 +556,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
OuterLaserlineRenderer.SetPosition(1, LaserPoint.transform.position); // 设置线段终点为目标点
}
+ if (lasertimes!=0)
+ {
+ lasertime = lasertimes;
+ }
isLasing = false;
}
diff --git a/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs b/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs
index d67be88a..11240118 100644
--- a/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs
+++ b/Assets/Zion/Scripts/ModelFunction/Radar/RadarManger.cs
@@ -121,7 +121,7 @@ public class RadarManger : MonoBehaviour
///
/// 计时火炮蓄能时间
///
- public float radartime;
+ public float radartime=0;
void Start()
{
Mincamera = GameObject.Find("Minimap Camera").GetComponent();
@@ -305,19 +305,18 @@ public class RadarManger : MonoBehaviour
UnmannedAerialVehicle unmannedAerialVehicle = colliders2[i].GetComponent();
if (unmannedAerialVehicle)
{
- radartime += Time.deltaTime;
- if (radartime>=LaserFireControlPlatformManger.lasertime)
+ if (radartime == LaserFireControlPlatformManger.lasertime)
{
Debug.Log("今来了");
LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false));
- radartime = 0;
- if (laserFireControlPlatformManger)
+ if (laserFireControlPlatformManger)
{
laserFireControlPlatformManger.isLasing = true;
//Debug.Log(laserFireControlPlatformManger.transform.name + "攻击无人机: " + unmannedAerialVehicle.transform.name);
laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
laserFireControlPlatformManger.Crosshair();
laserFireControlPlatformManger.Lasing();
+ radartime = 0;
}
}
number++;
diff --git a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
index cc5973db..4ca6de27 100644
--- a/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
+++ b/Assets/Zion/Scripts/ModelFunction/UAV/UnmannedAerialVehicleManage.cs
@@ -449,13 +449,13 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
break;
}
- ///根据风得速度改变无人机得速度
- FireSpeed = float.Parse(maximumFlyingSpeed) / int.Parse(currentSceneInfo.EnvWindSpeed);
- ///如果风速大于6级,无人机停止飞行
- if (int.Parse(currentSceneInfo.EnvWindSpeed) > 6)
- {
- FireSpeed = 0;
- }
+ /////根据风得速度改变无人机得速度
+ //FireSpeed = float.Parse(maximumFlyingSpeed) / int.Parse(currentSceneInfo.EnvWindSpeed);
+ /////如果风速大于6级,无人机停止飞行
+ //if (int.Parse(currentSceneInfo.EnvWindSpeed) > 6)
+ //{
+ // FireSpeed = 0;
+ //}
CheckRSC();
if (i == (weaponitemone.Count - 1))
{