PopSubjectGroup.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class PopSubjectGroup : PopBase
  5. {
  6. private ItemListView MItemList;//列表的组件
  7. [SerializeField]
  8. private Game3DButton CancelBtn;//返回按钮
  9. protected override void Awake()
  10. {
  11. base.Awake();
  12. MItemList = this.GetComponentInChildren<ItemListView>();
  13. }
  14. protected override void Start()
  15. {
  16. base.Start();
  17. MItemList.InitClick(ItemClick);
  18. CancelBtn.onClick.AddListener(CancelClick);
  19. }
  20. public override PopType MType { get { return PopType.SubjectList; } }
  21. public override void Show()
  22. {
  23. base.Show();
  24. GamePlayerData.Instance.CreateRoomdata = new SocketRoomItemData();
  25. RefreshItemList();
  26. }
  27. protected override void OnDestroy()
  28. {
  29. base.OnDestroy();
  30. CancelBtn.onClick.RemoveListener(CancelClick);
  31. }
  32. private void ItemClick(ItemViewBase item)
  33. {
  34. if (item.ItemData == null)
  35. {
  36. return;
  37. }
  38. SubjectData c_data = (SubjectData)(item.ItemData);
  39. CDebug.Log("科目的点击 " + c_data.subject_name + c_data.id);
  40. this.Hide();
  41. NormalUIData data = new NormalUIData();
  42. data.str = c_data.id;
  43. MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.CourseList, data));
  44. }
  45. private void RefreshItemList()
  46. {
  47. List<System.Object> data = new List<System.Object>();
  48. SubjectData[] datas = GameConfigData.Instance.course_data.SubjectDatas;
  49. for(int i = 0; i< GameConfigData.Instance.course_data.SubjectDatas.Length; i ++)
  50. {
  51. int test_id = int.Parse(GameConfigData.Instance.course_data.SubjectDatas[i].id);
  52. if (CheckUnLock(test_id))
  53. {
  54. data.Add(GameConfigData.Instance.course_data.SubjectDatas[i]);
  55. }
  56. }
  57. MItemList.InitInfo(data.ToArray());
  58. }
  59. private bool CheckUnLock(int check_id)
  60. {
  61. return GameConfigData.Instance.course_data.SubVisiable(check_id);
  62. }
  63. private void CancelClick()
  64. {
  65. this.Hide();
  66. MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.RoomList, null));
  67. }
  68. private NormalUIData CurData
  69. {
  70. get { return UICanshu as NormalUIData; }
  71. }
  72. }