123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330 |
- using System;
- using System.Collections.Generic;
- using LitJson;
- using SC.XR.Unity;
- using TMPro;
- using UnityEngine;
- using UnityEngine.UI;
- using static ScenesManager;
- public class RoomFile : RemoteSingleton<RoomFile>
- {
- public Toggle fileToggle;
- public GameObject tubiao1;
- public GameObject tubiao2;
- public GameObject allFile;
- public Button clearAllBtn;
- public GameObject msgRemind;
- public TextMeshProUGUI msgRemindText;
- public TextMeshProUGUI showfileCountText;
- public static int fileUpdataCount = 0;
- public Action<int> UpdataCountAction;
- public static Action<FileConfig> ClickFileItemAction;
- public List<FileConfig> FilePrefabConfigList = new List<FileConfig>();//是否实例化的List
- public static Action<FileConfig> IfFilePrefabConfigListAction;//点击知道是否实例化的监听
- public static Action<FileConfig> ClickOnPrefabAction;
- public static Action<FileConfig> HideChooseKuangAction;
- public static Action<FileConfig> HidefileChooseAction;
- public static Action SetIsOnFalse;
- public Transform PngJpgPoint;
- public Transform PrintscreenPoint;
- public Transform Mp4Point;
- public Transform PdfPoint;
- public Transform ModelPoint;
- public Transform filePos;
- public Transform filePosPoint;
- public int fileIndex;
- private bool isOne = true;
- //public List<Vector3> listFIlePos;
- //public List<Vector3> listFileEur;
- public override void Awake()
- {
- base.Awake();
- // WSHandler.Rtc.OnReceiveFile += ReceiveFile;
- UpdataCountAction += OnUpdataCount;
- //WSHandler.Rtc.OnClearFile += ClearFile;
- //WSHandler.Rtc.OnCoordinate += Coordinate;
- //WSHandler.Rtc.OnSharePrintscreen += ReceiveSharePrintscreen;
- MQTTClient.Instance.OnCoordinate += Coordinate;
- //listFIlePos = new List<Vector3>();
- //listFileEur = new List<Vector3>();
- }
- private void ReceiveSharePrintscreen(JsonData data)
- {
- if (PrintscreenList.Instance)
- {
- PrintscreenList.Instance.AddItem(data);
- }
- }
- private void OnUpdataCount(int num)
- {
- msgRemind.SetActive(true);
- msgRemindText.text = num.ToString();
- }
- private void Start()
- {
- ClickFileItemAction += ClickFileItme;
- fileToggle.onValueChanged.AddListener(OnFileToggleValueChange);
- clearAllBtn.onClick.AddListener(ClickOnClearAllBtn);
- ClearAllfileAction += ClearAllfile;
- WSHandler.Rtc.OnClearFileSucess += ClearFileSucess;
-
- }
- private void ReceiveFile(JsonData data)
- {
- FileConfig fileConfig = new FileConfig();
- fileConfig.PeerId = data["data"]["peerId"].ToString();
- fileConfig.From = data["data"]["from"].ToString();
- fileConfig.CreateTime = data["data"]["createTime"].ToString();
- fileConfig.Url = data["data"]["url"].ToString();
- fileConfig.Path = data["data"]["path"].ToString();
- fileConfig.FileName = data["data"]["fileName"].ToString();
- InstantFileConfig(fileConfig);
- }
- private void InstantFileConfig(FileConfig fileConfig)
- {
- if (FileList.Instance)
- {
- FileList.Instance.AddItem(fileConfig);
- }
- }
- public override void initShow()
- {
- base.initShow();
- HideClearBtn();
- if (FileList.Instance)
- {
- fileUpdataCount = 0;
- FileList.Instance.Init(ShowRoom.Instance.fileConfiglist);
- }
- if (fileToggle)
- {
- fileToggle.isOn = true;
- }
- allFile.SetActive(true);
- tubiao1.SetActive(false);
- tubiao2.SetActive(true);
- msgRemind.SetActive(false);
- fileUpdataCount = 0;
- fileIndex = 0;
- }
- public void ShowClearBtn()
- {
- clearAllBtn.gameObject.SetActive(true);
- //showfileCountText.transform.localPosition = new Vector3(15, 0, 0);
- }
- public void HideClearBtn()
- {
- clearAllBtn.gameObject.SetActive(false);
- //showfileCountText.transform.localPosition = new Vector3(-3, 0, 0);
- }
- private void OnFileToggleValueChange(bool isOn)
- {
- if (isOn)
- {
- allFile.SetActive(true);
- tubiao1.SetActive(false);
- tubiao2.SetActive(true);
- msgRemind.SetActive(false);
- fileUpdataCount = 0;
- }
- else
- {
- allFile.SetActive(false);
- tubiao1.SetActive(true);
- tubiao2.SetActive(false);
- }
- }
- public void ResetToggleValue()
- {
- if (!fileToggle.isOn)
- {
- fileToggle.isOn = true;
- }
- }
- private Action ClearAllfileAction;
- private void ClickOnClearAllBtn()
- {
- PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Pop, RtcStrConfig.clearallFile, "确定", ClearAllfileAction);
- }
- private void ClearAllfile()
- {
- HideClearBtn();
- WSHandler.Rtc.clearFile();
- }
- private void ClearFileSucess(JsonData data)
- {
- if (data["data"]["code"].ToString() == "200")
- {
- ClearAllFileItem();
- }
- }
- private void ClearFile(JsonData data)
- {
- if (data["method"].ToString() == "clearFile")
- {
- ClearAllFileItem();
- }
- }
- public void ClearAllFileItem()
- {
- if (ShowRoom.Instance && ShowRoom.Instance.fileConfiglist != null && ShowRoom.Instance.fileConfiglist.Count > 0)
- {
- ShowRoom.Instance.fileConfiglist.Clear();
- }
- if (FileList.Instance)
- {
- msgRemind.SetActive(false);
- fileUpdataCount = 0;
- FileList.Instance.DestoryAll();
- }
- ClearAllFilePrefab();
- }
- public void ClearAllFilePrefab()
- {
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.DeleteAll();
- }
- if (Mp4List.Instance)
- {
- Mp4List.Instance.DeleteAll();
- }
- if (PdfList.Instance)
- {
- PdfList.Instance.DeleteAll();
- }
- if (ModelList.Instance)
- {
- ModelList.Instance.DeleteAll();
- }
- FilePrefabConfigList.Clear();
- fileIndex = 0;
- }
- private void ClickFileItme(FileConfig fileConfig)
- {
- if (fileConfig != null)
- {
-
- switch (fileConfig.FileType)
- {
- case RoomFileType.png:
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.jpg:
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.jpeg:
- if (PngJpgList.Instance)
- {
- PngJpgList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.mp4:
- if (Mp4List.Instance)
- {
- Mp4List.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.zip:
- if (ModelList.Instance)
- {
- ModelList.Instance.AddItem(fileConfig);
- }
- break;
- case RoomFileType.pdf:
- if (PdfList.Instance)
- {
- PdfList.Instance.AddItem(fileConfig);
- }
- break;
- }
- fileIndex++;
- }
- }
- public Transform GetFilePos()
- {
- if (isOne)
- {
- isOne = false;
- if (filePos.localEulerAngles.y > 90)
- filePos.localEulerAngles = new Vector3(0, -15, 0);
- filePos.localEulerAngles += new Vector3(0, 30, 0);
- }
-
-
- return filePosPoint;
- }
- private void Coordinate(JsonData data)
- {
- string action = data["data"]["action"].ToString();
- switch (action)
- {
- case "10000":
- if (ArrowList.Instance)
- {
- float Valuex = float.Parse(data["data"]["params"]["x"].ToString());
- float Valuey = float.Parse(data["data"]["params"]["y"].ToString());
- ArrowList.Instance.AddArrow(Valuex, Valuey);
- }
- break;
- case "10001":
- if (RemoteRtc.Instance)
- {
- float Valuex = float.Parse(data["data"]["params"]["x"].ToString());
- float Valuey = float.Parse(data["data"]["params"]["y"].ToString());
- //RemoteRtc.Instance.webTex.autoFocusPoint = new Vector2(Valuex, 1 - Valuey);
- //TextMesh textMesh = obj.transform.Find("Text").GetComponent<TextMesh>();
- //textMesh.text = "**" + RemoteRtc.Instance.webTex.autoFocusPoint;
- }
- break;
- }
- }
- private void OnDestroy()
- {
- ClickFileItemAction -= ClickFileItme;
- WSHandler.Rtc.OnReceiveFile -= ReceiveFile;
- UpdataCountAction -= OnUpdataCount;
- ClearAllfileAction -= ClearAllfile;
- WSHandler.Rtc.OnClearFileSucess -= ClearFileSucess;
- WSHandler.Rtc.OnClearFile -= ClearFile;
- WSHandler.Rtc.OnCoordinate -= Coordinate;
- WSHandler.Rtc.OnSharePrintscreen -= ReceiveSharePrintscreen;
- MQTTClient.Instance.OnCoordinate -= Coordinate;
- }
- }
|