主持人

This commit is contained in:
liuliang 2024-12-25 22:10:20 +08:00
parent 999159c80b
commit e92750730f
11 changed files with 268 additions and 70 deletions

View File

@ -2,7 +2,6 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using static UnityEditor.Experimental.GraphView.GraphView;
public class Panel3 : MonoBehaviour
{

View File

@ -0,0 +1,64 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class ReadRoom : MonoBehaviour
{
public static ReadRoom instance;
public gameRoomList gameRoomListInstance; // 引用 gameRoomList 脚本实例
public GameRoomListResponse gameRoomListResponse;
private List<GameRoomListData> roomDataList;
public JSONReader js;
// Start is called before the first frame update
void Start()
{
instance = this;
gameRoomListInstance = FindObjectOfType<gameRoomList>();
}
//主持人直接进入房间要获取的数据
public async void head()
{
var response = await gameRoomListInstance.getGameRoomList();
if (response != null && response.Data != null)
{
roomDataList = response.Data;
Debug.Log($"获取到的房间数量:{roomDataList.Count}");
// 获取当前日期
DateTime currentDate = DateTime.Now;
//将当前日期格式化为 "yyyy/MM/dd" 形式
string formattedDate = currentDate.ToString("yyyy/MM/dd");
// 调用方法,动态生成房间元素
foreach (var room in roomDataList)
{
for (int i = 0; i < room.PlayerList.Count; i++)
{
if ((GlobalData.ServerData.data.userId == room.PlayerList[i].UserId) && ("2024/12/20" == room.ReserveDate))
{
Debug.Log("可以直接进入房间");
SceneManager.LoadScene(2);
}
//else
//{
// Debug.Log("不可以直接进入房间");
// SceneManager.LoadScene(1);
//}
}
}
}
else
{
Debug.LogError("获取房间列表失败!");
}
}
// Update is called once per frame
void Update()
{
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 67494b9dd890ac44fbcec6f6b28c3d60
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
//using System.Drawing;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class RoomManager : MonoBehaviour
{
@ -18,6 +20,7 @@ public class RoomManager : MonoBehaviour
gameRoomListInstance = FindObjectOfType<gameRoomList>();
FetchRoomList();
}
// 异步获取房间数据
private async void FetchRoomList()
{
@ -40,6 +43,7 @@ public class RoomManager : MonoBehaviour
// 动态生成房间预制体,并赋值数据
private void PopulateRoomList(List<GameRoomListData> roomDataList)
{
foreach (var room in roomDataList)
{
// 实例化房间预制体
@ -75,6 +79,21 @@ public class RoomManager : MonoBehaviour
// 添加 RoomDataHolder 脚本并存储数据
Status dataHolder = roomItem.GetComponent<Status>();
dataHolder.SetRoomData(room.RoomId, room.SceneId, room.SubjectId, room.TemplateId, room.Status);
// 获取当前日期
DateTime currentDate = DateTime.Now;
//将当前日期格式化为 "yyyy/MM/dd" 形式
string formattedDate = currentDate.ToString("yyyy/MM/dd");
for (int i = 0; i < room.PlayerList.Count; i++)
{
if (GlobalData.ServerData.data.userId== room.PlayerList[i].UserId)
{
Debug.Log("可以直接进入房间");
//SceneManager.LoadScene(2);
}
Debug.Log("UserId=" + room.PlayerList[i].UserId);
}
// 为按钮添加点击事件,并传入房间数据
roomButton.onClick.AddListener(() => OnRoomButtonClicked(room));
}
@ -84,5 +103,10 @@ public class RoomManager : MonoBehaviour
{
Debug.Log($"点击了房间: {room.RoomId}, 状态: {room.Status}," +
$"模板ID: {room.TemplateId},场景ID: {room.SceneId},科目ID: {room.SubjectId}");
Debug.Log("ReserveDate=" + room.ReserveDate);
for(int i=0;i<room.PlayerList.Count;i++)
{
Debug.Log("UserId=" + room.PlayerList[i].UserId);
}
}
}

View File

@ -47,6 +47,10 @@ public class Starthost : MonoBehaviour
private int currentLineIndex = 0; // 当前语音和文本索引
private GameObject right;//右边图标
private void Awake()
{
DontDestroyOnLoad(this.gameObject);
}
void Start()
{
audioSource= GetComponent<AudioSource>();

View File

@ -1665,7 +1665,7 @@ MonoBehaviour:
isEnd: 0
isOngoing: 0
isScheduled: 0
isadministrator: 0
isadministrator: 1
drill: {fileID: 0}
RoomId:
status:

View File

@ -10385,7 +10385,7 @@ Camera:
near clip plane: 0.3
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic: 0
orthographic size: 30
m_Depth: 1
m_CullingMask:
@ -26204,6 +26204,7 @@ MonoBehaviour:
m_EditorClassIdentifier:
yg: {fileID: 1221713538}
Player: {fileID: 382802809}
CameraControl: {fileID: 0}
horizontal: 0
vertical: 0
--- !u!114 &1490008726
@ -27893,6 +27894,7 @@ MonoBehaviour:
us: {fileID: 0}
UseSkill: {fileID: 0}
characterControl: {fileID: 0}
TimeText: {fileID: 0}
--- !u!135 &1629676688
SphereCollider:
m_ObjectHideFlags: 0
@ -27925,6 +27927,7 @@ MonoBehaviour:
spreadRadius: 3
windDirection: 0
SpreadFireNumber: 3
time: {fileID: 0}
--- !u!1001 &1637601597
PrefabInstance:
m_ObjectHideFlags: 0
@ -28392,6 +28395,52 @@ Transform:
m_CorrespondingSourceObject: {fileID: 443876, guid: be8a9b4fd6545dd4e901964c42af5f6c, type: 3}
m_PrefabInstance: {fileID: 1700457050}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1705420776
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1705420778}
- component: {fileID: 1705420777}
m_Layer: 0
m_Name: BurstCollisionWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1705420777
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1705420776}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3}
m_Name:
m_EditorClassIdentifier:
cellSpans:
m_AlignBytes: 16
--- !u!4 &1705420778
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1705420776}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 39
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1707678916
GameObject:
m_ObjectHideFlags: 0
@ -29789,52 +29838,6 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 2165836829436838819, guid: ca0e087ad731f8e4c87e761b0baa2d2c, type: 3}
m_PrefabInstance: {fileID: 1805548635}
m_PrefabAsset: {fileID: 0}
--- !u!1 &1810680226
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1810680228}
- component: {fileID: 1810680227}
m_Layer: 0
m_Name: BurstCollisionWorld
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &1810680227
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1810680226}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f1a161c4294214a4fbcb7e9e94800494, type: 3}
m_Name:
m_EditorClassIdentifier:
cellSpans:
m_AlignBytes: 16
--- !u!4 &1810680228
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1810680226}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 39
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!64 &1818617132
MeshCollider:
m_ObjectHideFlags: 0
@ -65970,6 +65973,7 @@ MonoBehaviour:
horizontalMaxRotation: 75
verticalMinRotation: -75
verticalMaxRotation: 75
joystickInput: {x: 0, y: 0}
--- !u!224 &8163955216411254552
RectTransform:
m_ObjectHideFlags: 0

