public void MakeNewBuilding(BuildingTypeSO buildingType) { ResAmount buyResAmount = null; for (int i = 0; i < buildingType.buildResCostArr.Length; i++) { buyResAmount = buildingType.buildResCostArr[i]; int curResoruce = ResourceManager.Instance.GetResourceAmount(buyResAmount.resourceType); ResourceManager.Instance.SetResourceAmount(buyResAmount.resourceType, curResoruce - buyResAmount.amount); } Instantiate(activeBuildingType.prefab, curMousePos, Quaternion.identity); }
private bool CanBuy(BuildingTypeSO buildingType) { ResAmount buyResAmount = null; for (int i = 0; i < buildingType.buildResCostArr.Length; i++) { buyResAmount = buildingType.buildResCostArr[i]; if (buyResAmount.amount > ResourceManager.Instance.GetResourceAmount(buyResAmount.resourceType)) { return(false); } } return(true); }