public CountryGenerator(IOrganisationFactory organisationFactory, IMapOrganizationGenerator mapOrganizationGenerator, Func <int, int, int> random) { _organisationFactory = organisationFactory ?? throw new ArgumentNullException(nameof(organisationFactory)); _mapOrganizationGenerator = mapOrganizationGenerator ?? throw new ArgumentNullException(nameof(mapOrganizationGenerator)); _random = random ?? throw new ArgumentNullException(nameof(random)); }
// Start is called before the first frame update private void Start() { var points = new List <Point>(); try { Debug.Log(Application.dataPath); Debug.Log(Application.persistentDataPath); _mapObject = new GameObject("Map"); if (LoadMapFromCache()) { return; } _hexGrid = new HexGrid(Height, Width, HexTile); _map = new HexMap(Height, Width); _organisationFactory = new OrganisationFactory(); _mapOrganizationGenerator = new MapOrganizationGenerator(_mapObject, _organisationFactory); _countryGenerator = new CountryGenerator(_organisationFactory, _mapOrganizationGenerator); var heightMapGenerator = new HeightMapGenerator(MountainRatio); _terrainGenerator = new TerrainGenerator(heightMapGenerator); _terrainGenerator.DesertBelt = DesertBelt; _terrainGenerator.PoleBelt = PoleBelt; var voronoiMap = GenerateMap(); points = voronoiMap.Where(g => g is Site).Select(s => s.Point).ToList(); _provinceFactory = new ProvinceFactory(_map, _lines, Instantiate, Province, _organisationFactory); _regions = _provinceFactory.CreateProvinces(points); Debug.Log("Map check after region detection"); CheckMap(points); var majorCountryNames = SettingsLoader.Instance.MajorCountryNames; var minorCountryNames = SettingsLoader.Instance.MinorCountryNames; _countryNames = majorCountryNames.Union(minorCountryNames).ToList(); _countryGenerator.GenerateCountries(_regions, _map, MajorCountries, MinorCountries, ProvincesMajorCountries, ProvincesMinorCountries, majorCountryNames, minorCountryNames, Instantiate, Country, CountryColors); _mapOrganizationGenerator.GenerateContinentsList(Instantiate, Continent, _regions, _map, _mapObject); _terrainGenerator.GenerateTerrain(_map); var resources = SettingsLoader.Instance.ResourceSettings; ResourceService.Instance.SpreadResources(_map, resources); if (MapMode == MapMode.InGame) { SkinMap(); } else { ColorCountries(); } StoreMapIntoCache(); var siteCommands = string.Join(", ", points.Select(p => $"new Point({p.X}, {p.Y})")); var siteListComand = $"var points = new List<Point> {{ {siteCommands} }};"; Debug.Log(siteListComand); } catch (Exception e) { Debug.LogError(e); LogMap(); var siteCommands = string.Join(", ", points.Select(p => $"new Point({p.X}, {p.Y})")); var siteListComand = $"var points = new List<Point> {{ {siteCommands} }};"; Debug.Log(siteListComand); Debug.Log("var lines = new List<Position>()"); Debug.Log("{"); foreach (var line in _lines) { Debug.Log($"new Position({line.X}, {line.Y})"); } Debug.Log("}"); } }
public CountryGenerator(IOrganisationFactory organisationFactory, IMapOrganizationGenerator mapOrganizationGenerator) : this(organisationFactory, mapOrganizationGenerator, UnityEngine.Random.Range) { }