FacilityUIPowerUpList.cs 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. using System;
  2. using System.Collections.Generic;
  3. using I2.Loc;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class FacilityUIPowerUpList : MonoBehaviour
  7. {
  8. public void Show(Facility facility, Action<Facility.PowerUpRecipe> callbackSelect)
  9. {
  10. this.SetupFacilityPowerUpListButton(facility, callbackSelect);
  11. }
  12. private void SetupFacilityPowerUpListButton(Facility facility, Action<Facility.PowerUpRecipe> callbackSelect)
  13. {
  14. FacilityUIPowerUpList.<SetupFacilityPowerUpListButton>c__AnonStorey0 <SetupFacilityPowerUpListButton>c__AnonStorey = new FacilityUIPowerUpList.<SetupFacilityPowerUpListButton>c__AnonStorey0();
  15. <SetupFacilityPowerUpListButton>c__AnonStorey.callbackSelect = callbackSelect;
  16. <SetupFacilityPowerUpListButton>c__AnonStorey.$this = this;
  17. this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(true);
  18. <SetupFacilityPowerUpListButton>c__AnonStorey.powerUpRecipeIDArray = new int[0];
  19. if (FacilityDataTable.IsExistFacilityPowerUpRecipe(facility.param.typeID, true))
  20. {
  21. <SetupFacilityPowerUpListButton>c__AnonStorey.powerUpRecipeIDArray = FacilityDataTable.GetFacilityPowerUpRecipeIDArray(facility.param.typeID, true);
  22. }
  23. this.m_uGUIListViewer.Show<Transform>(<SetupFacilityPowerUpListButton>c__AnonStorey.powerUpRecipeIDArray.Length, delegate(int i, Transform trans)
  24. {
  25. Facility.PowerUpRecipe powerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(<SetupFacilityPowerUpListButton>c__AnonStorey.powerUpRecipeIDArray[i]);
  26. Toggle componentInChildren = trans.GetComponentInChildren<Toggle>();
  27. Text componentInChildren2 = trans.GetComponentInChildren<Text>();
  28. Localize component = componentInChildren2.GetComponent<Localize>();
  29. componentInChildren2.text = powerUpRecipe.name;
  30. if (component != null)
  31. {
  32. component.SetTerm("SceneFacilityManagement/強化種類/" + powerUpRecipe.name);
  33. }
  34. componentInChildren.onValueChanged.RemoveAllListeners();
  35. componentInChildren.onValueChanged.AddListener(delegate(bool isOn)
  36. {
  37. if (!isOn)
  38. {
  39. return;
  40. }
  41. if (<SetupFacilityPowerUpListButton>c__AnonStorey.callbackSelect != null)
  42. {
  43. <SetupFacilityPowerUpListButton>c__AnonStorey.callbackSelect(powerUpRecipe);
  44. }
  45. <SetupFacilityPowerUpListButton>c__AnonStorey.UpdateConditionsText(powerUpRecipe.id);
  46. });
  47. });
  48. if (<SetupFacilityPowerUpListButton>c__AnonStorey.powerUpRecipeIDArray.Length <= 0)
  49. {
  50. this.m_uGUIListViewer.Show<Transform>(1, delegate(int i, Transform trans)
  51. {
  52. Toggle componentInChildren = trans.GetComponentInChildren<Toggle>();
  53. Text componentInChildren2 = trans.GetComponentInChildren<Text>();
  54. Localize component = componentInChildren2.GetComponent<Localize>();
  55. componentInChildren.enabled = false;
  56. componentInChildren2.text = "レシピは存在しません。";
  57. if (component != null)
  58. {
  59. component.SetTerm("SceneFacilityManagement/強化種類/レシピは存在しません");
  60. }
  61. });
  62. }
  63. this.m_uGUIListConditions.ResetList();
  64. }
  65. private void UpdateConditionsText(int recipeID)
  66. {
  67. FacilityDataTable.FacilityRecipeData facilityRecipeData = FacilityDataTable.GetFacilityRecipeData(recipeID);
  68. if (facilityRecipeData == null)
  69. {
  70. this.m_uGUIListConditions.ResetList();
  71. return;
  72. }
  73. string[] conditions = facilityRecipeData.conditions;
  74. List<string> strConditionsList = new List<string>();
  75. for (int j = 0; j < conditions.Length; j++)
  76. {
  77. if (!string.IsNullOrEmpty(conditions[j]))
  78. {
  79. strConditionsList.Add(conditions[j]);
  80. }
  81. }
  82. this.m_uGUIListConditions.Show<RectTransform>(strConditionsList.Count, delegate(int i, RectTransform trans)
  83. {
  84. string text = strConditionsList[i];
  85. Text[] componentsInChildren = trans.GetComponentsInChildren<Text>();
  86. Localize component = componentsInChildren[1].GetComponent<Localize>();
  87. componentsInChildren[0].text = (i + 1).ToString();
  88. componentsInChildren[1].text = text;
  89. if (component != null)
  90. {
  91. component.SetTerm("SceneFacilityManagement/実行条件/" + text);
  92. }
  93. Image componentInChildren = trans.GetComponentInChildren<Image>();
  94. componentInChildren.enabled = (i % 2 != 0);
  95. });
  96. }
  97. public void Hide()
  98. {
  99. this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(false);
  100. }
  101. [SerializeField]
  102. private uGUIListViewer m_uGUIListViewer;
  103. [SerializeField]
  104. private uGUIListViewer m_uGUIListConditions;
  105. }