86 lines
2.7 KiB
C#
86 lines
2.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using TMPro;
|
|
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 bool Available;
|
|
public GameObject notPurchasedIndicator;
|
|
public SkinShopItemData skinData;
|
|
|
|
public void Set(SkinShopItemData data, bool available){
|
|
skinData = data;
|
|
// newItem.backgroundImg.color = (skinsData.skins[i].skinType==SkinType.Base) ? basicColor : (skinsData.skins[i].skinType==SkinType.Rare ? rareColor : legendaryColor);
|
|
if(available){spaceshipImg.sprite = data.image;}
|
|
spaceshipImg.color = available ? Color.white : Color.black;
|
|
Available = available;
|
|
UpdateFrame();
|
|
|
|
if(data.price <=0){
|
|
banners[0].SetActive(true);
|
|
banners[1].SetActive(false);
|
|
}else{
|
|
banners[0].SetActive(false);
|
|
banners[1].SetActive(data.skinType== SkinType.Base);
|
|
}
|
|
banners[2].SetActive(data.skinType== SkinType.Rare);
|
|
banners[3].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);
|
|
notPurchasedIndicator.GetComponentInChildren<TMP_Text>().text = skinData.price.ToString();
|
|
}else{
|
|
notPurchasedIndicator.SetActive(false);
|
|
}
|
|
if(!Available){
|
|
notPurchasedIndicator.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void OnClick(){
|
|
SkinShopManager.instance.SelectItem(skinData,Available);
|
|
}
|
|
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();
|
|
// }
|
|
}
|