FacilityUIPowerUpList.cs 3.7 KB

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