/// <summary> /// Sets the "seed" for the terrain by setting the hex tiles to have random landscape types. /// </summary> public void InitialiseTerrain() { coordsToHex = new Dictionary <Vector2Int, Hex>(); foreach (Vector2Int coords in boardCoords) { LandscapeData landscape = LandscapeData.ChooseRandomLandscape(); Hex newHex = new Hex(coords, landscape); coordsToHex[coords] = newHex; } SmoothTerrainUsingInfluence(); }
/// <summary> /// Chooses a landscape given neighbouring landscapes. /// </summary> /// <param name="neighbourLandscapes"></param> /// <param name="maxAttempts"></param> /// <returns></returns> private static LandscapeData PickLandscapeUsingNeighbours(IEnumerable <LandscapeData> neighbourLandscapes, int maxAttempts = 100) { LandscapeData choice = null; float support = 0; bool choiceAccepted = false; for (int i = 0; i < maxAttempts; i++) { choice = LandscapeData.ChooseRandomLandscape(); support = CalculateSupportFromNeighbours(choice, neighbourLandscapes); choiceAccepted = support > UnityEngine.Random.Range(0, 61); if (choiceAccepted) { break; } } return(choice); }