This commit is contained in:
账号名 2023-11-23 19:54:51 +08:00
commit 8e893f1e42
6 changed files with 79 additions and 27 deletions

View File

@ -453,7 +453,7 @@ public class View_Panel2 : XUIPanel
selector_panl.gameObject.SetActive(true); selector_panl.gameObject.SetActive(true);
CreateAllUser(userData.data); CreateAllUser(userData.data);
EliminateAccount(); EliminateAccount();
Debug.Log($"currentSubjectID+currentSeatID=" + currentSubjectID + "=" + currentSeatID); Debug.Log($"currentSubjectID+currentSeatID={ currentSubjectID }={currentSeatID}");
}); });
if (GlobalFlag.currentUser.role_code.Equals("04") || GlobalFlag.currentUser.role_code.Equals("05")) if (GlobalFlag.currentUser.role_code.Equals("04") || GlobalFlag.currentUser.role_code.Equals("05"))
{ {
@ -523,7 +523,6 @@ 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)
{ {
@ -533,7 +532,7 @@ public class View_Panel2 : XUIPanel
roomItem.transform.Find("view_btn").GetComponent<Button>().onClick.AddListener(async () => roomItem.transform.Find("view_btn").GetComponent<Button>().onClick.AddListener(async () =>
{ {
Storm_and_capture_panl.gameObject.SetActive(true); Storm_and_capture_panl.gameObject.SetActive(true);
currentRoomData = await AsyncWebReq.Get<RSData.RoomSubjectData>("http://111.229.30.246:48888/Handler/Practice.ashx?action=querypracticesubject&PracticeId=" + roomItem.name); UIBootstrap.Instance.currentRoomData = await AsyncWebReq.Get<RSData.RoomSubjectData>("http://111.229.30.246:48888/Handler/Practice.ashx?action=querypracticesubject&PracticeId=" + roomItem.name);
currentRoomName = roomItem.name; currentRoomName = roomItem.name;
GlobalFlag.roomID = roomItem.name; GlobalFlag.roomID = roomItem.name;
GlobalFlag.practiceId = roomItem.name; GlobalFlag.practiceId = roomItem.name;
@ -541,7 +540,7 @@ public class View_Panel2 : XUIPanel
UIBootstrap.Instance.GetSceneData(GlobalFlag.practiceId); UIBootstrap.Instance.GetSceneData(GlobalFlag.practiceId);
UIBootstrap.Instance.GetAllDeviceData(); UIBootstrap.Instance.GetAllDeviceData();
Debug.Log(" roomItem.nameID==" + roomItem.name); Debug.Log(" roomItem.nameID==" + roomItem.name);
CreateSubjectItem(currentRoomData.data); CreateSubjectItem(UIBootstrap.Instance.currentRoomData.data);
}); });
} }
public RSData.SubjectInfo currentSubjectInfo = new RSData.SubjectInfo(); public RSData.SubjectInfo currentSubjectInfo = new RSData.SubjectInfo();
@ -634,6 +633,7 @@ public class View_Panel2 : XUIPanel
if (sdi[index].UserAccount == GlobalFlag.currentUser.login_name) if (sdi[index].UserAccount == GlobalFlag.currentUser.login_name)
{ {
item.transform.GetChild(2).GetComponent<Toggle>().graphic.color = Color.green; item.transform.GetChild(2).GetComponent<Toggle>().graphic.color = Color.green;
GlobalFlag.practiceSeatId = item.name;
isAssigned = true; isAssigned = true;
} }
} }
@ -676,6 +676,7 @@ public class View_Panel2 : XUIPanel
if (sdi[index].UserAccount == GlobalFlag.currentUser.login_name) if (sdi[index].UserAccount == GlobalFlag.currentUser.login_name)
{ {
item.transform.GetChild(2).GetComponent<Toggle>().graphic.color = Color.green; item.transform.GetChild(2).GetComponent<Toggle>().graphic.color = Color.green;
GlobalFlag.practiceSeatId = item.name;
isAssigned = true; isAssigned = true;
} }
} }
@ -751,11 +752,17 @@ 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); 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) if (returnRoomId.state)
{ {
CreateRoomBase(returnRoomId.data, currentRoomName); string roomID = returnRoomId.data;
//创建房间
string RoomName = "createroom " + returnRoomId.data;
_ = AdamSync.SyncCreateRoom.SendMessageAsync(RoomName); RoomState roomState = await AsyncWebReq.Post<RoomState>("http://111.229.30.246:48888/Handler/Practice.ashx?action=updatestate&Id=" + roomID + "&state=0", null);
//创建房间
if (roomState.message == "success")
{
CreateRoomBase(returnRoomId.data, currentRoomName);
}
Debug.Log($"<color=yellow> roomState=={roomState.message}</color>");
//string RoomName = "createroom " + returnRoomId.data;
//_ = AdamSync.SyncCreateRoom.SendMessageAsync(RoomName);
} }
else else
{ {

View File

@ -2,6 +2,23 @@
using System.Collections.Generic; using System.Collections.Generic;
namespace RDate namespace RDate
{ {
[Serializable]
public class RoomState
{
/// <summary>
///
/// </summary>
public string state;
/// <summary>
///
/// </summary>
public string message;
/// <summary>
///
/// </summary>
public string data;
}
[Serializable] [Serializable]
public class DataItem public class DataItem
{ {

View File

@ -1,6 +1,7 @@
using AdamSync; using AdamSync;
using AdamThinkDevicesData; using AdamThinkDevicesData;
using Boo.Lang; using Boo.Lang;
using RDate;
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
@ -83,20 +84,21 @@ public class GameManager : MonoSingleton<GameManager>
} }
} }
///04 student 03 teacher ///04 student 03 teacher
if (GlobalFlag.currentUser.role_code == "03")
{
Teacher.gameObject.SetActive(true);
student.gameObject.SetActive(false);
spt.GetComponent<Camera>().cullingMask = -1;
}
if (GlobalFlag.currentUser.role_code == "04") if (GlobalFlag.currentUser.role_code == "04")
{ {
Teacher.gameObject.SetActive(false); Teacher.gameObject.SetActive(false);
student.gameObject.SetActive(true); student.gameObject.SetActive(true);
GlobalFlag.isStartRehearsing = (UIBootstrap.Instance.GetRoomStateById(GlobalFlag.roomID) == 1);
Debug.Log($"<color=red>isStartRehearsing={ GlobalFlag.isStartRehearsing}</color>");
if (GlobalFlag.isStartRehearsing)
{
spt.GetComponent<Camera>().cullingMask = -1;
}
} }
if (GlobalFlag.currentUser.role_code == "03")
if (GlobalFlag.isStartRehearsing)
{ {
Teacher.gameObject.SetActive(true);
student.gameObject.SetActive(false);
spt.GetComponent<Camera>().cullingMask = -1; spt.GetComponent<Camera>().cullingMask = -1;
} }
@ -109,6 +111,7 @@ public class GameManager : MonoSingleton<GameManager>
{ {
SetWeatherValue(); SetWeatherValue();
SetModelValue(); SetModelValue();
string msg = "getroomusers "; string msg = "getroomusers ";
_ = SyncCreateRoom.SendMessageAsync(msg); _ = SyncCreateRoom.SendMessageAsync(msg);
} }
@ -176,15 +179,7 @@ public class GameManager : MonoSingleton<GameManager>
} }
break; break;
case "StartDeduction": case "StartDeduction":
GlobalFlag.isStartRehearsing = true; CheckRoomState();
for (int i = 0; i < DeviceManager.Instance.devices.Count; i++)
{
DeviceManager.Instance.devices[i].isStartRehearsing = true;
}
if (GlobalFlag.currentUser.role_code == "04")
{
currentSpt.GetComponent<Camera>().cullingMask = -1;
}
break; break;
case "无人机List": case "无人机List":
SpawnDevice(wrjDrag.prefabItem, data); SpawnDevice(wrjDrag.prefabItem, data);
@ -223,6 +218,22 @@ public class GameManager : MonoSingleton<GameManager>
} }
public async void CheckRoomState()
{
RoomState roomState = await AsyncWebReq.Post<RoomState>("http://111.229.30.246:48888/Handler/Practice.ashx?action=updatestate&Id=" + GlobalFlag.roomID + "&state=1", null);
if (roomState.message == "success")
{
GlobalFlag.isStartRehearsing = true;
for (int i = 0; i < DeviceManager.Instance.devices.Count; i++)
{
DeviceManager.Instance.devices[i].isStartRehearsing = true;
}
if (GlobalFlag.currentUser.role_code == "04")
{
currentSpt.GetComponent<Camera>().cullingMask = -1;
}
}
}
//} //}
@ -345,7 +356,7 @@ public class GameManager : MonoSingleton<GameManager>
Reset(); Reset();
} }
private void Reset() private void Reset()
{ {

View File

@ -15,6 +15,7 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
public List<RSData.SubjectDataItem> subjectInfo = new List<RSData.SubjectDataItem>(); public List<RSData.SubjectDataItem> subjectInfo = new List<RSData.SubjectDataItem>();
public List<Traininginformation> traininginformations = new List<Traininginformation>(); public List<Traininginformation> traininginformations = new List<Traininginformation>();
public AdamThinkDevicesData.DeviceData thinkDevicesData = new AdamThinkDevicesData.DeviceData(); public AdamThinkDevicesData.DeviceData thinkDevicesData = new AdamThinkDevicesData.DeviceData();
public RSData.RoomSubjectData currentRoomData = new RSData.RoomSubjectData();
// Start is called before the first frame update // Start is called before the first frame update
private async void Start() private async void Start()
{ {
@ -58,6 +59,19 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
return detaIteml; return detaIteml;
} }
public int GetRoomStateById(string Id)
{
for (int i = 0; i < currentRoomData.data.Count; i++)
{
if (currentRoomData.data[i].Id == Id)
{
return currentRoomData.data[i].State;
}
}
return 0;
}
public List<List_paraItem> GetListParaItemById(string deviceId) public List<List_paraItem> GetListParaItemById(string deviceId)
{ {
for (int i = 0; i < thinkDevicesData.data.Count; i++) for (int i = 0; i < thinkDevicesData.data.Count; i++)

View File

@ -7,6 +7,9 @@ public class GlobalFlag
public static UserInfo currentUser; public static UserInfo currentUser;
public static string roomID; public static string roomID;
public static string practiceId; public static string practiceId;
/// <summary>
/// 席位ID
/// </summary>
public static string practiceSeatId; public static string practiceSeatId;
/// <summary> /// <summary>
///是否正在预演 ///是否正在预演

View File

@ -45,7 +45,7 @@ public static class AsyncWebReq
{ {
string reqJson = JsonConvert.SerializeObject(data); string reqJson = JsonConvert.SerializeObject(data);
#if UNITY_EDITOR #if UNITY_EDITOR
//Debug.Log($"async req json : {reqJson}"); Debug.Log($"async req json : {reqJson}");
#endif #endif
var bodyRaw = Encoding.UTF8.GetBytes(reqJson); var bodyRaw = Encoding.UTF8.GetBytes(reqJson);
request.uploadHandler = new UploadHandlerRaw(bodyRaw); request.uploadHandler = new UploadHandlerRaw(bodyRaw);