123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247 |
- using System;
- using System.Collections.Generic;
- using LitJson;
- using SC.XR.Unity;
- using UnityEngine;
- using static ScenesManager;
- public class ShowRoom : RemoteSingleton<ShowRoom>
- {
- public List<FileConfig> fileConfiglist = new List<FileConfig>();
- public SCButton showMainScreenBtn;
- public override void Awake()
- {
- base.Awake();
- GameObject showMainScreenBtnObj = Resources.Load("ZhankaiBtn") as GameObject;
- showMainScreenBtnObj = Instantiate(showMainScreenBtnObj, this.transform);
- if (showMainScreenBtnObj)
- {
- showMainScreenBtn = showMainScreenBtnObj.transform.GetComponent<SCButton>();
- }
- }
- private void Start()
- {
- WSHandler.Office.OnRefuse += Refuse;
- WSHandler.Office.OnTimeout += TimeoutRefuse;
- if (showMainScreenBtn)
- {
- showMainScreenBtn.onClick.AddListener(ShowMainScreen);
- }
- }
- private void Refuse(JsonData data)
- {
- string peerId = data["data"]["peerId"].ToString();
- string nickName = data["data"]["nickName"].ToString();
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, nickName+"拒绝了你的邀请");
- if (!string.IsNullOrEmpty(peerId) && InviteDlg.Instance)
- {
- for (int i = InviteDlg.Instance.InvitingUnionIdList.Count - 1; i >= 0; i--)
- {
- if (peerId == InviteDlg.Instance.InvitingUnionIdList[i].UnionId)
- {
- InviteDlg.Instance.InvitingUnionIdList.Remove(InviteDlg.Instance.InvitingUnionIdList[i]);
- }
- }
- }
- RoomOtherUser.Instance.UpdateList();
- }
- private void TimeoutRefuse(JsonData data)
- {
- string peerId = data["data"]["peerId"].ToString();
- string nickName = data["data"]["nickName"].ToString();
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, nickName + "无应答");
- if (!string.IsNullOrEmpty(peerId) && InviteDlg.Instance)
- {
- for (int i = InviteDlg.Instance.InvitingUnionIdList.Count - 1; i >= 0; i--)
- {
- if (peerId == InviteDlg.Instance.InvitingUnionIdList[i].UnionId)
- {
- InviteDlg.Instance.InvitingUnionIdList.Remove(InviteDlg.Instance.InvitingUnionIdList[i]);
- }
- }
- }
- RoomOtherUser.Instance.UpdateList();
- }
- public void ShowMainScreen()
- {
- if (RoomInfo.Instance)
- {
- RoomInfo.Instance.gameObject.SetActive(true);
- }
- if (RoomMain.Instance)
- {
- RoomMain.Instance.gameObject.SetActive(true);
- }
- if (RoomOtherUser.Instance)
- {
- RoomOtherUser.Instance.gameObject.SetActive(true);
- }
- if (RoomFile.Instance)
- {
- RoomFile.Instance.gameObject.SetActive(true);
- }
- showMainScreenBtn.gameObject.SetActive(false);
- }
- public void HideMainScreen()
- {
- if (RoomInfo.Instance)
- {
- RoomInfo.Instance.gameObject.SetActive(false);
- }
- if (RoomMain.Instance)
- {
- RoomMain.Instance.gameObject.SetActive(false);
- }
- if (RoomOtherUser.Instance)
- {
- RoomOtherUser.Instance.gameObject.SetActive(false);
- }
- if (RoomFile.Instance)
- {
- RoomFile.Instance.gameObject.SetActive(false);
- }
- showMainScreenBtn.gameObject.SetActive(true);
- }
- public void ExitRoom()
- {
- if (PopPeerView.Instance && PopPublic.Instance && PopPeerView.Instance.list.parent != PopPublic.Instance.transform)
- {
- PopPeerView.Instance.list.position = new Vector3(0, 0, 0);
- PopPeerView.Instance.list.eulerAngles = new Vector3(0, 0, 0);
- PopPeerView.Instance.list.SetParent(PopPublic.Instance.transform);
- }
- if (PopUpInfo.Instance && PopPublic.Instance && PopUpInfo.Instance.transform.parent != PopPublic.Instance.transform)
- {
- PopUpInfo.Instance.transform.position = new Vector3(0, 0, 0);
- PopUpInfo.Instance.transform.eulerAngles = new Vector3(0, 0, 0);
- PopUpInfo.Instance.transform.SetParent(PopPublic.Instance.transform);
- }
- API_GSXR_Slam.GSXR_Reset_Slam();
- if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList != null)
- {
- if (InviteDlg.Instance.InvitingUnionIdList.Count > 0)
- {
- InviteDlg.Instance.InvitingUnionIdList.Clear();
- }
- }
- if (RoomFile.Instance)
- {
- RoomFile.Instance.ClearAllFileItem();
- }
- if (ArrowList.Instance)
- {
- ArrowList.Instance.DeleteAll();
- }
- if (PrintscreenList.Instance)
- {
- PrintscreenList.Instance.DeleteAll();
- }
- if (PopPeerView.Instance)
- {
- PopPeerView.Instance.DestoryAll();
- }
- ShowMainScreen();
- if (PopCall.Instance)
- {
- PopCall.Instance.gameObject.SetActive(false);
- }
- transform.position = new Vector3(0, 0, 0);
- transform.eulerAngles = new Vector3(0, 0, 0);
- if (GameStart.Instance && GameStart.Instance.systemMenu)
- {
- GameStart.Instance.systemMenu.ResetPattern();
- }
- }
- public void NetErrorExitRoom()
- {
- if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList != null)
- {
- if (InviteDlg.Instance.InvitingUnionIdList.Count > 0)
- {
- InviteDlg.Instance.InvitingUnionIdList.Clear();
- }
- }
- if (RoomFile.Instance)
- {
- RoomFile.Instance.ClearAllFileItem();
- }
- if (ArrowList.Instance)
- {
- ArrowList.Instance.DeleteAll();
- }
- if (PrintscreenList.Instance)
- {
- PrintscreenList.Instance.DeleteAll();
- }
- if (PopPeerView.Instance)
- {
- PopPeerView.Instance.DestoryAll();
- }
- ShowMainScreen();
- if (PopCall.Instance)
- {
- PopCall.Instance.gameObject.SetActive(false);
- }
- if (GameStart.Instance && GameStart.Instance.systemMenu)
- {
- GameStart.Instance.systemMenu.ResetPattern();
- }
- }
- private void OnDestroy()
- {
- WSHandler.Office.OnRefuse -= Refuse;
- WSHandler.Office.OnTimeout -= TimeoutRefuse;
- }
- public override void initShow()
- {
- base.initShow();
- ScenesManager.Instance.initRoom();
- RoomOtherUser.Instance.UpdateList();
- window[4].SetActive(false);
- if (GameStart.Instance && GameStart.Instance.systemMenu)
- {
- GameStart.Instance.systemMenu.Init();
- }
- }
- public void Reset()
- {
- RoomFile.SetIsOnFalse?.Invoke();
- if (ArrowList.Instance)
- {
- ArrowList.Instance.DeleteAll();
- }
- if (PrintscreenList.Instance)
- {
- PrintscreenList.Instance.DeleteAll();
- }
- //transform.position = new Vector3(-0.2f, 0, 0);
- //transform.eulerAngles = new Vector3(0, -30, 0);
- transform.position = new Vector3(0, 0, 0);
- transform.eulerAngles = new Vector3(0, 0, 0);
- ShowMainScreen();
- PopPeerView.CloseView?.Invoke();
- if (RoomFile.Instance)
- {
- RoomFile.Instance.ClearAllFilePrefab();
- RoomFile.Instance.ResetToggleValue();
- }
- if (RoomInfo.Instance)
- {
- RoomInfo.Instance.ResetChatText();
- }
- }
- }
|