public static BuildingTypes GetBuildingTypes() { var buildingTypes = new List <BuildingType>(); IEnumerable <string> lines = File.ReadLines("BuildingTypes.txt"); foreach (string line in lines) { if (line.StartsWith("--")) { continue; } string[] splitLine = line.Split(','); int id = splitLine[0].ToInt32(); string name = splitLine[1]; float constructionCost = splitLine[2].ToFloat(); float upkeepGold = splitLine[3].ToFloat(); float upkeepMana = splitLine[4].ToFloat(); float foodProduced = splitLine[5].ToFloat(); float growthRateIncrease = splitLine[6].ToFloat(); List <int> dependentBuildings = GetDependentBuildings(splitLine[7]); List <int> races = GetRaces(splitLine[8]); BuildingType buildingType = BuildingType.Create(id, name, constructionCost, 0.0f, upkeepGold, upkeepMana, foodProduced, growthRateIncrease, dependentBuildings, races); buildingTypes.Add(buildingType); } return(BuildingTypes.Create(buildingTypes)); }
//public static BuildingTypes GetBuildingTypes() //{ // var buildingTypes = new List<BuildingType>(); // IEnumerable<string> lines = File.ReadLines("BuildingTypes.txt"); // foreach (string line in lines) // { // if (line.StartsWith("--")) continue; // string[] splitLine = line.Split(','); // int id = splitLine[0].ToInt32(); // string name = splitLine[1]; // float constructionCost = splitLine[2].ToFloat(); // float upkeepGold = splitLine[3].ToFloat(); // float upkeepMana = splitLine[4].ToFloat(); // float foodProduced = splitLine[5].ToFloat(); // float growthRateIncrease = splitLine[6].ToFloat(); // List<int> dependentBuildings = GetDependentBuildings(splitLine[7]); // List<int> races = GetRaces(splitLine[8]); // BuildingType buildingType = BuildingType.Create(id, name, constructionCost, 0.0f, upkeepGold, upkeepMana, foodProduced, growthRateIncrease, dependentBuildings, races); // buildingTypes.Add(buildingType); // } // return BuildingTypes.Create(buildingTypes); //} public static BuildingTypes GetBuildingTypes() { var buildingTypes = new List <BuildingType> { BuildingType.Create(0, "Barracks", 30.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, GetDependentBuildings("none"), GetRaces("all")), BuildingType.Create(1, "Smithy", 40.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, GetDependentBuildings("none"), GetRaces("all")), BuildingType.Create(2, "Builders Hall", 60.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, GetDependentBuildings("none"), GetRaces("all")), BuildingType.Create(3, "Armory", 80.0f, 2.0f, 0.0f, 0.0f, 0.0f, 0.0f, GetDependentBuildings("1"), GetRaces("all")), BuildingType.Create(4, "Fighters Guild", 200.0f, 0.0f, 3.0f, 0.0f, 0.0f, 0.0f, GetDependentBuildings("3"), GetRaces("all")), BuildingType.Create(5, "Armorers Guild", 350.0f, 0.0f, 4.0f, 0.0f, 0.0f, 0.0f, GetDependentBuildings("4"), GetRaces("allexcept:5;6")) }; return(BuildingTypes.Create(buildingTypes)); }
internal void IncreaseProduction(BuildingType currentlyProducing, float production) { List <BuildingType> list = new List <BuildingType>(); foreach (BuildingType item in _allBuildings) { if (item.Id == currentlyProducing.Id) { list.Add(BuildingType.Create(item.Id, item.Name, item.ConstructionCost, item.ConstructedAmount + production, item.UpkeepGold, item.UpkeepMana, item.FoodProduced, item.GrowthRateIncrease, item.DependentBuildings, item.Races)); } else { list.Add(item); } } _allBuildings = BuildingTypes.Create(list); }