View File

@ -743,6 +743,8 @@ GameObject:
- component: {fileID: 252707972}
- component: {fileID: 252707975}
- component: {fileID: 252707974}
- component: {fileID: 252707976}
- component: {fileID: 252707977}
m_Layer: 5
m_Name: LoginPanel
m_TagString: Untagged
@ -845,6 +847,32 @@ MonoBehaviour:
pwd: {fileID: 1477048540}
sjh: {fileID: 691978845}
yzm: {fileID: 2052614155}
--- !u!114 &252707976
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 252707970}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 67494b9dd890ac44fbcec6f6b28c3d60, type: 3}
m_Name:
m_EditorClassIdentifier:
gameRoomListInstance: {fileID: 0}
js: {fileID: 7695717545649794843}
--- !u!114 &252707977
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 252707970}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 92f8778f7c80dcc4ba76a40411a6fa9c, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &287371580
GameObject:
m_ObjectHideFlags: 0
@ -3722,3 +3750,59 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2052614151}
m_CullTransparentMesh: 1
--- !u!4 &7695717545649794842
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7695717545649794844}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1006.09503, y: 598.65985, z: -4.566557}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7695717545649794843
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 7695717545649794844}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 13fa0701c49727a4c84282a40243e52d, type: 3}
m_Name:
m_EditorClassIdentifier:
npcJsonFile: {fileID: 4900000, guid: a854e20393334f04a8fc75e06404fe4f, type: 3}
locationJsonFile: {fileID: 4900000, guid: 4d6cd655327e27c4b88c2033169c8fed, type: 3}
eventJsonFile: {fileID: 4900000, guid: 2ef075e4830019a42b84d8d05d13d81c, type: 3}
matialJsonFile: {fileID: 4900000, guid: d98cb351d1a87dc4887a37106b9745d4, type: 3}
sceneJsonFile: {fileID: 4900000, guid: 06c09fd1c8b0a0a45951a1065189d922, type: 3}
incidentSiteJosnFile: {fileID: 4900000, guid: 1efa4372b10d4294199638c49173ff4c, type: 3}
NPCJosnFile: {fileID: 4900000, guid: 41009f009f0718647a782c7e1aec97dd, type: 3}
LanguageJsonFile: {fileID: 4900000, guid: 62a41129c4663ee41a06274114d28feb, type: 3}
SelectJsonFile: {fileID: 4900000, guid: 3efd15f4195557144a45659d2baa1ba3, type: 3}
TaskJsonFile: {fileID: 4900000, guid: 4dec25769ed4ed3469693b1c881248af, type: 3}
GlobalJsonFile: {fileID: 4900000, guid: 27ecc4e37cb448e45a2611c086cdfb90, type: 3}
SelectsJsonFile: {fileID: 4900000, guid: 3efd15f4195557144a45659d2baa1ba3, type: 3}
--- !u!1 &7695717545649794844
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7695717545649794842}
- component: {fileID: 7695717545649794843}
m_Layer: 0
m_Name: GameObject
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1

