public Hex(Vector2Int coords, LandscapeData landscapeType) { X = coords[0]; // "column" Z = coords[1]; // "row" LandscapeType = landscapeType; }
/// <summary> /// Goes over the board and reselects each landscape type using the influence of neighbouring hexes' landscape types. /// </summary> public void SmoothTerrainUsingInfluence() { foreach (Vector2Int coords in boardCoords) { IEnumerable <LandscapeData> neighbourScapes = Neighbors(coordsToHex[coords]).Select(x => x.LandscapeType); LandscapeData landscape = PickLandscapeUsingNeighbours(neighbourScapes); coordsToHex[coords].SetLandscapeData(landscape); } }
private Art(string mulFile, IndexFile indexFile, Stream dataStream) { this.mulFile = mulFile; this.indexFile = indexFile; this.dataStream = dataStream; tileObject = new LandscapeData(this); itemsObject = new ItemsData(this); animationsObject = new AnimationsData(this); }
/// <summary> /// Initializes the new empty Art object. /// </summary> public Art() { mulFile = null; dataStream = Stream.Null; indexFile = new IndexFile(); indexFile.Resize(65536); tileObject = new LandscapeData(this); itemsObject = new ItemsData(this); animationsObject = new AnimationsData(this); }
/// <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> /// Calculate the "support" for a landscape type based on its neighbours. /// </summary> private static float CalculateSupportFromNeighbours(LandscapeData landscape, IEnumerable <LandscapeData> neighbourLandscapes) { IEnumerable <float> influencesOnChoice = neighbourLandscapes .Select(x => LandscapeData.SupportValue(x.typeLabel, landscape.typeLabel)); float totalInfluence = 0; foreach (var influence in influencesOnChoice) { totalInfluence += influence; } return(totalInfluence); }
/// <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); }
public Landscape() { initialized = false; landscapeData = new LandscapeData(); }
public void SetLandscapeData(LandscapeData landscapeType) { LandscapeType = landscapeType; }