12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System.Collections.Generic;
- using Blue;
- using Newtonsoft.Json;
- using UnityEngine;
- using UnityEngine.UI;
- /// <summary>
- /// 舍弃InviteDlg
- /// </summary>
- public class InviteUserPanel : SingletonMonobehaviour<InviteUserPanel>
- {
- public Button mCall_Btn;
- public Button mClose_Btn;
- public Dictionary<int, RTCUserInfo> InviteUserDic = new Dictionary<int, RTCUserInfo>(); // 邀请用户的字典
- public List<InviteUserItem> InitDataList = new List<InviteUserItem>();
- 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<RoomOtherUserPanel>().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<Toggle>();
- if (toggle.isOn) toggle.isOn = false;
- }
- }
- }
|