View File

@ -2515,7 +2515,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 5e5a05a2a1e8fc54f84494c10939f22a, type: 3}
m_Name:
m_EditorClassIdentifier:
isadministrator: 0
isadministrator: 1
--- !u!114 &423561716
MonoBehaviour:
m_ObjectHideFlags: 0
@ -9492,10 +9492,10 @@ RectTransform:
m_Father: {fileID: 809548982}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 285.6966, y: -138.3536}
m_SizeDelta: {x: 571.3932, y: 276.7072}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1378049913
MonoBehaviour:
@ -9600,10 +9600,10 @@ RectTransform:
m_Father: {fileID: 809548982}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 1464.4829, y: -138.3536}
m_SizeDelta: {x: 571.3932, y: 276.7072}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1408016436
MonoBehaviour:
@ -12950,10 +12950,10 @@ RectTransform:
m_Father: {fileID: 809548982}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 875.0898, y: -138.3536}
m_SizeDelta: {x: 571.3932, y: 276.7072}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1832855453
MonoBehaviour:

View File

@ -58,12 +58,19 @@ public class Response
}
public class loginData
{
public string access_token;
public string userId;
public string scope;
public string openId;
public string companyId;
public string companyName;
public string client_id;
public int expire_in;//toling剩余时间
public string isCreater;//是否是模板创建者Y是则跳蓝湖预定演练01页面开始创建模板N否则跳蓝狐回放1页面
public string access_token;
public string refresh_token;
public int expire_in;
public string refresh_expire_in;
public string client_id;
//public int expire_in;//toling剩余时间
}
public static class GlobalData
{

View File

@ -64,13 +64,14 @@ public class LoginPanel : Base
// 打印 access_token
Debug.Log(serverData.data.access_token);
// 跳转场景
ReadRoom.instance.head();
//如果是管理员账号就跳预定演练
if(loginBody.userType == "company_user")
SceneManager.LoadScene(1);
//if (loginBody.userType == "company_user")
// SceneManager.LoadScene(1);
//如果是玩家账号就跳转到加入房间界面
if (loginBody.userType == "Player")
SceneManager.LoadScene(2);
////如果是玩家账号就跳转到加入房间界面
//if (loginBody.userType == "Player")
// SceneManager.LoadScene(2);
}