using System; using I2.Loc; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.UI; public class FacilityUIPowerUpMaterialList : MonoBehaviour { private FacilityManager FacilityMgr { get { if (this.m_FacilityMgr == null) { this.m_FacilityMgr = GameMain.Instance.FacilityMgr; } return this.m_FacilityMgr; } } public void Show(int id, Facility facility, Action callbackSelect) { this.m_CallbackSelect = callbackSelect; this.SetupFacilityPowerUpMaterialListDropDown(id, facility); } private void SetupFacilityPowerUpMaterialListDropDown(int id, Facility facility) { FacilityUIPowerUpMaterialList.c__AnonStorey0 c__AnonStorey = new FacilityUIPowerUpMaterialList.c__AnonStorey0(); c__AnonStorey.$this = this; this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(true); this.DeleteDropdown(); Facility.PowerUpRecipe facilityPowerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(id); c__AnonStorey.materialCategoryIDArray = facilityPowerUpRecipe.materialCategoryIDArray; c__AnonStorey.recipeData = facility.GetRecipeData(id); this.m_uGUIListViewer.Show(c__AnonStorey.materialCategoryIDArray.Length, delegate(int i, Transform trans) { int num = c__AnonStorey.materialCategoryIDArray[i]; Dropdown componentInChildren = trans.GetComponentInChildren(); Text[] componentsInChildren = trans.GetComponentsInChildren(); FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial dropdownPowerUpMaterial = trans.gameObject.AddComponent(); string facilityPowerUpMaterialCategoryName = FacilityDataTable.GetFacilityPowerUpMaterialCategoryName(num); componentsInChildren[0].text = facilityPowerUpMaterialCategoryName; componentsInChildren[1].text = string.Format("CATEGORY{0}", i + 1); Localize component = componentsInChildren[0].GetComponent(); if (component != null) { component.SetTerm("SceneFacilityManagement/強化素材カテゴリー/" + facilityPowerUpMaterialCategoryName); } componentInChildren.ClearOptions(); Facility.PowerUpMaterial[] materialArray = c__AnonStorey.$this.FacilityMgr.GetFacilityPowerUpItemEnableArray(num); LocalizeDropdown localizeDropdown = null; if (Product.SPP) { localizeDropdown = componentInChildren.GetComponent(); if (localizeDropdown != null) { localizeDropdown.enabled = true; localizeDropdown._Terms.Clear(); } } if (materialArray.Length > 0) { for (int j = 0; j < materialArray.Length; j++) { if (localizeDropdown != null) { localizeDropdown._Terms.Add("SceneFacilityManagement/強化素材/" + materialArray[j].name); } else { componentInChildren.options.Add(new Dropdown.OptionData(materialArray[j].name)); } if (c__AnonStorey.recipeData.materialIDArray[i] == materialArray[j].id) { dropdownPowerUpMaterial.materialID = materialArray[j].id; componentInChildren.value = j; } } if (localizeDropdown != null) { localizeDropdown.UpdateLocalization(); } } else { componentInChildren.image.raycastTarget = false; dropdownPowerUpMaterial.materialID = 0; if (localizeDropdown != null) { localizeDropdown._Terms.Clear(); localizeDropdown._Terms.Add("SceneFacilityManagement/強化素材/無し"); localizeDropdown.UpdateLocalization(); } else { componentInChildren.options.Add(new Dropdown.OptionData("無し")); } } if (dropdownPowerUpMaterial.materialID == 0) { if (materialArray.Length > 0) { dropdownPowerUpMaterial.materialID = materialArray[0].id; componentInChildren.value = 0; } else { dropdownPowerUpMaterial.materialID = -1; } } componentInChildren.RefreshShownValue(); componentInChildren.onValueChanged.AddListener(delegate(int value) { dropdownPowerUpMaterial.materialID = materialArray[value].id; c__AnonStorey.OnUpdateDropdownParams(); }); if (i == 0) { Transform transform = dropdownPowerUpMaterial.transform.Find("Image Plus Mark"); if (transform) { transform.gameObject.SetActive(false); } else { Debug.LogError("[FacilityPowerUP]プラスマークのイメージが見つかりません\n「Image Plus Mark」という名前の子オブジェクトを追加してください"); } } }); this.OnUpdateDropdownParams(); } public void HideAllDropdown() { Transform transform = this.m_uGUIListViewer.transform; Dropdown[] componentsInChildren = transform.GetComponentsInChildren(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Hide(); } } public void DeleteDropdown() { this.HideAllDropdown(); this.m_uGUIListViewer.ResetList(); } private void OnUpdateDropdownParams() { Transform transform = this.m_uGUIListViewer.transform; FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial[] componentsInChildren = transform.GetComponentsInChildren(); int[] array = new int[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { array[i] = componentsInChildren[i].materialID; } if (this.m_CallbackSelect != null) { this.m_CallbackSelect(array); } } private FacilityManager m_FacilityMgr; [SerializeField] private uGUIListViewer m_uGUIListViewer; private Action m_CallbackSelect; private class DropdownPowerUpMaterial : MonoBehaviour, IPointerClickHandler, ISubmitHandler, IEventSystemHandler { private void SetupTemplateCanvas() { Dropdown component = base.GetComponent(); Transform transform = component.transform.Find("Dropdown List"); if (!transform) { return; } Canvas component2 = transform.GetComponent(); Canvas componentInParent = component.GetComponentInParent(); component2.sortingOrder = componentInParent.sortingOrder + 50; } private void SetupBlockerCanvas() { Dropdown component = base.GetComponent(); Canvas componentInParent = component.GetComponentInParent(); Transform transform = componentInParent.transform.Find("Blocker"); if (!transform) { return; } Canvas component2 = transform.GetComponent(); component2.sortingOrder = componentInParent.sortingOrder + 1; CanvasGroup canvasGroup = transform.gameObject.GetComponent(); if (!canvasGroup) { canvasGroup = transform.gameObject.AddComponent(); } canvasGroup.ignoreParentGroups = true; canvasGroup.interactable = true; canvasGroup.blocksRaycasts = true; } public void OnPointerClick(PointerEventData data) { this.SetupTemplateCanvas(); this.SetupBlockerCanvas(); } public void OnSubmit(BaseEventData data) { this.SetupTemplateCanvas(); this.SetupBlockerCanvas(); } public int materialID; } }