using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class ShopController : MonoBehaviour { public enum ShopType { OUTFIT, HAIRSTYLE, FOOD } [SerializeField] ShopType type = ShopType.OUTFIT; [SerializeField] Transform verticalLayoutGroup; [SerializeField] GameObject ShopItemPrefab; [SerializeField] ScrollRect scroll; [SerializeField] VNObjectController assets; public void SetUp() { while (verticalLayoutGroup.childCount > 0) { DestroyImmediate(verticalLayoutGroup.GetChild(0).gameObject); } if (type == ShopType.OUTFIT) { GameData.GLOBAL.UpdateForSale(); foreach (Body body in VNData.OUTFIT_INFO.Keys) { ShopItemController item = Instantiate(ShopItemPrefab).GetComponent(); item.assets = assets; item.SetFields(VNData.OUTFIT_INFO[body], body); item.transform.SetParent(verticalLayoutGroup); item.persist = true; } } else if (type == ShopType.HAIRSTYLE) { GameData.GLOBAL.UpdateForSale(); foreach (Hair hair in VNData.HAIR_INFO.Keys) { ShopItemController item = Instantiate(ShopItemPrefab).GetComponent(); item.assets = assets; item.SetFields(VNData.HAIR_INFO[hair], hair); item.transform.SetParent(verticalLayoutGroup); item.persist = true; } } else if (type == ShopType.FOOD) { foreach (Food food in VNData.FOOD_INFO.Keys) { ShopItemController item = Instantiate(ShopItemPrefab).GetComponent(); item.assets = assets; item.SetFields(VNData.FOOD_INFO[food], food); item.transform.SetParent(verticalLayoutGroup); item.persist = true; } } scroll.verticalNormalizedPosition = 1f; } }