public void CalculateBuildingCost(int configID) { BUILDING configData = GetBuildingConfigDataByConfigID(configID); if (configData == null) { return; } buildingCostList.Clear(); //level, gold, elec NCostDef cost = new NCostDef(); cost.configID = 1; cost.value = configData.BldgLvLim; buildingCostList.Add(cost); if (configData.GoldCost > 0) { cost = new NCostDef(); cost.configID = 2; cost.value = configData.GoldCost; buildingCostList.Add(cost); } if (configData.ElecCost > 0) { cost = new NCostDef(); cost.configID = 3; cost.value = configData.ElecCost; buildingCostList.Add(cost); } //res cost for (int i = 0; i < configData.CostTableCount; i++) { cost = new NCostDef(); int itemConfigID = configData.GetCostTable(i).CostId; if (itemConfigID == 0) { continue; } int num = configData.GetCostTable(i).CostQty; cost.configID = itemConfigID; cost.value = num; buildingCostList.Add(cost); } }
public override void DrawCell(int index, int count = 0) { base.DrawCell(index, count); var dataList = sanctuaryPackage.GetBuildingCostList(); NCostDef cost = dataList[index]; bool isEnough = true; if (cost.configID == 1) { nameLabel.text = string.Format("庄园等级限制:"); valueLabel.text = string.Format("{0}/{1}", cost.value, userPackage.GetManorLevel()); if (userPackage.GetManorLevel() < cost.value) { isEnough = false; } } else if (cost.configID == 2) { nameLabel.text = string.Format("黄金:"); valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemPackage.GetGoldNumber())); if (itemPackage.GetGoldNumber() < cost.value) { isEnough = false; } } else if (cost.configID == 3) { nameLabel.text = string.Format("电力:"); valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemPackage.GetElecNumber())); if (itemPackage.GetElecNumber() < cost.value) { isEnough = false; } } else { ITEM_RES itemData = itemPackage.GetItemDataByConfigID(cost.configID); if (itemData == null) { return; } nameLabel.text = string.Format("{0}:", itemData.MinName); NItemInfo itemInfo = itemPackage.GetItemInfo(cost.configID); if (itemInfo == null) { valueLabel.text = string.Format("{0}/{1}", cost.value, 0); isEnough = false; } else { valueLabel.text = string.Format("{0}/{1}", cost.value, GlobalFunction.NumberFormat(itemInfo.number)); if (itemInfo.number < cost.value) { isEnough = false; } } } if (isEnough) { nameLabel.color = Color.white; valueLabel.color = Color.white; } else { nameLabel.color = Color.red; valueLabel.color = Color.red; } }