/// <summary> /// /// </summary> /// <param name="continent"></param> /// <returns></returns> public List<IRegion> Generate(IContinent continent, List<ICivilization> civilizations) { List<IRegion> listOfRegions = new List<IRegion>(); int remainingKilometersSquare = continent.AreaKilometersSquare; int regionCount = 0; while(true) { // FOR EXAMPLE: A Savanna shouldn't have a forest in it IRegion region = new Region(); region.Id = regionCount; region.Climate = ClimateFactory.Get(continent.UpperLatitude, continent.Lowerlatitude); // TODO: this should be based off latitude (upper and lower bounds) of parent continent region.Name = GetName(region.Climate); region.Size = SelectRandomSize(remainingKilometersSquare, 5); region.AreaKilometersSquare = CalculateRegionSizeKM(region.Size); region.Topography = TopographyFactory.Get(Random.Next(0, 6), region.Size, region.Climate); // TODO: pass in the climate type so features can be filtered out (no forests in tundra for example) region.Features = region.Topography.Features; // FROM ABOVE: features here should be based off climate... region.Civilizations.Add(civilizations.ElementAt(Random.Next(0, civilizations.Count - 1))); listOfRegions.Add(region); remainingKilometersSquare -= region.AreaKilometersSquare; if (remainingKilometersSquare < (int)CoreEnums.RegionSize.VerySmall) { region.AreaKilometersSquare += remainingKilometersSquare; break; } regionCount++; } return listOfRegions; }
public CountyData(string name, string code, IContinent continent, IReadOnlyList <ICity> cities = null) { Name = name; Code = code; Continent = continent; Cities = cities; }
public WorldOfAnimals(IContinent CurrentContinent, int AmountOfCarnivorous, int AmountOfHerbivorous) { AnimalsFactory = CurrentContinent; int RandomValue; for (int Counter = 0; Counter < AmountOfCarnivorous; ++Counter) { RandomValue = Program.MainRandom.Next(1, 3); if (RandomValue == 1) { AllCarnivorous.Add(AnimalsFactory.GetСarnivorous()); } else { AllCarnivorous.Add(AnimalsFactory.GetСarnivorous()); } } for (int Counter = 0; Counter < AmountOfHerbivorous; ++Counter) { RandomValue = Program.MainRandom.Next(1, 3); if (RandomValue == 1) { AllHerbivorous.Add(AnimalsFactory.GetHerbivorous()); } else { AllHerbivorous.Add(AnimalsFactory.GetHerbivorous()); } } }
public CountyImpl( string name, string code, IContinent continent, IReadOnlyList <ICity> cities) { Name = name; Code = code; Continent = continent; Cities = cities ?? new List <ICity>(); }
public Ip64ClientData( string ipV6, ICity city, ICounty county, IContinent continent, ILocation location) { IpV6 = ipV6; City = city; County = county; Continent = continent; Location = location; }
public IpV4ClientImpl( string ipV4, ICity city, ICounty county, IContinent continent, ILocation location) { IpV4 = ipV4; City = city; County = county; Continent = continent; Location = location; }
public UpgradedWarEngine( IRenderer renderer, IInputController inputController, IUnitFactory unitFactory, IArmyStructureFactory armyStructureFactory, ICommandFactory commandFactory, IContinent continent) : base(renderer, inputController, unitFactory, armyStructureFactory, commandFactory, continent) { }
public WarEngine( IRenderer renderer, IInputController inputController, IUnitFactory unitFactory, IArmyStructureFactory armyStructureFactory, ICommandFactory commandFactory, IContinent continent) { this.renderer = renderer; this.inputController = inputController; this.UnitFactory = unitFactory; this.ArmyStructureFactory = armyStructureFactory; this.CommandFactory = commandFactory; this.Continent = continent; }
public WarEngine( IRenderer renderer, IInputController inputController, IUnitFactory unitFactory, IArmyStructureFactory armyStructureFactory, ICommandFactory commandFactory, IContinent continent) { this.renderer = renderer; this.inputController = inputController; this.UnitFactory = unitFactory; this.ArmyStructureFactory = armyStructureFactory; this.CommandFactory = commandFactory; this.Continent = continent; }
public static ContinentModel CreateContinent(IContinent continent) { var result = new ContinentModel { Code = continent.Code, Name = continent.Name, }; if (continent.Counties.Count > 0) { for (var i = 0; i < continent.Counties.Count; i++) { result.Counties.Add(CreateCountry(continent.Counties[i])); } } return(result); }
private List <List <TileBase> > SliceContinentSectors(IContinent continent) { Debug.Log($"Continent {continent.Name}"); var tiles = continent.Countries.SelectMany(c => c.Provinces.SelectMany(p => p.HexTiles)).ToList(); var west = tiles.Min(t => t.Position.X); var east = tiles.Max(t => t.Position.X); var north = tiles.Max(t => t.Position.Y); var south = tiles.Min(t => t.Position.Y); Debug.Log($"West: {west}, north: {north}, east: {east}, south: {south}"); var centerX = west / 2 + east / 2; var centerY = north / 2 + south / 2; Debug.Log($"centerX: {centerX}, centerY: {centerY}"); var comparer = new PositionComparer(east); Func <TileBase, bool> predicate = t => t.TileTerrainType == TileTerrainType.Plain; var sectors = new List <List <TileBase> > { tiles.Where(predicate).Where(t => t.Position.X <= centerX && t.Position.Y > centerY).OrderBy(p => p.Position, comparer).ToList(), tiles.Where(predicate).Where(t => t.Position.X > centerX && t.Position.Y > centerY).OrderBy(p => p.Position, comparer).ToList(), tiles.Where(predicate).Where(t => t.Position.X <= centerX && t.Position.Y <= centerY).OrderBy(p => p.Position, comparer).ToList(), tiles.Where(predicate).Where(t => t.Position.X > centerX && t.Position.Y <= centerY).OrderBy(p => p.Position, comparer).ToList() }; var emptySectors = sectors.Where(s => !s.Any()).ToList(); foreach (var sector in emptySectors) { sectors.Remove(sector); } return(sectors); }
internal static Continent CreateContinent(IContinent data) { if (data == null) { return(null); } var result = new Continent { Code = data.Code, Name = data.Name, }; if (data.Counties != null && data.Counties.Count > 0) { var counties = new List <County>(); for (var i = 0; i < data.Counties.Count; i++) { counties.Add(CreateCounty(data.Counties[i])); } result.Counties = counties; } return(result); }
private List<IContinent> ConnectContinents(List<IContinent> continents, IContinent startingContinent) { int numberOfLoops = (continents.Count * 2) / 3; for (int n = 0; n < numberOfLoops; n++) { Dictionary<CoreEnums.CardinalDirections, IContinent> availableConnections = new Dictionary<CoreEnums.CardinalDirections, IContinent>(); List<int> availableDirections = new List<int> { 0, 1, 2, 3 }; int direction = Random.Next(0, startingContinent.AdjoiningContinents.Count - 1); // randomly select one of the connections if (startingContinent.AdjoiningContinents.Values.ElementAt(direction).Name == null) { // no connection was found... let's create one continents = NoConnectionExists(continents, startingContinent, direction); } else { // a connection was found. Dig into that connection and try all over again // this needs to keep digging until it finds a spot to create continents = ConnectionExists(continents, startingContinent.AdjoiningContinents.Values.ElementAt(direction)); } } return continents; }
private List<IContinent> ConnectionExists(List<IContinent> continents, IContinent startingContinent) { Dictionary<CoreEnums.CardinalDirections, IContinent> availableConnections = new Dictionary<CoreEnums.CardinalDirections, IContinent>(); List<int> availableDirections = new List<int> { 0, 1, 2, 3 }; int direction = Random.Next(0, startingContinent.AdjoiningContinents.Count - 1); // randomly select one of the connections if (startingContinent.AdjoiningContinents.Values.ElementAt(direction).Name == null) { // no connection was found... let's create one continents = NoConnectionExists(continents, startingContinent, direction); } else { // a connection was found. Dig into that connection and try all over again continents = ConnectContinents(continents, startingContinent.AdjoiningContinents.Values.ElementAt(direction)); } return continents; }
private Dictionary<CoreEnums.CardinalDirections, IContinent> ConstructConnections(Dictionary<CoreEnums.CardinalDirections, IContinent> availableConnections, List<IContinent> continents, IContinent primaryContinent) { foreach (IContinent continent in continents) { if (continents[0].AdjoiningContinents.Count == 0) break; // it's Australia! // check if the continent already has a connection to another landmass int element = Random.Next(0, continents[0].AdjoiningContinents.Count - 1); if (primaryContinent.AdjoiningContinents.Values.ElementAt(element).Name == null) { // no connection to another continent exists primaryContinent.AdjoiningContinents[0] = continent; } else { // a connection exists so let's go deeper ConstructConnections(availableConnections, continents, primaryContinent.AdjoiningContinents.Values.ElementAt(element)); } } return availableConnections; }
static void Main(string[] args) { string[] menu = Configuration.GetContinentMenu(); byte menuLength = Convert.ToByte(menu.Length); IContinent continent = null; IAnimal[] animals = null; while (true) { for (byte i = 0; i < menuLength; i++) { Console.WriteLine($"{i + 1}) {menu[i]}"); } Console.Write("\nSelect one of this continents: "); bool isNumber = byte.TryParse(Console.ReadLine(), out byte choiceNumber); while (isNumber == false || Verify.IsChoiceExist(choiceNumber, menuLength) == false) { Console.Write("Enter one of this numbers please: "); isNumber = byte.TryParse(Console.ReadLine(), out choiceNumber); } switch (choiceNumber) { case ContinentNumbers.DomesticCarnivorousContinent: { continent = new DomesticCarnivorousContinent(); } break; case ContinentNumbers.DomesticHerbivorousContinent: { continent = new DomesticHerbivorousContinent(); } break; case ContinentNumbers.WildCarnivorousContinent: { continent = new WildCarnivorousContinent(); } break; case ContinentNumbers.WildHerbivorousContinent: { continent = new WildHerbivorousContinent(); } break; } Console.Clear(); animals = continent.CreateAnimals(); byte animalsLength = Convert.ToByte(animals.Length); Console.WriteLine($"Animals in {menu[choiceNumber - 1]}\n"); for (byte i = 0; i < animalsLength; i++) { animals[i].Eat(); Console.Write("Noise with text: "); animals[i].Speak(); Console.WriteLine(); } Console.Write("Press any key to continue..."); Console.ReadLine(); Console.Clear(); } }
private List<IContinent> NoConnectionExists(List<IContinent> continents, IContinent startingContinent, int direction) { // select the first continent that's greater than the current one (the ones coming before should have lower Ids) // TODO: this has generated a "Sequence contains no elements" exception... IContinent continent = continents.Where(c => c.Id > startingContinent.Id).First(); CoreEnums.CardinalDirections key = (CoreEnums.CardinalDirections)startingContinent.AdjoiningContinents.Keys.ElementAt(direction); startingContinent.AdjoiningContinents[key] = continent; switch (Convert.ToInt32(key)) { case 0: direction = 2; break; case 1: direction = 3; break; case 2: direction = 0; break; default: direction = 1; break; } continent.AdjoiningContinents[(CoreEnums.CardinalDirections)direction] = startingContinent; return continents; }