123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222 |
- 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<int[]> callbackSelect)
- {
- this.m_CallbackSelect = callbackSelect;
- this.SetupFacilityPowerUpMaterialListDropDown(id, facility);
- }
- private void SetupFacilityPowerUpMaterialListDropDown(int id, Facility facility)
- {
- FacilityUIPowerUpMaterialList.<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey0 <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey = new FacilityUIPowerUpMaterialList.<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey0();
- <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.$this = this;
- this.m_uGUIListViewer.parentItemArea.gameObject.SetActive(true);
- this.DeleteDropdown();
- Facility.PowerUpRecipe facilityPowerUpRecipe = FacilityDataTable.GetFacilityPowerUpRecipe(id);
- <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.materialCategoryIDArray = facilityPowerUpRecipe.materialCategoryIDArray;
- <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.recipeData = facility.GetRecipeData(id);
- this.m_uGUIListViewer.Show<Transform>(<SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.materialCategoryIDArray.Length, delegate(int i, Transform trans)
- {
- int num = <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.materialCategoryIDArray[i];
- Dropdown componentInChildren = trans.GetComponentInChildren<Dropdown>();
- Text[] componentsInChildren = trans.GetComponentsInChildren<Text>();
- FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial dropdownPowerUpMaterial = trans.gameObject.AddComponent<FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial>();
- string facilityPowerUpMaterialCategoryName = FacilityDataTable.GetFacilityPowerUpMaterialCategoryName(num);
- componentsInChildren[0].text = facilityPowerUpMaterialCategoryName;
- componentsInChildren[1].text = string.Format("CATEGORY{0}", i + 1);
- Localize component = componentsInChildren[0].GetComponent<Localize>();
- if (component != null)
- {
- component.SetTerm("SceneFacilityManagement/強化素材カテゴリー/" + facilityPowerUpMaterialCategoryName);
- }
- componentInChildren.ClearOptions();
- Facility.PowerUpMaterial[] materialArray = <SetupFacilityPowerUpMaterialListDropDown>c__AnonStorey.$this.FacilityMgr.GetFacilityPowerUpItemEnableArray(num);
- LocalizeDropdown localizeDropdown = null;
- if (Product.SPP)
- {
- localizeDropdown = componentInChildren.GetComponent<LocalizeDropdown>();
- 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 (<SetupFacilityPowerUpMaterialListDropDown>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;
- <SetupFacilityPowerUpMaterialListDropDown>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<Dropdown>();
- 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<FacilityUIPowerUpMaterialList.DropdownPowerUpMaterial>();
- 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<int[]> m_CallbackSelect;
- private class DropdownPowerUpMaterial : MonoBehaviour, IPointerClickHandler, ISubmitHandler, IEventSystemHandler
- {
- private void SetupTemplateCanvas()
- {
- Dropdown component = base.GetComponent<Dropdown>();
- Transform transform = component.transform.Find("Dropdown List");
- if (!transform)
- {
- return;
- }
- Canvas component2 = transform.GetComponent<Canvas>();
- Canvas componentInParent = component.GetComponentInParent<Canvas>();
- component2.sortingOrder = componentInParent.sortingOrder + 50;
- }
- private void SetupBlockerCanvas()
- {
- Dropdown component = base.GetComponent<Dropdown>();
- Canvas componentInParent = component.GetComponentInParent<Canvas>();
- Transform transform = componentInParent.transform.Find("Blocker");
- if (!transform)
- {
- return;
- }
- Canvas component2 = transform.GetComponent<Canvas>();
- component2.sortingOrder = componentInParent.sortingOrder + 1;
- CanvasGroup canvasGroup = transform.gameObject.GetComponent<CanvasGroup>();
- if (!canvasGroup)
- {
- canvasGroup = transform.gameObject.AddComponent<CanvasGroup>();
- }
- 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;
- }
- }
|