This commit is contained in:
账号名 2024-01-19 09:45:05 +08:00
commit 935442e7d1
9 changed files with 202 additions and 99 deletions

View File

@ -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}

View File

@ -0,0 +1,20 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 电子侦察无人机
/// </summary>
public class ElectronicReconnaissanceDrone : UAVBase
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddc1db5913d56ec47ac93953631c9a82
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,27 @@
using PData;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 无人机基类
/// </summary>
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));
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1acac6355624a274ea601506c5f2a3ff
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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<GameManager>
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));
}

View File

@ -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<UnmannedAerialVehicleManage>().wrjModel).ToString());
if (gameObject.GetComponent<UnmannedAerialVehicleManage>())
replaceInfoDic.Add("r2", ((int)gameObject.GetComponent<UnmannedAerialVehicleManage>().wrjModel).ToString());
StartCoroutine(AsyncWebReq.PostData2(Url_AddDeviceAndGetDeviceId, replaceInfoDic, ResultsInfo =>
{
ReturnDeviceID returnID = JsonConvert.DeserializeObject<ReturnDeviceID>(ResultsInfo);

View File

@ -120,7 +120,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// <summary>
/// 十字准星架视角
/// </summary>
public Camera Camera;
public Camera camera;
/// <summary>
/// 十字准星架视角UI显示
/// </summary>
@ -137,12 +137,24 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 点击空白处碰撞器
/// </summary>
public GameObject Detection;
/// <summary>
/// 摄像机视角开关
/// </summary>
public bool isplaser = true;
/// <summary>
/// 激光火炮打击时间
/// </summary>
public static float lasertime;
public float lasertimes;
/// <summary>
/// 判断物体是否在相机里面
/// </summary>
public bool ispcamera;
void Start()
{
equipmentCommon = GetComponent<EquipmentCommon>();
laserFireControlPlatformMangers.Add(this);
Camera = transform.GetChild(1).GetComponent<Camera>();
camera = transform.GetChild(1).GetComponent<Camera>();
//weaponitemones = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(msg);
//FillInTheData(weaponitemones);//测试写入
// 订阅布尔值变化事件
@ -176,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())
@ -184,9 +200,10 @@ 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 +211,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 +220,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
}
}
}
}
}
}
/// <summary>
/// 开启暂停激光发射武器
@ -254,16 +271,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 +303,8 @@ public class LaserFireControlPlatformManger : MonoBehaviour
{
case "储能间隔时间:":
StorageIntervalTime = weaponitemone[i].para_value;
timepiece = float.Parse(StorageIntervalTime);
lasertime = float.Parse(StorageIntervalTime);
lasertimes = float.Parse(StorageIntervalTime);
break;
case "毁伤目标累积作用时间:":
CumulativeActionTimeOfDamageTarget = weaponitemone[i].para_value;
@ -306,10 +328,9 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// </summary>
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 +349,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 +379,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 +392,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 +409,47 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 十字准星架视角
/// </summary>
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();
});
}
}
/// <summary>
/// 激光显示
/// </summary>
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 +462,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);
}
/// <summary>
@ -429,46 +485,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
StartCoroutine(LaserExtinction());
}
}
/// <summary>
/// 激光打击位置未打中
/// </summary>
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();
}
}
/// <summary>
/// 十字准星架为打中视角
/// </summary>
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);
}
}
/// <summary>
/// 激光显示为打中
/// </summary>
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());
}
/// <summary>
/// 销毁单体无人机
@ -519,7 +536,7 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// 单个无人机被销毁
/// </summary>
/// <returns></returns>
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 +556,11 @@ public class LaserFireControlPlatformManger : MonoBehaviour
OuterLaserlineRenderer.SetPosition(0, LaserPoint.transform.position); // 设置线段起点为物体位置
OuterLaserlineRenderer.SetPosition(1, LaserPoint.transform.position); // 设置线段终点为目标点
}
isLasings = false;
if (lasertimes!=0)
{
lasertime = lasertimes;
}
isLasing = false;
}
#endregion
@ -551,10 +572,10 @@ public class LaserFireControlPlatformManger : MonoBehaviour
/// <returns></returns>
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);
}

View File

@ -118,6 +118,10 @@ public class RadarManger : MonoBehaviour
/// 渲染小地图摄像机
/// </summary>
public Camera Mincamera;
/// <summary>
/// 计时火炮蓄能时间
/// </summary>
public float radartime=0;
void Start()
{
Mincamera = GameObject.Find("Minimap Camera").GetComponent<Camera>();
@ -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,25 @@ public class RadarManger : MonoBehaviour
UnmannedAerialVehicle unmannedAerialVehicle = colliders2[i].GetComponent<UnmannedAerialVehicle>();
if (unmannedAerialVehicle)
{
LaserFireControlPlatformManger laserFireControlPlatformManger = LaserFireControlPlatformManger.laserFireControlPlatformMangers.Find(x => (x != null && x.isLasing == false));
if (laserFireControlPlatformManger)
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));
if (laserFireControlPlatformManger)
{
laserFireControlPlatformManger.isLasing = true;
//Debug.Log(laserFireControlPlatformManger.transform.name + "攻击无人机: " + unmannedAerialVehicle.transform.name);
laserFireControlPlatformManger.targetPoint = unmannedAerialVehicle.transform;
laserFireControlPlatformManger.Crosshair();
laserFireControlPlatformManger.Lasing();
radartime = 0;
}
}
number++;
}
}
}
}