FreeModeItemList.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using wf;
  5. public class FreeModeItemList : MonoBehaviour
  6. {
  7. public void Awake()
  8. {
  9. this.grid_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents/Grid", false).GetComponent<UIGrid>();
  10. this.scroll_view_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents", false).GetComponent<UIScrollView>();
  11. this.tab_pabel_ = UTY.GetChildObject(base.gameObject, "ListParent/MaskGroup/Contents/Grid", false).GetComponent<UIWFTabPanel>();
  12. this.info_label_ = UTY.GetChildObject(base.gameObject, "DetailParent/DetailBlock/Text", false).GetComponent<UILabel>();
  13. UIGrid component = UTY.GetChildObject(base.gameObject, "DetailParent/ConditionBlock/GridParent", false).GetComponent<UIGrid>();
  14. List<Transform> childList = component.GetChildList();
  15. for (int i = 0; i < childList.Count; i++)
  16. {
  17. this.condition_label_list_.Add(UTY.GetChildObject(childList[i].gameObject, "Message", false).GetComponent<UILabel>());
  18. }
  19. }
  20. public bool SetList(AbstractFreeModeItem[] item_list)
  21. {
  22. if (0 < this.grid_.gameObject.transform.childCount || item_list == null || item_list.Length <= 0)
  23. {
  24. return false;
  25. }
  26. this.select_item_data_ = null;
  27. UIWFTabButton uiwftabButton = null;
  28. for (int i = 0; i < item_list.Length; i++)
  29. {
  30. GameObject gameObject = Utility.CreatePrefab(this.grid_.gameObject, "SceneFreeModeSelect/FreeModeItemButton", true);
  31. UTY.GetChildObject(gameObject, "Name", false).GetComponent<UILabel>().text = item_list[i].title;
  32. UIWFTabButton component = gameObject.GetComponent<UIWFTabButton>();
  33. component.isEnabled = false;
  34. EventDelegate.Add(component.onSelect, new EventDelegate.Callback(this.OnSelectItem));
  35. UIEventTrigger component2 = gameObject.GetComponent<UIEventTrigger>();
  36. EventDelegate eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  37. eventDelegate.parameters[0].value = component;
  38. EventDelegate.Add(component2.onHoverOver, eventDelegate);
  39. EventDelegate.Add(component2.onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
  40. component2 = UTY.GetChildObject(gameObject, "HitRect", false).GetComponent<UIEventTrigger>();
  41. eventDelegate = new EventDelegate(this, "OnMouseHoverIn");
  42. eventDelegate.parameters[0].value = component;
  43. EventDelegate.Add(component2.onHoverOver, eventDelegate);
  44. EventDelegate.Add(component2.onHoverOut, new EventDelegate.Callback(this.OnMouseHoverOut));
  45. bool is_enabled = item_list[i].is_enabled;
  46. if (is_enabled)
  47. {
  48. component.isEnabled = true;
  49. UTY.GetChildObject(gameObject, "HitRect", false).SetActive(false);
  50. if (uiwftabButton == null)
  51. {
  52. uiwftabButton = component;
  53. }
  54. }
  55. else
  56. {
  57. component.isEnabled = false;
  58. UTY.GetChildObject(gameObject, "HitRect", false).SetActive(true);
  59. }
  60. this.item_obj_dic_.Add(gameObject, item_list[i]);
  61. }
  62. this.grid_.Reposition();
  63. this.scroll_view_.ResetPosition();
  64. this.tab_pabel_.UpdateChildren();
  65. if (uiwftabButton != null)
  66. {
  67. this.tab_pabel_.Select(uiwftabButton);
  68. }
  69. this.UpdateInfo(this.select_item_data_);
  70. return uiwftabButton != null;
  71. }
  72. public void OnSelectItem()
  73. {
  74. if (!UIWFTabButton.current.isSelected || !this.item_obj_dic_.ContainsKey(UIWFTabButton.current.gameObject))
  75. {
  76. return;
  77. }
  78. this.select_item_data_ = this.item_obj_dic_[UIWFTabButton.current.gameObject];
  79. this.UpdateInfo(this.select_item_data_);
  80. }
  81. private void OnMouseHoverIn(UIWFTabButton tab_btn)
  82. {
  83. this.UpdateInfo(this.item_obj_dic_[tab_btn.gameObject]);
  84. }
  85. private void OnMouseHoverOut()
  86. {
  87. this.UpdateInfo(this.select_item_data_);
  88. }
  89. public void UpdateInfo(AbstractFreeModeItem select_item_dat)
  90. {
  91. if (select_item_dat == null)
  92. {
  93. this.info_label_.text = string.Empty;
  94. for (int i = 0; i < this.condition_label_list_.Count; i++)
  95. {
  96. this.condition_label_list_[i].transform.parent.gameObject.SetActive(false);
  97. }
  98. }
  99. else
  100. {
  101. this.info_label_.text = select_item_dat.text;
  102. for (int j = 0; j < this.condition_label_list_.Count; j++)
  103. {
  104. if (j < select_item_dat.condition_texts.Length)
  105. {
  106. this.condition_label_list_[j].transform.parent.gameObject.SetActive(true);
  107. this.condition_label_list_[j].text = select_item_dat.condition_texts[j];
  108. }
  109. else
  110. {
  111. this.condition_label_list_[j].transform.parent.gameObject.SetActive(false);
  112. }
  113. }
  114. }
  115. }
  116. public AbstractFreeModeItem select_item_data
  117. {
  118. get
  119. {
  120. return this.select_item_data_;
  121. }
  122. set
  123. {
  124. this.select_item_data_ = value;
  125. }
  126. }
  127. private Dictionary<GameObject, AbstractFreeModeItem> item_obj_dic_ = new Dictionary<GameObject, AbstractFreeModeItem>();
  128. private UIGrid grid_;
  129. private UIScrollView scroll_view_;
  130. private UIWFTabPanel tab_pabel_;
  131. private UILabel info_label_;
  132. private List<UILabel> condition_label_list_ = new List<UILabel>();
  133. private AbstractFreeModeItem select_item_data_;
  134. }