FacilityUIPowerUpMaterialList.cs 7.4 KB

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