Compare commits

...

2 Commits

8 changed files with 155 additions and 41 deletions

View File

@ -1,4 +1,5 @@
using System.Collections;
using AdamSync;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
@ -18,7 +19,7 @@ public class Taskpanel : MonoBehaviour
/// <summary>
/// 二维地图页面
/// </summary>
public RectTransform measure_panl;//测量页面
public RectTransform punctuation_panl;//标记工具
public RectTransform specific_panl;//专用标会
@ -38,19 +39,24 @@ public class Taskpanel : MonoBehaviour
public Button fanhuiBtn;
public Button fanhui;
private bool isp=true;
private bool isp = true;
void Start()
{
AdamSync.SyncCreateRoom.leaveRoomRequset += OnGetLeaveRoomsInfo;
fanhui.onClick.AddListener(() =>
{
GameMain.tiao = false;
SceneManager.LoadScene("SampleScene");
OnLeaveRoom();
});
two_dimensional.onClick.AddListener(() =>
{
//two_dimensional.gameObject.SetActive(false);
//playback_btn.gameObject.SetActive(false);
model.gameObject.SetActive(true);
model.gameObject.SetActive(true);
});
////返回按钮
//fanhuiBtn.onClick.AddListener(() =>
@ -119,7 +125,7 @@ public class Taskpanel : MonoBehaviour
});
menu_button.onClick.AddListener(() =>
{
if (isp==true)
if (isp == true)
{
measure_btn.gameObject.SetActive(false);
punctuation_btn.gameObject.SetActive(false);
@ -139,10 +145,22 @@ public class Taskpanel : MonoBehaviour
}
});
}
public void OnGetLeaveRoomsInfo(string msg)
{
Debug.Log("OnGetLeaveRoomsInfo====" + msg);
string[] info = msg.Split(',');
GameManager.Instance.RemovePlayer(ulong.Parse(info[0]));
SceneManager.LoadScene("SampleScene");
}
public void OnLeaveRoom()
{
Debug.Log("Leaveroom");
string msg = "leaveroom ";
_ = SyncCreateRoom.SendMessageAsync(msg);
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -574,12 +574,12 @@ public class View_Panel2 : XUIPanel
GameObject subjectTemp = GameObject.Instantiate(currentRoomSubjectItem, currentRoomSubjectItemConnect);
subjectTemp.SetActive(true);
subjectTemp.name = di[index].Id;
GlobalFlag.practiceSubjectID = subjectTemp.name;
subjectTemp.transform.GetChild(0).GetComponent<Text>().text = di[index].Name;
subjectTemp.GetComponent<Button>().onClick.AddListener(async () =>
{
currentDIPracticeID = di[index].PracticeId;
currentDISubjectID = subjectTemp.name;
GlobalFlag.practiceSubjectID = subjectTemp.name;
currentSubjectInfo = await AsyncWebReq.Get<RSData.SubjectInfo>("http://111.229.30.246:48888/Handler/Practice.ashx?action=querypracticeseat&PracticeId=" + currentDIPracticeID + "&PracticeSubjectId=" + currentDISubjectID);
CreateSubjectInfo(currentSubjectInfo.data);
});

View File

@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 1113159741}
m_IndirectSpecularColor: {r: 0.009410857, g: 0.009313087, b: 0.009679941, a: 1}
m_IndirectSpecularColor: {r: 0.16219163, g: 0.30625746, b: 0.67076117, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@ -37276,7 +37276,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &754191142
RectTransform:
m_ObjectHideFlags: 0
@ -48301,6 +48301,7 @@ MonoBehaviour:
wxdDrag: {fileID: 3438159622238491400, guid: 57c5ff12282ea37439abe26b94bc93b3, type: 3}
Teacher: {fileID: 754191141}
student: {fileID: 1862065805184089353}
players: []
--- !u!4 &1436809530
Transform:
m_ObjectHideFlags: 0
@ -48413,6 +48414,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 27096289766e99845a47ad87729a988f, type: 3}
m_Name:
m_EditorClassIdentifier:
devices: []
--- !u!1 &1444599844
GameObject:
m_ObjectHideFlags: 0
@ -61862,10 +61864,10 @@ MonoBehaviour:
colorSkyBase: {r: 0.6054902, g: 0.7090196, b: 0.7968628, a: 0.8}
colorSkyBaseLow: {r: 0.75686276, g: 0.88627446, b: 0.9960785, a: 1}
colorHorizon: {r: 0.9082354, g: 1.0682354, b: 1.1952941, a: 1.2}
colorHorizonLow: {r: 0.12235295, g: 0.2964706, b: 0.36705884, a: 1.2}
colorHorizonLow: {r: 0.9082354, g: 1.0682354, b: 1.1952941, a: 1.2}
colorSkyAmbient: {r: 1, g: 1, b: 1, a: 1}
colorClouds: {r: 1, g: 1, b: 1, a: 1}
colorHighlightClouds: {r: 0, g: 0, b: 0, a: 1}
colorHighlightClouds: {r: 1, g: 1, b: 1, a: 1}
colorSkyboxGround: {r: 0.1102941, g: 0.08836951, b: 0.06487888, a: 1}
colorSkyboxMie: {r: 1, g: 1, b: 1, a: 1}
displayTime: '[ 10:30:00 AM] [ 3/6/1027 ad]'
@ -62203,7 +62205,7 @@ MonoBehaviour:
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
randSeed: 830968
randSeed: 84043625
isDoingTransition: 0
minimumHeight: 0
--- !u!114 &1820978574
@ -63720,6 +63722,36 @@ PrefabInstance:
value:
objectReference: {fileID: 21300000, guid: 47390e15134f347458cdb6364e799ffc,
type: 3}
- target: {fileID: 5855821741890996493, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.size
value: 0
objectReference: {fileID: 0}
- target: {fileID: 5855821741890996493, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Mode
value: 1
objectReference: {fileID: 0}
- target: {fileID: 5855821741890996493, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
objectReference: {fileID: 0}
- target: {fileID: 5855821741890996493, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 1436809529}
- target: {fileID: 5855821741890996493, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName
value: OnLeaveRoom
objectReference: {fileID: 0}
- target: {fileID: 5855821741890996493, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName
value: UnityEngine.Object, UnityEngine
objectReference: {fileID: 0}
- target: {fileID: 5855821741952944143, guid: fbbb5cf357f688c4e8fb400e3c92f0e1,
type: 3}
propertyPath: m_Text

View File

@ -110,7 +110,7 @@ namespace AdamThinkDevicesData
public List<List_paraItem> list_para ;
}
[Serializable]
public class Root
public class DeviceData
{
/// <summary>
///

View File

@ -1,4 +1,5 @@
using AdamSync;
using AdamThinkDevicesData;
using Boo.Lang;
using System;
using System.Collections;
@ -9,7 +10,7 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameManager : MonoBehaviour
public class GameManager : MonoSingleton<GameManager>
{
public SyncPlayerTransform playerTransformPrefab;
public Transform spawnPos;
@ -23,6 +24,7 @@ public class GameManager : MonoBehaviour
public DragController wxdDrag;
public GameObject Teacher;
public GameObject student;
public System.Collections.Generic.List<SyncPlayerTransform> players = new System.Collections.Generic.List<SyncPlayerTransform>();
// Start is called before the first frame update
private void Awake()
{
@ -45,6 +47,7 @@ public class GameManager : MonoBehaviour
spt.gameObject.transform.position = spawnPos.position;
spt.gameObject.transform.eulerAngles = spawnPos.eulerAngles;
spt.SetPlayerInfo(ulong.Parse(GlobalFlag.currentUser.user_id), GlobalFlag.currentUser.login_name, ulong.Parse(GlobalFlag.roomID), true);
AddPlayers(spt);
ToolsBootstrap.Instance.SetCameraInfo(spt);
//0 red 1 blue
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) == "0")
@ -105,7 +108,7 @@ public class GameManager : MonoBehaviour
private void Update()
{
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) == "0"&&Input.GetMouseButtonDown(1))
if (UIBootstrap.Instance.GetRoleByIDPracticeId(GlobalFlag.practiceSeatId) == "0" && Input.GetMouseButtonDown(1))
{
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
@ -119,6 +122,26 @@ public class GameManager : MonoBehaviour
}
}
public void AddPlayers(SyncPlayerTransform s)
{
if (!players.Contains(s))
{
players.Add(s);
}
}
public void RemovePlayer(ulong playerID)
{
for (int i = 0; i < players.Count; i++)
{
if (players[i].userID == playerID)
{
players.Remove(players[i]);
Destroy(players[i].gameObject);
}
}
}
public void OnOtherPlayerOnline(string msg)
{
StopCoroutine(WaitSpawn(msg));
@ -142,6 +165,7 @@ public class GameManager : MonoBehaviour
spt.gameObject.transform.position = spawnPos.position;
spt.gameObject.transform.eulerAngles = spawnPos.eulerAngles;
spt.SetPlayerInfo(ulong.Parse(data[1]), data[2], ulong.Parse(data[3]), false);
AddPlayers(spt);
}
break;
case "StartDeduction":
@ -152,16 +176,16 @@ public class GameManager : MonoBehaviour
}
break;
case "无人机List":
SpawnDevice(wrjDrag, data);
SpawnDevice(wrjDrag.prefabItem, data);
break;
case "地面无线电干扰":
SpawnDevice(wxdDrag, data);
SpawnDevice(wxdDrag.prefabItem, data);
break;
case "探测雷达":
SpawnDevice(ldDrag, data);
SpawnDevice(ldDrag.prefabItem, data);
break;
case "激光火控平台":
SpawnDevice(hpDrag, data);
SpawnDevice(hpDrag.prefabItem, data);
break;
case "Stop":
GlobalFlag.isStartRehearsing = false;
@ -178,6 +202,7 @@ public class GameManager : MonoBehaviour
}
break;
case "offline":
break;
default:
break;
@ -187,12 +212,20 @@ public class GameManager : MonoBehaviour
public void SpawnDevice(DragController deviceDragBtn, string[] data)
public void SpawnDevice(GameObject devicePrefab, string[] data = null, string deviceID = null)
{
GameObject obj = Instantiate(deviceDragBtn.prefabItem);
obj.transform.position = new Vector3(float.Parse(data[1]), float.Parse(data[2]), float.Parse(data[3]));
obj.transform.eulerAngles = new Vector3(float.Parse(data[4]), float.Parse(data[5]), float.Parse(data[6]));
obj.GetComponent<EquipmentCommon>().deviceID = data[7];
GameObject obj = Instantiate(devicePrefab);
if (string.IsNullOrEmpty(deviceID))
{
obj.transform.position = new Vector3(float.Parse(data[1]), float.Parse(data[2]), float.Parse(data[3]));
obj.transform.eulerAngles = new Vector3(float.Parse(data[4]), float.Parse(data[5]), float.Parse(data[6]));
obj.GetComponent<EquipmentCommon>().deviceID = data[7];
}
else
{
obj.GetComponent<EquipmentCommon>().deviceID = deviceID;
}
}
private void OnGetRoomUsers(string obj)
@ -211,19 +244,43 @@ public class GameManager : MonoBehaviour
spt.SetPlayerInfo(ulong.Parse(userInfo[0]), userInfo[1], ulong.Parse(userInfo[2]), false);
spt.transform.position = new Vector3(spawnPos.position.x + index * 0.5f, spawnPos.position.y, spawnPos.position.z + index * 0.5f);
spt.transform.eulerAngles = spawnPos.eulerAngles;
AddPlayers(spt);
userIds.Add(ulong.Parse(userInfo[0]));
}
}
OnGetRoomDevice();
string msg = $"send2room online,{ulong.Parse(GlobalFlag.currentUser.user_id)},{GlobalFlag.currentUser.login_name},{ulong.Parse(GlobalFlag.roomID)}";
_ = SyncCreateRoom.SendMessageAsync(msg);
}
public void OnBack()
/// <summary>
/// 获取 当前房间-当前科目里的所有设备
/// </summary>
public async void OnGetRoomDevice()
{
SceneManager.LoadScene("TEstSync");
DeviceData deviceData = await AsyncWebReq.Get<DeviceData>("http://111.229.30.246:48888/Handler/Thinkingfile.ashx?action=querypracticedevicedetail&PracticeId=" + GlobalFlag.roomID + "&PracticeSubjectId=" + GlobalFlag.practiceSubjectID);
for (int i = 0; i < deviceData.data.Count; i++)
{
switch (deviceData.data[i].device_name)
{
case "无人机List":
SpawnDevice(wrjDrag.prefabItem, null, deviceData.data[i].id);
break;
case "地面无线电干扰":
SpawnDevice(wxdDrag.prefabItem, null, deviceData.data[i].id);
break;
case "探测雷达":
SpawnDevice(ldDrag.prefabItem, null, deviceData.data[i].id);
break;
case "激光火控平台":
SpawnDevice(hpDrag.prefabItem, null, deviceData.data[i].id);
break;
}
}
}
public void SetWeatherValue()
{
tenkokuModule.weather_RainAmt = Mathf.Lerp(0f, 1f, float.Parse(UIBootstrap.Instance.currentSceneInfo.data.EnvRain));

View File

@ -13,7 +13,7 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
public SceneRoot currentSceneInfo = new SceneRoot();
public List<RSData.SubjectDataItem> subjectInfo = new List<RSData.SubjectDataItem>();
public List<Traininginformation> traininginformations = new List<Traininginformation>();
public AdamThinkDevicesData.Root thinkDevicesData = new AdamThinkDevicesData.Root();
public AdamThinkDevicesData.DeviceData thinkDevicesData = new AdamThinkDevicesData.DeviceData();
// Start is called before the first frame update
private async void Start()
{
@ -44,7 +44,7 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
public async void GetAllDeviceData()
{
thinkDevicesData = await AsyncWebReq.Post<AdamThinkDevicesData.Root>("http://111.229.30.246:48888/Handler/Thinkingfile.ashx?action=practicethinkdevice&Id=" + GlobalFlag.currentThinkId, null);
thinkDevicesData = await AsyncWebReq.Post<AdamThinkDevicesData.DeviceData>("http://111.229.30.246:48888/Handler/Thinkingfile.ashx?action=practicethinkdevice&Id=" + GlobalFlag.currentThinkId, null);
}
public AdamThinkDevicesData.DataItem GetDeviceByName(string deviceName)
{
@ -92,7 +92,8 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
public void OnGetRoomsInfo(string msg)
{
Debug.Log("OnGetRooms====" + msg);
}
}
// Update is called once per frame
void Update()
{
@ -114,6 +115,12 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
Debug.Log(info);
_ = AdamSync.SyncCreateRoom.SendMessageAsync(info);
}
if (Input.GetKeyDown("l"))
{
string msg = "leaveroom ";
_ = AdamSync.SyncCreateRoom.SendMessageAsync(msg);
}
}
private void OnDisable()
{

View File

@ -55,11 +55,11 @@ namespace AdamSync
Vector3 temp = new Vector3(float.Parse(data[0]), float.Parse(data[1]), float.Parse(data[2]));
return temp;
}
private void OnDisable()
{
Debug.Log("OnDisable");
StopAllCoroutines();
SyncCreateRoom.playerInfoRequset -= ReceivePlayInfo;
}
//private void OnDisable()
//{
// Debug.Log("OnDisable");
// StopAllCoroutines();
// SyncCreateRoom.playerInfoRequset -= ReceivePlayInfo;
//}
}
}

View File

@ -38,10 +38,10 @@ public class SingleMachineTest : MonoBehaviour
/// <summary>
/// 测试接受数据
/// </summary>
private AdamThinkDevicesData.Root root;
private AdamThinkDevicesData.DeviceData root;
void Start()
{
root = Newtonsoft.Json.JsonConvert.DeserializeObject<AdamThinkDevicesData.Root>(msg1);
root = Newtonsoft.Json.JsonConvert.DeserializeObject<AdamThinkDevicesData.DeviceData>(msg1);
unmannedAerialVehicleManages.ForEach(x => x.FillInTheData(root.data[2].list_para));
radarMangers.ForEach(x => x.FillInTheData(root.data[0].list_para));