Пример #1
0
        public BuildingTypes CanCurrentlyBuild()
        {
            List <BuildingType> canCurrentlyBuild = new List <BuildingType>();

            foreach (BuildingType building in _allBuildings)
            {
                if (building.HasBeenBuilt)
                {
                    continue;                        // already built - skip
                }
                if (!building.CanBeBuiltBy(_settlement.RaceId))
                {
                    continue;                                             // race cannot build this - skip
                }
                bool hasAllDependentBuildings = true;
                foreach (int item in building.DependentBuildings)
                {
                    hasAllDependentBuildings = BuildingHasBeenBuilt(item);
                }

                if (hasAllDependentBuildings)
                {
                    canCurrentlyBuild.Add(building);
                }
            }

            return(BuildingTypes.Create(canCurrentlyBuild));
        }
Пример #2
0
        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));
        }
Пример #3
0
        //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));
        }
Пример #4
0
        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);
        }