Esempio n. 1
0
        public bool TrySpawnUnit(IEncampment encampment)
        {
            if (Randomizer.GetRandom01() <= BarbarianConfig.WaterSpawnChance)
            {
                var navalInfo = SpawningTools.TryGetValidSpawn(encampment, AvailableUnitsLogic.NavalTemplateSelector);

                if (navalInfo.IsValidSpawn)
                {
                    UnitFactory.BuildUnit(navalInfo.LocationOfUnit, navalInfo.TemplateToBuild, CivFactory.BarbarianCiv);

                    return(true);
                }
            }

            var landInfo = SpawningTools.TryGetValidSpawn(encampment, AvailableUnitsLogic.LandTemplateSelector);

            if (landInfo.IsValidSpawn)
            {
                UnitFactory.BuildUnit(landInfo.LocationOfUnit, landInfo.TemplateToBuild, CivFactory.BarbarianCiv);

                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        public void PerformEncampmentSpawning(InfluenceMaps maps)
        {
            int encampmentCount      = EncampmentFactory.AllEncampments.Count;
            int nonBarbarianCivCount = CivFactory.AllCivilizations.Count(civ => !civ.Template.IsBarbaric);

            float spawnChance = SpawningTools.GetEncampmentSpawnChance(encampmentCount, nonBarbarianCivCount);

            if (spawnChance >= 1f || Randomizer.GetRandom01() < spawnChance)
            {
                EncampmentSpawner.TrySpawnEncampment(maps);
            }
        }