using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class FacilityUIPowerUpList : MonoBehaviour { public void Show(Facility facility, Action callbackSelect) { this.SetupFacilityPowerUpListButton(facility, callbackSelect); } private void SetupFacilityPowerUpListButton(Facility facility, Action callbackSelect) { this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(true); int[] powerUpRecipeIDArray = new int[0]; if (FacilityDataTable.IsExistFacilityPowerUpRecipe(facility.param.typeID, true)) { powerUpRecipeIDArray = FacilityDataTable.GetFacilityPowerUpRecipeIDArray(facility.param.typeID, true); } this.m_uGUIListViewer.Show(powerUpRecipeIDArray.Length, delegate(int i, Transform trans) { Facility.PowerUpRecipe powerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(powerUpRecipeIDArray[i]); Toggle componentInChildren = trans.GetComponentInChildren(); Text componentInChildren2 = trans.GetComponentInChildren(); componentInChildren2.text = powerUpRecipe.name; componentInChildren.onValueChanged.RemoveAllListeners(); componentInChildren.onValueChanged.AddListener(delegate(bool isOn) { if (!isOn) { return; } if (callbackSelect != null) { callbackSelect(powerUpRecipe); } this.UpdateConditionsText(powerUpRecipe.id); }); }); if (powerUpRecipeIDArray.Length <= 0) { this.m_uGUIListViewer.Show(1, delegate(int i, Transform trans) { Toggle componentInChildren = trans.GetComponentInChildren(); Text componentInChildren2 = trans.GetComponentInChildren(); componentInChildren.enabled = false; componentInChildren2.text = "レシピは存在しません。"; }); } this.m_uGUIListConditions.ResetList(); } private void UpdateConditionsText(int recipeID) { FacilityDataTable.FacilityRecipeData facilityRecipeData = FacilityDataTable.GetFacilityRecipeData(recipeID); if (facilityRecipeData == null) { this.m_uGUIListConditions.ResetList(); return; } string[] conditions = facilityRecipeData.conditions; List strConditionsList = new List(); for (int j = 0; j < conditions.Length; j++) { if (!string.IsNullOrEmpty(conditions[j])) { strConditionsList.Add(conditions[j]); } } this.m_uGUIListConditions.Show(strConditionsList.Count, delegate(int i, RectTransform trans) { string text = strConditionsList[i]; Text[] componentsInChildren = trans.GetComponentsInChildren(); componentsInChildren[0].text = (i + 1).ToString(); componentsInChildren[1].text = text; Image componentInChildren = trans.GetComponentInChildren(); componentInChildren.enabled = (i % 2 != 0); }); } public void Hide() { this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(false); } [SerializeField] private uGUIListViewer m_uGUIListViewer; [SerializeField] private uGUIListViewer m_uGUIListConditions; }