添加当前想定ID获取的逻辑

This commit is contained in:
yulong 2023-11-19 23:06:03 +08:00
parent f23049efb0
commit 9b546eef9b
4 changed files with 59 additions and 14 deletions

View File

@ -531,8 +531,9 @@ public class View_Panel2 : XUIPanel
public RSData.RoomSubjectData currentRoomData = new RSData.RoomSubjectData();
public void CreateRoomBase(string roomId, string name)
public void CreateRoomBase(string _roomId, string name)
{
string roomId = _roomId.Split(',')[0];
GameObject roomItem = GameObject.Instantiate(root_pan, place);
roomItem.name = roomId;
roomItem.transform.Find("Text").GetComponent<Text>().text = name;
@ -543,6 +544,7 @@ public class View_Panel2 : XUIPanel
currentRoomName = roomItem.name;
GlobalFlag.roomID = roomItem.name;
GlobalFlag.practiceId = roomItem.name;
GlobalFlag.currentThinkId = _roomId.Split(',')[1];
UIBootstrap.Instance.GetSceneData(GlobalFlag.practiceId);
Debug.Log(" roomItem.nameID==" + roomItem.name);
@ -755,7 +757,7 @@ public class View_Panel2 : XUIPanel
ReturnRoomID returnRoomId = await AsyncWebReq.Post<ReturnRoomID>("http://111.229.30.246:48888/Handler/Practice.ashx?action=add&Name=" + currentRoomName + "&MissionModel=" + currentMissionModel + "&ThinkingId=" + currentThinkingId + "&AccountsInfo=" + accountInfo, null);
if (returnRoomId.state)
{
CreateRoomBase(returnRoomId.data, currentRoomName);
CreateRoomBase(returnRoomId.data+","+currentThinkingId, currentRoomName);
//创建房间
string RoomName = "createroom " + returnRoomId.data;

View File

@ -12,7 +12,8 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
public HuoPaoController[] huoPaoCtrls;
public Text modelname_text;
public bool isDragWRJ = true;
public string deviceID;
private Weaponitemone weaponitemones = new Weaponitemone();
public void OnBeginDrag(PointerEventData eventData)
{
if (model == null)
@ -32,14 +33,15 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
}
}
public void OnEndDrag(PointerEventData eventData)
public async void OnEndDrag(PointerEventData eventData)
{
if (model != null)
{
if (isDragWRJ)
{
model.GetComponent<UnmannedAerialVehicleManage>().isStartRehearsing = GlobalFlag.isStartRehearsing;
weaponitemones = await AsyncWebReq.Post<Weaponitemone>("http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&think_device_id=" + deviceID, null);
model.GetComponent<UnmannedAerialVehicleManage>().FillInTheData(weaponitemones);
//for (int i = 0; i < huoPaoCtrls.Length; i++)
//{
// huoPaoCtrls[i].wrjs.Add(model);
@ -50,7 +52,7 @@ public class DragController : MonoBehaviour, IBeginDragHandler, IEndDragHandler,
{
DragManager.Instance.AddObj(model);//把对应模型传入链表
//DragManager.Instance.Addobj1(model);//
//model.GetComponent<Modeldata>().SetPos();//重新获取该模型的位置的值
//model.GetComponent<Modeldata>().SetPos();//重新获取该模型的位置的值
DragManager.Instance.Addtext(modelname_text.text);//把对应名字存入链表
}
model = null;

View File

@ -1,4 +1,5 @@
using AdamSync;
using Boo.Lang;
using System;
using System.Collections;
using System.Collections.Generic;
@ -12,9 +13,9 @@ public class GameManager : MonoBehaviour
{
public SyncPlayerTransform playerTransformPrefab;
public Transform spawnPos;
public List<ulong> userIds = new List<ulong>();
public System.Collections.Generic.List<ulong> userIds = new System.Collections.Generic.List<ulong>();
public TenkokuModule tenkokuModule;
public List<ModelInfo> modelsInfo = new List<ModelInfo>();
public System.Collections.Generic.List<ModelInfo> modelsInfo = new System.Collections.Generic.List<ModelInfo>();
public Transform dviceContent;
public GameObject wrjDrag;
public GameObject ldDrag;
@ -22,6 +23,7 @@ public class GameManager : MonoBehaviour
public GameObject wxdDrag;
public GameObject Teacher;
public GameObject student;
public Weaponitem weaponitem = new Weaponitem();
// Start is called before the first frame update
private void Awake()
{
@ -36,7 +38,7 @@ public class GameManager : MonoBehaviour
student.gameObject.SetActive(true);
}
GetAllWeapons();
SyncCreateRoom.getroomusersRequset += OnGetRoomUsers;
SyncCreateRoom.send2roomRequset += OnOtherPlayerOnline;
@ -50,19 +52,54 @@ public class GameManager : MonoBehaviour
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) == "0")
{
spt.GetComponent<Camera>().cullingMask = ~(1 << 11);
GameObject wrj = Instantiate(wrjDrag, dviceContent);
for (int i = 0; i < GetDeviceByName("蜂群无人机").Count; i++)
{
GameObject wrj = Instantiate(wrjDrag, dviceContent);
wrj.GetComponent<DragController>().deviceID = GetDeviceByName("蜂群无人机")[i].id;
}
}
else
{
spt.GetComponent<Camera>().cullingMask = ~(1 << 12);
GameObject ld = Instantiate(ldDrag, dviceContent);
GameObject hp = Instantiate(hpDrag, dviceContent);
GameObject wzd = Instantiate(wxdDrag, dviceContent);
for (int i = 0; i < GetDeviceByName("探测雷达").Count; i++)
{
GameObject ld = Instantiate(ldDrag, dviceContent);
ld.GetComponent<DragController>().deviceID = GetDeviceByName("探测雷达")[i].id;
}
for (int i = 0; i < GetDeviceByName("激光火控平台").Count; i++)
{
GameObject hp = Instantiate(hpDrag, dviceContent);
hp.GetComponent<DragController>().deviceID = GetDeviceByName("激光火控平台")[i].id;
}
for (int i = 0; i < GetDeviceByName("地面无线电干扰").Count; i++)
{
GameObject wxd = Instantiate(wxdDrag, dviceContent);
wxd.GetComponent<DragController>().deviceID = GetDeviceByName("地面无线电干扰")[i].id;
}
}
userIds.Add(ulong.Parse(GlobalFlag.currentUser.user_id));
tenkokuModule.mainCamera = spt.transform;
}
private async void GetAllWeapons()
{
weaponitem = await AsyncWebReq.Post<Weaponitem>("http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevice&think_id=" + GlobalFlag.currentThinkId, null);
}
public System.Collections.Generic.List<DataItem1> GetDeviceByName(string deviceName)
{
System.Collections.Generic.List<DataItem1> detaIteml = new System.Collections.Generic.List<DataItem1>();
for (int i = 0; i < weaponitem.data.Count; i++)
{
if (weaponitem.data[i].device_name == deviceName)
detaIteml.Add(weaponitem.data[i]);
}
return detaIteml;
}
public void Start()
{
SetWeatherValue();
@ -171,7 +208,7 @@ public class GameManager : MonoBehaviour
Debug.Log(info);
if (info.Length > 0 && !string.IsNullOrWhiteSpace(info))
{
modelsInfo = Jsonanalyze.FromJson<List<ModelInfo>>(info);
modelsInfo = Jsonanalyze.FromJson<System.Collections.Generic.List<ModelInfo>>(info);
for (int i = 0; i < modelsInfo.Count; i++)
{
GameObject obj = Resources.Load<GameObject>(modelsInfo[i].str);

View File

@ -12,4 +12,8 @@ public class GlobalFlag
///是否正在预演
/// </summary>
public static bool isStartRehearsing;
/// <summary>
/// 当前想定ID
/// </summary>
public static string currentThinkId;
}