using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class PeerView : BaseView { public Text tName; public RawImage mViewTexture; public Button mainBtn; public GameObject user; //public GameObject add; public SysEnterManager sysEenter; public CustomPeer cPeer; //public Button addBtn; private InviteUserConfig inviteUserConfig; private float alltime = 30f; private bool istime = false; public Texture texture; public GameObject ChooseKuang; private void ShowChooseKuang(string id) { if (id == cPeer.peerId) { ChooseKuang.SetActive(true); if (ShowUserMsg.Instance) { ShowUserMsg.Instance.Init(this.cPeer); } } else { ChooseKuang.SetActive(false); } } private void Update() { if (istime) { alltime -= Time.deltaTime; if (alltime <= 0) { istime = false; alltime = 30f; if (this.inviteUserConfig != null) { //if (InviteDlg.Instance && InviteDlg.Instance.InvitingUnionIdList.Contains(this.inviteUserConfig)) //{ // PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Tip, this.inviteUserConfig.NickName + "无应答"); // InviteDlg.Instance.InvitingUnionIdList.Remove(this.inviteUserConfig); // RoomOtherUser.Instance.UpdateList(); //} } } } else { alltime = 30f; } } public override void Init(int i, BaseConfig c, int vi) { base.Init(i, c, vi); mainBtn.onClick.RemoveAllListeners(); mainBtn.onClick.AddListener(setBigView); if (c is PeerConfig) { if (this.inviteUserConfig != null) { this.inviteUserConfig = null; } user.SetActive(true); //add.SetActive(false); sysEenter.gameObject.SetActive(true); cPeer = (c as PeerConfig).peer; sysEenter.cPeer = cPeer; tName.text = cPeer.name; if (!cPeer.isSn) { if (!string.IsNullOrEmpty(cPeer.avater)) { NetWorkHeaders.Instance.getNetTexture(cPeer.avater, null, (Texture tex) => { mViewTexture.texture = tex; }); } else { if (UserInfo.defaulttextIcon != null) { mViewTexture.texture = UserInfo.defaulttextIcon; } } } else { NetWorkHeaders.GetUserAvater((aData) => { for (int j = 0; j < aData["data"]["sn"].Count; j++) { NetWorkHeaders.Instance.getNetTexture(aData["data"]["sn"][j].ToString(), null, (Texture tex) => { mViewTexture.texture = tex; }); } }); } cPeer.onChangeInfo -= OnChangeInfo; cPeer.onChangeInfo += OnChangeInfo; cPeer.onChangeTexture -= onChangeTexture; cPeer.onChangeTexture += onChangeTexture; cPeer.onChangeName -= onChangeName; cPeer.onChangeName += onChangeName; RoomOtherUser.ShowAction -= ShowChooseKuang; RoomOtherUser.ShowAction += ShowChooseKuang; if (RoomMainForms.userId == RoomMainForms.NOUSER) { RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId); } alltime = 30f; istime = false; } else if (c is InviteUserConfig) { if (cPeer != null) { cPeer = null; } this.inviteUserConfig = c as InviteUserConfig; user.SetActive(true); //add.SetActive(false); tName.text = "等待进入..."; sysEenter.gameObject.SetActive(false); if (this.inviteUserConfig != null && !string.IsNullOrEmpty(inviteUserConfig.Avatar)) { NetWorkHeaders.Instance.getNetTexture(inviteUserConfig.Avatar, null, (Texture tex) => { mViewTexture.texture = tex; }); } else { if (UserInfo.defaulttextIcon != null) { mViewTexture.texture = UserInfo.defaulttextIcon; } } alltime = 30f; istime = true; } //else //{ // user.SetActive(false); // add.SetActive(true); // alltime = 30f; // istime = false; //} AgoraVideoAudioManager.Instance.listCustomPeer.Add(cPeer); } void onChangeTexture() { if (RoomMainForms.userId == cPeer.peerId) { RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId); } } void onChangeName(string cName) { tName.text = cName; } public void setBigView() { if (cPeer == null) { return; } RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId); RoomMainForms.Instance.ClickOnCloseCoordinate(); //RoomOtherUser.ShowAction?.Invoke(cPeer.peerId); // AgoraVideoAudioManager.Instance.AddListShowView(cPeer.peerId, RoomMainForms.Instance.bigView); } private void ClickAdd() { //if (ShowRoom.Instance) //{ // ShowRoom.Instance.window[4].SetActive(true); // if (InviteDlg.Instance) // { // InviteDlg.Instance.ShowHistory(); // } //} } private void OnChangeInfo(string type, string id) { if (type == "video") { if (cPeer.isVideo) { if (cPeer.isCloseVideo) { RemoteRtc.Instance.closeRev(cPeer.cIdV); } } if (RoomMainForms.userId == cPeer.peerId) { Debug.Log("开启大视频"); RoomMainForms.Instance.setBigView(cPeer.tex, cPeer.peerId); } } else { if (cPeer.isAudio) { if (cPeer.isCloseAudio) { RemoteRtc.Instance.closeRev(cPeer.cIdA); } } } } public void OpenVideo() { if (cPeer != null && cPeer.isVideo && cPeer.cIdV != "" && cPeer.isCloseVideo) { RemoteRtc.Instance.startRev(cPeer.cIdV); //cPeer.isCloseVideo = false; } cPeer.isCloseVideo = false; AgoraVideoAudioManager.Instance.MuteRemoteVideoStream(cPeer.peerId, false); } public void CloseVideo() { if (cPeer != null && cPeer.isVideo && cPeer.cIdV != "" && !cPeer.isCloseVideo) { RemoteRtc.Instance.closeRev(cPeer.cIdV); // cPeer.isCloseVideo = true; } cPeer.isCloseVideo = true; AgoraVideoAudioManager.Instance.MuteRemoteVideoStream(cPeer.peerId, true); } public void openMic() { if (cPeer != null && cPeer.isAudio && cPeer.cIdA != "" && cPeer.isCloseAudio) { RemoteRtc.Instance.startRev(cPeer.cIdA); cPeer.isCloseAudio = false; } AgoraVideoAudioManager.Instance.MuteRemoteAudioStream(cPeer.peerId, false); cPeer.isCloseAudio = false; } public void closeMic() { if (cPeer != null && cPeer.isAudio && cPeer.cIdA != "" && !cPeer.isCloseAudio) { RemoteRtc.Instance.closeRev(cPeer.cIdA); cPeer.isCloseAudio = true; } AgoraVideoAudioManager.Instance.MuteRemoteAudioStream(cPeer.peerId, true); cPeer.isCloseAudio = true; } public void ChangeVideo( bool isVideo) { cPeer.isVideo = isVideo; } public void ChangeAudio(bool isAudio) { cPeer.isAudio = isAudio; } }