using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class SkinShopItem : MonoBehaviour { public Image spaceshipImg; [Tooltip("In order of: normal, rare, legendary. 3 items required")] public GameObject[] banners; public Image frame; public GameObject notPurchasedIndicator; public SkinShopItemData skinData; public void Set(SkinShopItemData data){ skinData = data; // newItem.backgroundImg.color = (skinsData.skins[i].skinType==SkinType.Base) ? basicColor : (skinsData.skins[i].skinType==SkinType.Rare ? rareColor : legendaryColor); spaceshipImg.sprite = data.image; UpdateFrame(); banners[0].SetActive(data.skinType== SkinType.Base); banners[1].SetActive(data.skinType== SkinType.Rare); banners[2].SetActive(data.skinType== SkinType.Legendary); } public void UpdateFrame(){ if(SkinShopManager.GetEquipedSkin() == skinData.name){ frame.enabled=true; frame.color = Color.cyan; }else{ frame.enabled=false; } if(!DBmanager.SkinsPurchased.Contains(skinData.name)){ frame.color = Color.red; notPurchasedIndicator.SetActive(true); }else{ notPurchasedIndicator.SetActive(false); } } public void OnClick(){ SkinShopManager.instance.SelectItem(skinData); } public void OnSelectionChanged(string selectedItem){ if(selectedItem == skinData.name){ frame.enabled=true; }else{ frame.enabled = false; } if(SkinShopManager.GetEquipedSkin() == skinData.name){ frame.enabled = true; } } // void onEquip(){ // SkinShopManager.EquipSkin(name); // SkinShopManager.instance.Populate(); // } // void onBuy(){ // SkinShopItemData data = new SkinShopItemData(){name=name, price=price}; // DBmanager.PurchaseSkin(data); // SkinShopManager.instance.Populate(); // } }