12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PopSubjectGroup : PopBase
- {
- private ItemListView MItemList;//列表的组件
- [SerializeField]
- private Game3DButton CancelBtn;//返回按钮
- protected override void Awake()
- {
- base.Awake();
- MItemList = this.GetComponentInChildren<ItemListView>();
- }
- protected override void Start()
- {
- base.Start();
- MItemList.InitClick(ItemClick);
- CancelBtn.onClick.AddListener(CancelClick);
- }
- public override PopType MType { get { return PopType.SubjectList; } }
- public override void Show()
- {
- base.Show();
- GamePlayerData.Instance.CreateRoomdata = new SocketRoomItemData();
- RefreshItemList();
- }
- protected override void OnDestroy()
- {
- base.OnDestroy();
- CancelBtn.onClick.RemoveListener(CancelClick);
- }
- private void ItemClick(ItemViewBase item)
- {
- if (item.ItemData == null)
- {
- return;
- }
- SubjectData c_data = (SubjectData)(item.ItemData);
- CDebug.Log("科目的点击 " + c_data.subject_name + c_data.id);
- this.Hide();
- NormalUIData data = new NormalUIData();
- data.str = c_data.id;
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.CourseList, data));
- }
- private void RefreshItemList()
- {
- List<System.Object> data = new List<System.Object>();
- SubjectData[] datas = GameConfigData.Instance.course_data.SubjectDatas;
- for(int i = 0; i< GameConfigData.Instance.course_data.SubjectDatas.Length; i ++)
- {
- int test_id = int.Parse(GameConfigData.Instance.course_data.SubjectDatas[i].id);
- if (CheckUnLock(test_id))
- {
- data.Add(GameConfigData.Instance.course_data.SubjectDatas[i]);
- }
- }
- MItemList.InitInfo(data.ToArray());
- }
- private bool CheckUnLock(int check_id)
- {
- return GameConfigData.Instance.course_data.SubVisiable(check_id);
- }
- private void CancelClick()
- {
- this.Hide();
- MessageCenterController.Instance.Broadcast(GameEnum.MESSAGE_SHOW_POP_BY_TYPE, new ShowPopData(PopType.RoomList, null));
- }
- private NormalUIData CurData
- {
- get { return UICanshu as NormalUIData; }
- }
- }
|