Compare commits

...

3 Commits

Author SHA1 Message Date
YangHua 618b5cf5d5 融合 2024-01-17 16:09:43 +08:00
YangHua 72f846932b 212 2024-01-17 16:08:56 +08:00
YangHua de255738a9 修改无人机属性 2024-01-17 16:06:45 +08:00
14 changed files with 103 additions and 80 deletions

View File

@ -310,6 +310,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: d7c8a5e37f63c8e419e73f2c1b2ad41e, type: 3}
m_Name:
m_EditorClassIdentifier:
wrjModel: 0
pattern: 0
interval: 5
equipmentCommon: {fileID: -7238547075891962512}

View File

@ -182,6 +182,7 @@ MonoBehaviour:
deviceID:
isPlayer: 0
isThinck: 0
wrjModel: 0
--- !u!1 &3625114603613546360
GameObject:
m_ObjectHideFlags: 0

View File

@ -1 +1 @@
192.168.107.15:48888
127.0.0.1:48888

View File

@ -1 +1 @@
192.168.107.15
127.0.0.1

View File

@ -1860,15 +1860,15 @@ public class Scenariopage : MonoBehaviour
}
properties.Clear();//清空链表
}
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)//判断单例生成预设体
for (int i = 0; i < DragManager.Instance.devices.Count; i++)//判断单例生成预设体
{
int index = i;
if (DragManager.Instance.deviceimages[i] != null)
if (DragManager.Instance.devices[i] != null)
{
Propertypanl pro = Instantiate(propertypanl, Panel_making);//生成预设体对象
pro.Property(DragManager.Instance.deviceimages[i].name.Replace("(Clone)", ""), () =>
pro.Property(DragManager.Instance.devices[i].name.Replace("(Clone)", ""), () =>
{
Destroy(DragManager.Instance.deviceimages[index].gameObject);//删除
Destroy(DragManager.Instance.devices[index].gameObject);//删除
Destroy(pro.gameObject);//删除
});
properties.Add(pro);
@ -1891,15 +1891,15 @@ public class Scenariopage : MonoBehaviour
//想定文件下的保存按钮
save_btn.onClick.AddListener(() =>
{
if (DragManager.Instance.deviceimages.Count > 0)//判断场景的模型是否为空
if (DragManager.Instance.devices.Count > 0)//判断场景的模型是否为空
{
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
{
if (DragManager.Instance.deviceimages[i] != null)//如果链表有模型就进入
if (DragManager.Instance.devices[i] != null)//如果链表有模型就进入
{
DragManager.Instance.deviceimages[i].GetComponent<Modeldata>().SetPos();//初始化获取模型对应位置的值
DragManager.Instance.Addobj1(DragManager.Instance.deviceimages[i]);//就把对应的模型加到链表类里面
DragManager.Instance.devices[i].GetComponent<Modeldata>().SetPos();//初始化获取模型对应位置的值
DragManager.Instance.Addobj1(DragManager.Instance.devices[i]);//就把对应的模型加到链表类里面
}
}
}
@ -1907,16 +1907,16 @@ public class Scenariopage : MonoBehaviour
{
Passbyvalue();//把场景中天气插件的值传给接口
}
if (DragManager.Instance.deviceimages.Count > 0)//判断模型列表个数是否大于零
if (DragManager.Instance.devices.Count > 0)//判断模型列表个数是否大于零
{
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
{
if (DragManager.Instance.deviceimages[i] != null)//如果链表里有一个物体就进去
if (DragManager.Instance.devices[i] != null)//如果链表里有一个物体就进去
{
Destroy(DragManager.Instance.deviceimages[i].gameObject);//删除链表有的物体
Destroy(DragManager.Instance.devices[i].gameObject);//删除链表有的物体
}
}
DragManager.Instance.deviceimages.Clear();//清空链表
DragManager.Instance.devices.Clear();//清空链表
}
if (DragManager.Instance.modellist.Count > 0)
{

View File

@ -219,8 +219,8 @@ GameObject:
serializedVersion: 6
m_Component:
- component: {fileID: 2132962759}
- component: {fileID: 2132962758}
- component: {fileID: 2132962760}
- component: {fileID: 2132962758}
m_Layer: 0
m_Name: Net
m_TagString: Untagged

View File

@ -16,8 +16,18 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
public string deviceID;
public bool isPlayer = false;
public bool isThinck = false;
public WRJModel wrjModel = WRJModel.;
public void OnBeginDrag(PointerEventData eventData)
{
if (isDragWRJ)
{
if (DragManager.Instance.devices.Count == GameManager.Instance.wrjCount)
{
return;
}
}
if (model == null)
{
model = Instantiate(prefabItem);
@ -41,14 +51,18 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
{
if (!isThinck)
{
model.GetComponent<EquipmentCommon>().isPlayer = true;
model.GetComponent<EquipmentCommon>().isStartRehearsing = GlobalFlag.isStartRehearsing;
List<List_paraItem> temp = UIBootstrap.Instance.GetListParaItemById(deviceID);
model.GetComponent<EquipmentCommon>().FillInTheData(temp);
//
//
transform.SetAsLastSibling();
transform.localScale = Vector3.zero;
if (model.GetComponent<UnmannedAerialVehicleManage>())
model.GetComponent<UnmannedAerialVehicleManage>().wrjModel = wrjModel;
if (!isDragWRJ)
{
transform.SetAsLastSibling();
transform.localScale = Vector3.zero;
}
}
if (DragManager.Instance != null)
{

View File

@ -10,7 +10,7 @@ using XFrame.Core.Utils;
public class DragManager : MonoSingleton<DragManager>
{
public List<Modelequipment> deviceimages1 = new List<Modelequipment>();//把最终场景中存在的模型放入链表当中
public List<GameObject> deviceimages = new List<GameObject>();//把最开始生成在场景中的模型存入链表
public List<GameObject> devices = new List<GameObject>();//把最开始生成在场景中的模型存入链表
public List<string> modellist = new List<string>();//存入最开始场景生成模型的名字
public Dictionary<string,int> model = new Dictionary<string,int>();
@ -36,7 +36,7 @@ public class DragManager : MonoSingleton<DragManager>
//}
public void AddObj(GameObject obj)
{
deviceimages.Add(obj);//把生成的预设体放入链表当中
devices.Add(obj);//把生成的预设体放入链表当中
}
public void Addobj1(GameObject obj)
{

View File

@ -4,6 +4,7 @@ using RDate;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Tenkoku.Core;
using UnityEngine;
using static InterfaceManager;
@ -27,7 +28,14 @@ public class GameManager : MonoSingleton<GameManager>
public GameObject Teacher;
public GameObject student;
public GameObject posture;
public int wrjCount;
public List<SyncPlayerTransform> players = new List<SyncPlayerTransform>();
public DragController[] wrjDrags;
// Start is called before the first frame update
private void Awake()
{
@ -45,18 +53,30 @@ public class GameManager : MonoSingleton<GameManager>
spt.gameObject.SetActive(true);
spt.GetComponent<Camera>().cullingMask = ~(1 << 12);
spt.GetComponent<Camera>().cullingMask = ~(1 << 15);
if (UIBootstrap.Instance.GetDeviceByName("蜂群无人机").device_count > 0)
AdamThinkDevicesData.DataItem diTemp = UIBootstrap.Instance.GetDeviceByName("蜂群无人机");
if (diTemp.device_count > 0)
{
for (int i = 0; i < UIBootstrap.Instance.GetDeviceByName("蜂群无人机").device_count; i++)
wrjCount = diTemp.device_count;
for (int i = 0; i < wrjDrags.Length; i++)
{
DragController wrj = Instantiate(wrjDrag, dviceContent);
wrj.isPlayer = true;
wrj.deviceID = UIBootstrap.Instance.GetDeviceByName("蜂群无人机").id;
wrjDrags[i].isPlayer = true;
wrjDrags[i].deviceID = UIBootstrap.Instance.GetDeviceByName("蜂群无人机").id;
}
}
for (int i = 0; i < diTemp.list_para.Count; i++)
{
if (diTemp.list_para[i].para_name.Contains("光学侦察能力") && diTemp.list_para[i].para_value == "1")
{
wrjDrags[0].gameObject.SetActive(false);
}
}
}
else
{
for (int i = 0; i < dviceContent.childCount; i++)
{
Destroy(dviceContent.GetChild(i).gameObject);
}
spt.transform.position = blueSpawnPos.position;
spt.transform.eulerAngles = blueSpawnPos.eulerAngles;
spt.gameObject.SetActive(true);
@ -328,7 +348,7 @@ public class GameManager : MonoSingleton<GameManager>
SpawnDevice(hpDrag.prefabItem, deviceData.data[i]);
break;
case "频谱探测":
SpawnDevice(ppDrag.prefabItem,deviceData.data[i]);
SpawnDevice(ppDrag.prefabItem, deviceData.data[i]);
break;
case "微波武器":
SpawnDevice(wbDrag.prefabItem, deviceData.data[i]);
@ -355,7 +375,7 @@ public class GameManager : MonoSingleton<GameManager>
device.GetComponent<EquipmentCommon>().deviceID = data.id;
device.GetComponent<EquipmentCommon>().FillInTheData(data.list_para);
}
private void OnGetRoomUsers(string obj)
{
if (!string.IsNullOrWhiteSpace(obj))
@ -400,8 +420,8 @@ public class GameManager : MonoSingleton<GameManager>
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));
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);
}

View File

@ -9,7 +9,7 @@ using static InterfaceManager;
public class UIBootstrap : MonoSingleton<UIBootstrap>
{
//private string url = Url_GetAllThinkData;
private string sceneInfoUrl = Url_GetSceneInfo;
private string sceneInfoUrl;
public Editinformation editinformation = new Editinformation();
public SceneRoot currentSceneInfo = new SceneRoot();
public List<RSData.SubjectDataItem> subjectInfo = new List<RSData.SubjectDataItem>();
@ -21,7 +21,8 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
// Start is called before the first frame update
private async void Start()
{
Debug.Log(Url_GetAllThinkData);
sceneInfoUrl = Url_GetSceneInfo;
Debug.LogError(Url_GetAllThinkData);
editinformation = await AsyncWebReq.Post<Editinformation>(Url_GetAllThinkData, null);
for (int i = 0; i < editinformation.data.Count; i++)
{

View File

@ -1,4 +1,5 @@
using System;
using AdamSync;
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
@ -16,18 +17,13 @@ public class AddConfing : MonoBehaviour
private void Awake()
{
StartCoroutine(GetSetting(ipSetting, (data) =>
{
string[] datas= data.ToString().Split(':');
//Debug.Log(IP);
//Debug.Log(Port);
//Debug.Log(Url_Action);
IP = datas[0];
Port = datas[1];
//Debug.Log(IP);
//Debug.Log(Port);
//Debug.Log(Url_Action);
}));
string[] datas = ContectServer.ReadFromLocal("IPPort.txt").Split(':');
//Debug.Log(IP);
//Debug.Log(Port);
//Debug.Log(Url_Action);
IP = datas[0];
Port = datas[1];
}

View File

@ -9,7 +9,7 @@ using Newtonsoft.Json.Linq;
public static class InterfaceManager
{
private static string _IP = "192.168.107.15";
private static string _IP;
public static string IP
{
get { return _IP; }
@ -19,7 +19,7 @@ public static class InterfaceManager
_IP = value;
}
}
private static string _Port = "48888";
private static string _Port;
public static string Port
{
get { return _Port; }
@ -100,7 +100,7 @@ public static class InterfaceManager
/// <summary>
/// 获取房间ID并添加房间
/// </summary>
public static string Url_GetRoomID{get => IpAddress + "/Handler/Practice.ashx?action=add&Name=";}
public static string Url_GetRoomID { get => IpAddress + "/Handler/Practice.ashx?action=add&Name="; }
/// <summary>
/// 更新房间状态
/// </summary>
@ -142,7 +142,7 @@ public static class InterfaceManager
using (System.IO.StreamReader reader = new System.IO.StreamReader(path)) { return reader.ReadToEnd(); }
}
public static IEnumerator GetBytes(string url, Action<string> callback)
{
@ -221,10 +221,10 @@ public static class InterfaceManager
}
}
public static IEnumerator PostString(string url, WWWForm formdata, Dictionary<string, string> headers = null, Action<string> callback = null)
{
@ -279,7 +279,7 @@ public static class InterfaceManager
}
}
public static IEnumerator GetString(string url, Dictionary<string, string> headers = null,int time=50,Action<string> callback = null)
public static IEnumerator GetString(string url, Dictionary<string, string> headers = null, int time = 50, Action<string> callback = null)
{
while (true)
{

View File

@ -13,6 +13,7 @@ using Newtonsoft.Json;
/// </summary>
public class UnmannedAerialVehicle : MonoBehaviour
{
public WRJModel wrjModel = WRJModel.;
/// <summary>
/// 所属无人机蜂群
/// </summary>
@ -70,9 +71,6 @@ public class UnmannedAerialVehicle : MonoBehaviour
/// </summary>
public GameObject explodePrefab;
private void OnTriggerEnter(Collider other)
{
@ -85,6 +83,16 @@ public class UnmannedAerialVehicle : MonoBehaviour
}
}
/// <summary>
/// 设置无人机类型
/// </summary>
/// <param name="wrjModel"></param>
public void SetWRJModel(WRJModel _wrjModel)
{
wrjModel = _wrjModel;
}
/// <summary>
/// 被攻击
/// </summary>

View File

@ -20,11 +20,12 @@ public enum WRJModel
/// </summary>
public class UnmannedAerialVehicleManage : MonoBehaviour
{
public WRJModel wrjModel = WRJModel.;
/// <summary>
/// 无人机状态
/// </summary>
public Pattern pattern = Pattern.;
public WRJModel wrjModel = WRJModel.;
public static List<UnmannedAerialVehicleManage> unmannedAerialVehicleManages = new List<UnmannedAerialVehicleManage>();
#region
private bool _isStartRehearsing = false;
@ -149,25 +150,6 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
OnActivationChanged += OnActivationChangedHandler;
}
/// <summary>
/// 设置无人机类型
/// </summary>
/// <param name="wrjModel"></param>
public void SetWRJModel()
{
switch (wrjModel)
{
case WRJModel.:
Debug.Log("光学无人机");
break;
case WRJModel.:
Debug.Log("电子侦察无人机");
break;
case WRJModel.:
Debug.Log("自杀式无人机");
break;
}
}
[ContextMenu("Test")]
public void Test()
@ -196,7 +178,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
break;
}
var _unmannedAerialVehicle = unmannedAerialVehicles.FindAll(x => x != null);
var _unmannedAerialVehicle = unmannedAerialVehicles.FindAll(x => x != null&&x.gameObject.activeInHierarchy);
if (_unmannedAerialVehicle.Count == 0)
{
string nowData = string.Format("{0},{1}", "SetToBeDestroyed", equipmentCommon.deviceID);
@ -282,7 +264,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<UnmannedAerialVehicle> _unmannedAerialVehicles = unmannedAerialVehicles.FindAll(x => x != null);
List<UnmannedAerialVehicle> _unmannedAerialVehicles = unmannedAerialVehicles.FindAll(x => x != null&&x.gameObject.activeInHierarchy);
SendMsg(colliders1[_number].transform);
for (int i = 0; i < _unmannedAerialVehicles.Count; i++)
{
@ -467,7 +449,7 @@ public class UnmannedAerialVehicleManage : MonoBehaviour
unmannedAerialVehicles[i].dataLinkCommunicationFrequency = dataLinkCommunicationFrequency;
unmannedAerialVehicles[i].electronicReconnaissanceCapability = electronicReconnaissanceCapability;
unmannedAerialVehicles[i].opticalReconnaissanceCapability = opticalReconnaissanceCapability;
unmannedAerialVehicles[i].wrjModel = wrjModel;
}
}
}