FacilityUIPowerUpMaterialList.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using UnityEngine;
  3. using UnityEngine.EventSystems;
  4. using UnityEngine.UI;
  5. public class FacilityUIPowerUpMaterialList : MonoBehaviour
  6. {
  7. private FacilityManager FacilityMgr
  8. {
  9. get
  10. {
  11. if (this.m_FacilityMgr == null)
  12. {
  13. this.m_FacilityMgr = GameMain.Instance.FacilityMgr;
  14. }
  15. return this.m_FacilityMgr;
  16. }
  17. }
  18. public void Show(int id, Facility facility, Action<int[]> callbackSelect)
  19. {
  20. this.m_CallbackSelect = callbackSelect;
  21. this.SetupFacilityPowerUpMaterialListDropDown(id, facility);
  22. }
  23. private void SetupFacilityPowerUpMaterialListDropDown(int id, Facility facility)
  24. {
  25. FacilityUIPowerUpMaterialList.<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey0 <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey = new FacilityUIPowerUpMaterialList.<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey0();
  26. <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.$this = this;
  27. this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(true);
  28. this.DeleteDropdown();
  29. Facility.PowerUpRecipe facilityPowerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(id);
  30. <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.materialCategoryIDArray = facilityPowerUpRecipe.materialCategoryIDArray;
  31. <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.recipeData = facility.GetRecipeData(id);
  32. this.m_uGUIListViewer.Show<Transform>(<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.materialCategoryIDArray.Length, delegate(int i, Transform trans)
  33. {
  34. int num = <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.materialCategoryIDArray[i];
  35. Dropdown componentInChildren = trans.GetComponentInChildren<Dropdown>();
  36. Text[] componentsInChildren = trans.GetComponentsInChildren<Text>();
  37. FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial dropdownPowerUpMaterial = trans.gameObject.AddComponent<FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial>();
  38. string facilityPowerUpMaterialCategoryName = FacilityDataTable.GetFacilityPowerUpMaterialCategoryName(num);
  39. componentsInChildren[0].text = facilityPowerUpMaterialCategoryName;
  40. componentsInChildren[1].text = string.Format("CATEGORY{0}", i + 1);
  41. componentInChildren.ClearOptions();
  42. Facility.PowerUpMaterial[] materialArray = <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.$this.FacilityMgr.GetFacilityPowerUpItemEnableArray(num);
  43. if (materialArray.Length > 0)
  44. {
  45. for (int j = 0; j < materialArray.Length; j++)
  46. {
  47. componentInChildren.options.Add(new Dropdown.OptionData(materialArray[j].name));
  48. if (<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.recipeData.materialIDArray[i] == materialArray[j].id)
  49. {
  50. dropdownPowerUpMaterial.materialID = materialArray[j].id;
  51. componentInChildren.value = j;
  52. }
  53. }
  54. }
  55. else
  56. {
  57. componentInChildren.image.raycastTarget = false;
  58. dropdownPowerUpMaterial.materialID = 0;
  59. componentInChildren.options.Add(new Dropdown.OptionData("無し"));
  60. }
  61. if (dropdownPowerUpMaterial.materialID == 0)
  62. {
  63. if (materialArray.Length > 0)
  64. {
  65. dropdownPowerUpMaterial.materialID = materialArray[0].id;
  66. componentInChildren.value = 0;
  67. }
  68. else
  69. {
  70. dropdownPowerUpMaterial.materialID = -1;
  71. }
  72. }
  73. componentInChildren.RefreshShownValue();
  74. componentInChildren.onValueChanged.AddListener(delegate(int value)
  75. {
  76. dropdownPowerUpMaterial.materialID = materialArray[value].id;
  77. <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.OnUpdateDropdownParams();
  78. });
  79. if (i == 0)
  80. {
  81. Transform transform = dropdownPowerUpMaterial.transform.Find("Image Plus Mark");
  82. if (transform)
  83. {
  84. transform.gameObject.SetActive(false);
  85. }
  86. else
  87. {
  88. Debug.LogError("[FacilityPowerUP]プラスマークのイメージが見つかりません\n「Image Plus Mark」という名前の子オブジェクトを追加してください");
  89. }
  90. }
  91. });
  92. this.OnUpdateDropdownParams();
  93. }
  94. public void HideAllDropdown()
  95. {
  96. Transform transform = this.m_uGUIListViewer.transform;
  97. Dropdown[] componentsInChildren = transform.GetComponentsInChildren<Dropdown>();
  98. for (int i = 0; i < componentsInChildren.Length; i++)
  99. {
  100. componentsInChildren[i].Hide();
  101. }
  102. }
  103. public void DeleteDropdown()
  104. {
  105. this.HideAllDropdown();
  106. this.m_uGUIListViewer.ResetList();
  107. }
  108. private void OnUpdateDropdownParams()
  109. {
  110. Transform transform = this.m_uGUIListViewer.transform;
  111. FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial[] componentsInChildren = transform.GetComponentsInChildren<FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial>();
  112. int[] array = new int[componentsInChildren.Length];
  113. for (int i = 0; i < componentsInChildren.Length; i++)
  114. {
  115. array[i] = componentsInChildren[i].materialID;
  116. }
  117. if (this.m_CallbackSelect != null)
  118. {
  119. this.m_CallbackSelect(array);
  120. }
  121. }
  122. private FacilityManager m_FacilityMgr;
  123. [SerializeField]
  124. private uGUIListViewer m_uGUIListViewer;
  125. private Action<int[]> m_CallbackSelect;
  126. private class DropdownPowerUpMaterial : MonoBehaviour, IPointerClickHandler, ISubmitHandler, IEventSystemHandler
  127. {
  128. private void SetupTemplateCanvas()
  129. {
  130. Dropdown component = base.GetComponent<Dropdown>();
  131. Transform transform = component.transform.Find("Dropdown List");
  132. if (!transform)
  133. {
  134. return;
  135. }
  136. Canvas component2 = transform.GetComponent<Canvas>();
  137. Canvas componentInParent = component.GetComponentInParent<Canvas>();
  138. component2.sortingOrder = componentInParent.sortingOrder + 50;
  139. }
  140. private void SetupBlockerCanvas()
  141. {
  142. Dropdown component = base.GetComponent<Dropdown>();
  143. Canvas componentInParent = component.GetComponentInParent<Canvas>();
  144. Transform transform = componentInParent.transform.Find("Blocker");
  145. if (!transform)
  146. {
  147. return;
  148. }
  149. Canvas component2 = transform.GetComponent<Canvas>();
  150. component2.sortingOrder = componentInParent.sortingOrder + 1;
  151. CanvasGroup canvasGroup = transform.gameObject.GetComponent<CanvasGroup>();
  152. if (!canvasGroup)
  153. {
  154. canvasGroup = transform.gameObject.AddComponent<CanvasGroup>();
  155. }
  156. canvasGroup.ignoreParentGroups = true;
  157. canvasGroup.interactable = true;
  158. canvasGroup.blocksRaycasts = true;
  159. }
  160. public void OnPointerClick(PointerEventData data)
  161. {
  162. this.SetupTemplateCanvas();
  163. this.SetupBlockerCanvas();
  164. }
  165. public void OnSubmit(BaseEventData data)
  166. {
  167. this.SetupTemplateCanvas();
  168. this.SetupBlockerCanvas();
  169. }
  170. public int materialID;
  171. }
  172. }