You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.7 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TownInfo : MonoBehaviour
{
public List<GameObject> goodsInTown = new List<GameObject>();
public Transform townGoodsTempTransform;
public GameObject goodsPrafab;
public List<Goods> goodsProduceInfo = new List<Goods>();
public Dictionary<GoodsType, int> townGoodsPrice;
// Start is called before the first frame update
private void Awake()
{
GenerateGoodsInTown();
}
public void GenerateGoodsInTown()
{
townGoodsPrice = new Dictionary<GoodsType, int>();
goodsInTown = new List<GameObject>();
for (int i = 0; i < goodsProduceInfo.Count; i++)
{
if (goodsProduceInfo[i].isProducing)
{
townGoodsPrice.Add(goodsProduceInfo[i].goodsType, GoodsDatabase.instance.goodsPriceLookup[goodsProduceInfo[i].goodsType]);
goodsPrafab.GetComponent<SingleGoods>().goodsType = goodsProduceInfo[i].goodsType;
/*for (int j = 0; j < Random.Range(1,3); j++)
{
GameObject _gameObject = Instantiate(goodsPrafab, townGoodsTempTransform, false);
goodsInTown.Add(_gameObject);
}*/
GameObject _gameObject = Instantiate(goodsPrafab, townGoodsTempTransform, false);
goodsInTown.Add(_gameObject);
Debug.Log(goodsInTown.Count);
}
else
{
townGoodsPrice.Add(goodsProduceInfo[i].goodsType, GoodsDatabase.instance.goodsPriceLookup[goodsProduceInfo[i].goodsType]);
}
}
}
int GetPrice(int _basePrice)
{
return _basePrice;
}
}