Compare commits

...

2 Commits

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);
CreateAllUser(userData.data);
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"))
{
@ -523,7 +523,6 @@ public class View_Panel2 : XUIPanel
}
}
public RSData.RoomSubjectData currentRoomData = new RSData.RoomSubjectData();
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 () =>
{
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;
GlobalFlag.roomID = roomItem.name;
GlobalFlag.practiceId = roomItem.name;
@ -541,7 +540,7 @@ public class View_Panel2 : XUIPanel
UIBootstrap.Instance.GetSceneData(GlobalFlag.practiceId);
UIBootstrap.Instance.GetAllDeviceData();
Debug.Log(" roomItem.nameID==" + roomItem.name);
CreateSubjectItem(currentRoomData.data);
CreateSubjectItem(UIBootstrap.Instance.currentRoomData.data);
});
}
public RSData.SubjectInfo currentSubjectInfo = new RSData.SubjectInfo();
@ -634,6 +633,7 @@ public class View_Panel2 : XUIPanel
if (sdi[index].UserAccount == GlobalFlag.currentUser.login_name)
{
item.transform.GetChild(2).GetComponent<Toggle>().graphic.color = Color.green;
GlobalFlag.practiceSeatId = item.name;
isAssigned = true;
}
}
@ -676,6 +676,7 @@ public class View_Panel2 : XUIPanel
if (sdi[index].UserAccount == GlobalFlag.currentUser.login_name)
{
item.transform.GetChild(2).GetComponent<Toggle>().graphic.color = Color.green;
GlobalFlag.practiceSeatId = item.name;
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);
if (returnRoomId.state)
{
CreateRoomBase(returnRoomId.data, currentRoomName);
//创建房间
string RoomName = "createroom " + returnRoomId.data;
string roomID = 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
{

View File

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

View File

@ -1,6 +1,7 @@
using AdamSync;
using AdamThinkDevicesData;
using Boo.Lang;
using RDate;
using System;
using System.Collections;
using System.Collections.Generic;
@ -83,20 +84,21 @@ public class GameManager : MonoSingleton<GameManager>
}
}
///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")
{
Teacher.gameObject.SetActive(false);
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.isStartRehearsing)
if (GlobalFlag.currentUser.role_code == "03")
{
Teacher.gameObject.SetActive(true);
student.gameObject.SetActive(false);
spt.GetComponent<Camera>().cullingMask = -1;
}
@ -109,6 +111,7 @@ public class GameManager : MonoSingleton<GameManager>
{
SetWeatherValue();
SetModelValue();
string msg = "getroomusers ";
_ = SyncCreateRoom.SendMessageAsync(msg);
}
@ -176,15 +179,7 @@ public class GameManager : MonoSingleton<GameManager>
}
break;
case "StartDeduction":
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;
}
CheckRoomState();
break;
case "无人机List":
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();
}
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<Traininginformation> traininginformations = new List<Traininginformation>();
public AdamThinkDevicesData.DeviceData thinkDevicesData = new AdamThinkDevicesData.DeviceData();
public RSData.RoomSubjectData currentRoomData = new RSData.RoomSubjectData();
// Start is called before the first frame update
private async void Start()
{
@ -58,6 +59,19 @@ public class UIBootstrap : MonoSingleton<UIBootstrap>
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)
{
for (int i = 0; i < thinkDevicesData.data.Count; i++)

View File

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

View File

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