using System.Collections.Generic; using Blue; using Newtonsoft.Json; using UnityEngine; using UnityEngine.UI; /// /// 舍弃InviteDlg /// public class InviteUserPanel : SingletonMonobehaviour { public Button mCall_Btn; public Button mClose_Btn; public Dictionary InviteUserDic = new Dictionary(); // 邀请用户的字典 public List InitDataList = new List(); void Start() { mClose_Btn.onClick.AddListener(ClickOnClose); mCall_Btn.onClick.AddListener(ClickOnInvite); } private void OnEnable() { for (int i = 0; i < InitDataList.Count; i++) { InitDataList[i].InitData(null, InitDataList[i].mCurrentRTCUserInfo); InitDataList[i].toggle.isOn = false; } } public void TestInitData() { for (int i = 0; i < InitDataList.Count; i++) { RTCUserInfo RTCUserInfo = new RTCUserInfo() { UserID = 600000 + i, UserName = "韩" + i.ToString(), Level = "组" + i.ToString(), }; if (i % 3 == 0) RTCUserInfo.State = "0"; else if (i % 3 == 1) RTCUserInfo.State = "1"; else if (i % 3 == 2) RTCUserInfo.State = "2"; InitDataList[i].InitData(null, RTCUserInfo); } } private string mInviteUserIDList; private void ClickOnInvite() { string json = JsonConvert.SerializeObject(InviteUserDic.Values); Debug.LogError($"ClickOnInvite:邀请指定用户,{json}"); RTCRoomMain.Instance.mRoomOtherUser.SetActive(true); RTCRoomMain.Instance.mRoomOtherUser.GetComponent().ExeCuteInvite(InviteUserDic); this.gameObject.SetActive(false); } private void ClickOnClose() { // TODO : 关闭邀请 this.gameObject.SetActive(false); } public void SelectInviteUser(RTCUserInfo mCurrentRTCUserInfo, bool isOn) { if (isOn) { if (!InviteUserDic.ContainsKey(mCurrentRTCUserInfo.UserID)) InviteUserDic.Add(mCurrentRTCUserInfo.UserID, mCurrentRTCUserInfo); } else { if (InviteUserDic.ContainsKey(mCurrentRTCUserInfo.UserID)) InviteUserDic.Remove(mCurrentRTCUserInfo.UserID); } foreach (RTCUserInfo RTCUserInfo in InviteUserDic.Values) { Debug.LogError($"选择了{RTCUserInfo.UserName},ID为:{RTCUserInfo.UserID}"); } } public void Reset() { InviteUserDic.Clear(); foreach (InviteUserItem item in InitDataList) // 选择用户面板的勾 { Toggle toggle = item.GetComponent(); if (toggle.isOn) toggle.isOn = false; } } }