From 040d273993219a6f89b28ef1e7912cebcd308e4e Mon Sep 17 00:00:00 2001 From: p21380769 <18963570599@qq.com> Date: Thu, 8 Jul 2021 12:01:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8D=E5=90=8C=E5=95=86=E5=BA=97=E7=9A=84?= =?UTF-8?q?=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TownInfo.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 TownInfo.cs diff --git a/TownInfo.cs b/TownInfo.cs new file mode 100644 index 0000000..e12db19 --- /dev/null +++ b/TownInfo.cs @@ -0,0 +1,52 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TownInfo : MonoBehaviour +{ + public List goodsInTown = new List(); + public Transform townGoodsTempTransform; + public GameObject goodsPrafab; + + public List goodsProduceInfo = new List(); + + public Dictionary townGoodsPrice; + // Start is called before the first frame update + private void Awake() + { + GenerateGoodsInTown(); + } + + public void GenerateGoodsInTown() + { + townGoodsPrice = new Dictionary(); + goodsInTown = new List(); + 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().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; + } +}