PopServerGroup.cs 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.EventSystems;
  5. /// <summary>
  6. /// 选课界面
  7. /// </summary>
  8. public class PopServerGroup : PopBase
  9. {
  10. private ItemListView MItemList;//列表的组件
  11. [SerializeField]
  12. private Game3DButton CancelBtn;//创建普通房间的按钮
  13. protected override void Awake()
  14. {
  15. base.Awake();
  16. MItemList = this.GetComponentInChildren<ItemListView>();
  17. }
  18. protected override void Start()
  19. {
  20. base.Start();
  21. MItemList.InitClick(ItemClick);
  22. CancelBtn.onClick.AddListener(CancelClick);
  23. }
  24. //框体类型
  25. public override PopType MType { get { return PopType.ServerList; } }
  26. protected override void OnDestroy()
  27. {
  28. base.OnDestroy();
  29. CancelBtn.onClick.RemoveListener(CancelClick);
  30. }
  31. public override void Show()
  32. {
  33. base.Show();
  34. RefreshItemList();
  35. }
  36. private bool isPublic;//是否是公开课
  37. public override void Show(object data)
  38. {
  39. base.Show(data);
  40. RefreshItemList();
  41. }
  42. private void RefreshItemList()
  43. {
  44. MItemList.InitInfo(GameServerInfo.Instance.servers.ToArray());
  45. }
  46. private void CancelClick()
  47. {
  48. this.Hide();
  49. MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.Login, null));
  50. }
  51. private void ItemClick(ItemViewBase item)
  52. {
  53. if (item.ItemData == null)
  54. {
  55. return;
  56. }
  57. CDebug.Log("创建课的点击");
  58. ServerData c_data = (ServerData)(item.ItemData);
  59. GameServerInfo.Instance.CurServer = c_data;
  60. this.Hide();
  61. GameNetManager.Instance.mSocketMsgCenter.StartConnect();//启动Socket连接
  62. }
  63. }