using ShadowStudio.Mgr;
using ShadowStudio.Model;
using ShadowStudio.UI;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using Vuforia;
using XRTool.Util;
using XRTool.WorldUI;
public class ItemUserView : MonoBehaviour
{
public Peer _peer;
public MeshRenderer videoBG;
public Text nametext;
public XRIcon touxiang;
public Button bigBtn;
// Start is called before the first frame update
void Start()
{
bigBtn.onClick.AddListener(OnClickBigBtn);
}
private void OnClickBigBtn()
{
if (ShowViewMgr.Instance)
{
PlayerViewComponent.CreateViewComponent(this._peer.PeerId, ShowViewMgr.Instance.Target);
}
}
private void Update()
{
checkPeer();
StateUpdata();
}
void checkPeer()
{
if (cPeer == null && _peer != null)
{
cPeer = AgoraRTCManager.Instance.GetCustomPeer(_peer.PeerId);
_peer.AgoraCustomPeer = cPeer;
}
}
void StateUpdata()
{
if (cPeer == null)
return;
// Debug.Log(cPeer.peerId + " " + cPeer.isVideo + cPeer.isOpenVideo + cPeer.isAudio + cPeer.isOpenAduio);
if (cPeer.isVideo)
{
if (cPeer.isOpenVideo)
{
openVideo.SetActive(false);
closeVideo.SetActive(false);
pauseVideo.SetActive(true);
}
else
{
openVideo.SetActive(false);
closeVideo.SetActive(true);
pauseVideo.SetActive(false);
}
}
else
{
openVideo.SetActive(true);
closeVideo.SetActive(false);
pauseVideo.SetActive(false);
}
if (cPeer.isAudio)
{
if (cPeer.isOpenAduio)
{
openAudio.SetActive(false);
closeAudio.SetActive(false);
pauseAudio.SetActive(true);
}
else
{
openAudio.SetActive(false);
closeAudio.SetActive(true);
pauseAudio.SetActive(false);
}
}
else
{
openAudio.SetActive(true);
closeAudio.SetActive(false);
pauseAudio.SetActive(false);
}
}
AgoraCustomPeer cPeer;
public void Init(Peer peer)
{
Debug.Log("123213Init213213"+ peer.Avatar);
_peer = peer;
nametext.text = peer.NickName;
textMic.text = "0.02";
VolumnGo.SetActive(false);
if (!string.IsNullOrEmpty(peer.Avatar))
{
for (int i = 0; i < CommonMethod.UserAvatarsList.Count; i++)
{
if (peer.Avatar == CommonMethod.UserAvatarsList[i].Url)
{
string path = "Avatar/" + CommonMethod.UserAvatarsList[i].Id + "Avatar";
touxiang.icon = Resources.Load(path) as Texture2D;
touxiang.AutoSetSprite();
}
}
}
if (_peer.IsSlef)
{
nametext.text = "" + peer.NickName + "";
openAudio.GetComponent().color = new Color(255, 0, 0, 255);
openVideo.GetComponent().color = new Color(255, 0, 0, 255);
Invoke("checkAudio", 0.5f);
// Invoke("checkVideo", 1f);
}
}
public GameObject openAudio;
public GameObject closeAudio;
public GameObject VolumnGo;
public float volume = 0.2f;
public Text textMic;
public void addMic()
{
volume += 0.1f;
}
public void redMic()
{
volume -= 0.1f;
}
public GameObject pauseCerAudio;
public GameObject pauseCerVideo;
public GameObject pauseAudio;
public GameObject pauseVideo;
public GameObject openVideo;
public GameObject closeVideo;
public void openMic()
{
if (_peer.IsSlef)
{
AgoraRTCManager.Instance.MuteLocalAudioStream(true);
}
else
{
AgoraRTCManager.Instance.MuteRemoteAudioStream(cPeer.peerId, true);
}
}
public void closeMic()
{
if (_peer.IsSlef)
{
AgoraRTCManager.Instance.MuteLocalAudioStream(false);
}
else
{
AgoraRTCManager.Instance.MuteRemoteAudioStream(cPeer.peerId, false);
}
}
public void OpenVideo()
{
if (_peer.IsSlef)
{
AgoraRTCManager.Instance.MuteLocalVideoStream(true);
}
else
{
AgoraRTCManager.Instance.MuteRemoteVideoStream(cPeer.peerId, true);
}
}
public void CloseVideo()
{
if (_peer.IsSlef)
{
AgoraRTCManager.Instance.MuteLocalVideoStream(false);
}
else
{
AgoraRTCManager.Instance.MuteRemoteVideoStream(cPeer.peerId, false);
}
}
}