using System; using System.Collections.Generic; using DatabaseModel; using SaveDataModel; using UnityEngine; public class UIEnhancementItemsController : MonoBehaviour { private void Awake() { this._scrollView = base.GetComponentInChildren(); this._grid = this._scrollView.gameObject.GetComponentInChildren(); this._items = this.InstantiateAndGetUIEnhancementItems(); base.gameObject.SetActive(false); } private List InstantiateAndGetUIEnhancementItems() { Transform transform = this._grid.transform; Transform child = this._grid.GetChild(0); bool flag = true; foreach (KeyValuePair keyValuePair in DB.Enhancements) { Transform transform2; if (flag) { flag = false; transform2 = child; transform2.GetComponent().value = true; } else { transform2 = UnityEngine.Object.Instantiate(child); transform2.parent = transform; transform2.localScale = Vector3.one; } transform2.GetComponent().Name = keyValuePair.Key; } List childList = this._grid.GetChildList(); List list = new List(); for (int i = 0; i < childList.Count; i++) { list.Add(childList[i].GetComponent()); } return list; } public void OnClick() { EnhancementItem current = UIEnhancementItem.Current; if (current.CoinEnough && current.Unlockable) { SaveDataModel.Enhancement enhancement; string name; (enhancement = R.Player.Enhancement)[name = current.Name] = enhancement[name] + 1; R.Equipment.CoinNum -= current.Cost; R.Player.Enhancement.Post(current.Name, R.Player.Enhancement[current.Name]); } } private UIScrollView _scrollView; private UIGrid _grid; private List _items; }