void Start() { _popup = GetComponent <ShopPopup>(); _popup.AddFunction(BasePopup.FunctionTypes.displayCallback, OnPopupDisplayCallback); _gm = FindObjectOfType <GameManager>(); _storeInfoData = new Dictionary <MinionType, MinionStoreData>(); _storeStatsCurrencyDef = new Dictionary <MinionType, MinionsStatsCurrencyDef>(); var config = GameUtils.LoadConfig <GenericListJsonLoader <MinionStoreData> > ("StoreMinionsData.json" , GameUtils.MINION_CONFIG_PATH); var config2 = GameUtils.LoadConfig <GenericListJsonLoader <MinionsStatsCurrencyDef> > ("StoreMinionsStatsUpgrade.json" , GameUtils.MINION_CONFIG_PATH); MinionType minionType; foreach (var item2 in config2.list) { minionType = (MinionType)Enum.Parse(typeof(MinionType), item2.type); _storeStatsCurrencyDef.Add(minionType, item2); } foreach (var item in config.list) { minionType = (MinionType)Enum.Parse(typeof(MinionType), item.type); _storeInfoData.Add(minionType, item); _popup.AddMinionToShop(minionType, CreateDescriptionString(item)); } }
public void ClosePopup() { selectedSkinName = null; UIManager.Instance.SetEnableTouchLayer("Main", true); for (int i = 0; i < effecters.Length; i += 1) { effecters[i].enabled = true; } Destroy(shopPopup.gameObject); shopPopup = null; }
public void OpenShopPopup(SkinType shopType) { this.shopType = shopType; UIManager.Instance.SetEnableTouchLayer("Main", false); for (int i = 0; i < effecters.Length; i += 1) { effecters[i].enabled = false; } shopPopup = Instantiate(preShopPopup).GetComponent <ShopPopup>(); shopPopup.transform.parent = UIManager.Instance.Canvas.transform; shopPopup.transform.localPosition = Vector3.zero; shopPopup.transform.localScale = Vector3.one; if (shopType == SkinType.Floor || shopType == SkinType.Wall) { shopPopup.IconImage.transform.localScale = new Vector3(0.25f, 0.25f, 1); } GameObject[] objs; if (shoppingList.TryGetValue(shopType, out objs)) { RectTransform trans = shopPopup.GetComponent <ShopPopup>().ScrolledRect.GetComponent <RectTransform>(); int width = objs.Length * 150 + (objs.Length - 1) * 50; Vector2 offset = trans.offsetMax; offset.x = trans.offsetMin.x + width + 20; trans.offsetMax = offset; for (int i = 0; i < objs.Length; i += 1) { GameObject obj = Instantiate(objs[i]); obj.transform.SetParent(trans.transform); obj.transform.localScale = Vector3.one; } } moneyIcon.SetSiblingIndex(moneyIcon.GetSiblingIndex() + 1); moneyText.SetSiblingIndex(moneyText.GetSiblingIndex() + 1); }