商品数据库

master
p21380769 5 years ago
parent 40c50479bf
commit 60e62cba0e

@ -0,0 +1,50 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GoodsDatabase : MonoBehaviour
{
public static GoodsDatabase instance;
public List<Goods> goodsInfo = new List<Goods>();
public Dictionary<GoodsType, string> goodsNameLookup;
public Dictionary<GoodsType, int> goodsPriceLookup;
public Dictionary<GoodsType, Sprite> goodsSpriteLookup;
// Start is called before the first frame update
private void Awake()
{
instance = this;
goodsNameLookup = new Dictionary<GoodsType, string>();
for(int i = 0; i < goodsInfo.Count; i++)
{
goodsNameLookup.Add(goodsInfo[i].goodsType, goodsInfo[i].goodsName);
}
goodsPriceLookup = new Dictionary<GoodsType, int>();
for (int i = 0; i < goodsInfo.Count; i++)
{
goodsPriceLookup.Add(goodsInfo[i].goodsType, goodsInfo[i].basePrice);
}
goodsSpriteLookup = new Dictionary<GoodsType, Sprite>();
for (int i = 0; i < goodsInfo.Count; i++)
{
goodsSpriteLookup.Add(goodsInfo[i].goodsType, goodsInfo[i].sprite);
}
}
}
[System.Serializable]
public class Goods
{
public GoodsType goodsType;
public string goodsName;
public int basePrice;
public Sprite sprite;
public bool isProducing;
}
public enum GoodsType
{
Redbottle,
Bluebottle,
}
Loading…
Cancel
Save