75 lines
1.8 KiB
C#
75 lines
1.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class SkinShopManager : MonoBehaviour
|
|
{
|
|
public static SkinShopManager instance;
|
|
public SkinsData skinsData;
|
|
public TMPro.TMP_Text metalsTxt;
|
|
|
|
public GameObject listItemPrefab;
|
|
public Transform listItemsParent;
|
|
|
|
public Color basicColor = Color.grey;
|
|
public Color rareColor = Color.blue;
|
|
public Color legendaryColor = Color.red;
|
|
|
|
void Awake() {
|
|
instance = this;
|
|
}
|
|
void Start()
|
|
{
|
|
Populate();
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
|
|
}
|
|
|
|
public void Populate(){
|
|
//PURGE
|
|
for(int i=0;i < listItemsParent.childCount;i++){
|
|
Destroy(listItemsParent.GetChild(i).gameObject);
|
|
}
|
|
|
|
for(int i=0; i<skinsData.skins.Length;i++){
|
|
SkinShopItem newItem = Instantiate(listItemPrefab, listItemsParent).GetComponent<SkinShopItem>();
|
|
newItem.Set(skinsData.skins[i]);
|
|
newItem.backgroundImg.color = (skinsData.skins[i].skinType==SkinType.Base) ? basicColor : (skinsData.skins[i].skinType==SkinType.Rare ? rareColor : legendaryColor);
|
|
}
|
|
|
|
metalsTxt.text = DBmanager.Metal.ToString();
|
|
}
|
|
|
|
public static void EquipSkin(string skin){
|
|
PlayerPrefs.SetString("shipSkin", skin);
|
|
PlayerPrefs.Save();
|
|
}
|
|
|
|
public static string GetEquipedSkin(){
|
|
if(PlayerPrefs.HasKey("shipSkin")){
|
|
return PlayerPrefs.GetString("shipSkin");
|
|
}
|
|
|
|
return "Default";
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class SkinShopItemData{
|
|
public string name;
|
|
public Sprite image;
|
|
public int price;
|
|
public SkinType skinType;
|
|
}
|
|
|
|
|
|
public enum SkinType{
|
|
Base,
|
|
Rare,
|
|
Legendary
|
|
} |