using System; using System.Collections.Generic; using LitJson; using SC.XR.Unity; using UnityEngine; using static ScenesManager; public class ShowRoom : RemoteSingleton { public List fileConfiglist = new List(); 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(); } } 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(); } } }