RoomOtherUserItem.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. using Blue;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using TMPro;
  5. using UnityEngine;
  6. public class RoomOtherUserItem : MonoBehaviour, IController
  7. {
  8. public TMP_Text mName;
  9. private RTCUserInfo mRTCUserInfo;
  10. public List<GameObject> TestBtn;
  11. private bool IsEnter = false;
  12. private void Start()
  13. {
  14. }
  15. /// <summary>
  16. /// 初始化
  17. /// </summary>
  18. /// <param name="RTCUserInfo"></param>
  19. /// <param name="active">主动进入</param>
  20. public void Init(RTCUserInfo RTCUserInfo,bool active=false)
  21. {
  22. mName.text = "待加入";
  23. mRTCUserInfo = RTCUserInfo;
  24. if(active)
  25. {
  26. foreach(GameObject go in TestBtn)
  27. {
  28. go.SetActive(false);
  29. }
  30. mName.text = mRTCUserInfo.UserName;
  31. mRTCUserInfo.State = "2";
  32. IsEnter = true;
  33. }
  34. }
  35. private void OnEnable()
  36. {
  37. StartCoroutine(Close());
  38. }
  39. private IEnumerator Close()
  40. {
  41. yield return new WaitForSeconds(10);
  42. if(!IsEnter)
  43. TestRefuse();
  44. }
  45. public void TestEnter()
  46. {
  47. mName.text = mRTCUserInfo.UserName;
  48. mRTCUserInfo.State = "2";
  49. this.SendCommand(new OtherUserJoinRoomCommand(mRTCUserInfo));
  50. IsEnter = true;
  51. }
  52. public void TestRefuse()
  53. {
  54. Destroy(gameObject);
  55. this.SendCommand(new NoEnterRoomCommand(mRTCUserInfo.UserID));
  56. }
  57. public void TestResponse()
  58. {
  59. Destroy(gameObject);
  60. this.SendCommand(new NoEnterRoomCommand(mRTCUserInfo.UserID));
  61. }
  62. }