private void addLandFeatures(List<MapHex> sourceList, terrainType terrain, int seedCount, int passes, float convChance) { List<MapHex> openList = new List<MapHex>(); List<MapHex> closedList = new List<MapHex>(); int rand; sourceList.TrimExcess(); //Choose a few seeds. for(int i=0;i<seedCount;i++){ rand = Random.Range(0,sourceList.Count); sourceList[rand].setTerrain (terrain); addNeighbours(sourceList[rand],openList,closedList,landTiles); sourceList.Remove(sourceList[rand]); } //Grow 'em like continents. for(int i=0;i<passes;i++){ for(int j=0;j<openList.Count;j++){ if(Random.value <= convChance){ openList[j].setTerrain(terrain); addNeighbours(openList[j],openList,closedList,landTiles); } closedList.Add(openList[j]); sourceList.Remove(openList[j]); } } }
public Node(worldObject _thing, terrainType _walk, Vector3Int _worldPos, orientation _dir) { placedThing = _thing; walkable = _walk; worldSpacePosition = _worldPos; texture = 1; direction = _dir; }
public void copyTile(Tile tileToCopy) { this.thisTileElement = tileToCopy.thisTileElement; this.thisTileTerrType = tileToCopy.thisTileTerrType; this.rowNum = tileToCopy.rowNum; this.columnNum = tileToCopy.columnNum; this.worldPos = tileToCopy.worldPos; this.gridH = tileToCopy.gridH; this.gridW = tileToCopy.gridW; this.gridIndex = tileToCopy.gridIndex; }
public void setTileTerrType(int newVal) { if (newVal >= 0 & newVal <= 2) { thisTileTerrType = (terrainType)newVal; } else { thisTileTerrType = (terrainType)0; } }
private terrainType[,] terrainGeneration(int width, int length) { terrainType[,] tempMap = new terrainType[length, width]; for (int i = 0; i < tempMap.GetLength(0); i++) { for (int j = 0; j < tempMap.GetLength(1); j++) { tempMap[i, j] = terrainType.grass; } } return(tempMap); }
private IEnumerator addSeaFeatures(List<MapHex> sourceList, terrainType terrain, int seedCount, int passes, float convChance) { List<MapHex> openList = new List<MapHex>(); List<MapHex> closedList = new List<MapHex>(); int rand; //Choose a few seeds. for(int i=0;i<seedCount;i++){ rand = Random.Range(0,sourceList.Count); sourceList[rand].setTerrain (terrain); addNeighbours(sourceList[rand],openList,closedList,seaTiles); sourceList.Remove(sourceList[rand]); updateTiles (); yield return new WaitForSeconds(0.01f); } //Grow 'em like continents. for(int i=0;i<passes;i++){ for(int j=0;j<openList.Count;j++){ if(Random.value <= convChance){ openList[j].setTerrain(terrain); addNeighbours(openList[j],openList,closedList,seaTiles); } closedList.Add(openList[j]); sourceList.Remove(openList[j]); } updateTiles (); yield return new WaitForSeconds(0.01f); } }
public void setTerrain(terrainType input) { terrain = input; }
public void initializeHex(terrainType input, int x, int y) { xCord = x; yCord = y; terrain = input; temperature = 1-(Mathf.Abs (yCord-WorldMap.height/2f))/WorldMap.height*2; temperature += Random.Range (-0.05f,0.05f); }
public GameObject findNearestType(terrainType target) { List<GameObject> openList = new List<GameObject>(); List<GameObject> tempAdd = new List<GameObject>(); List<GameObject> tempRem = new List<GameObject>(); List<GameObject> closedList = new List<GameObject>(); foreach(GameObject hex in neighborList){ if(hex.GetComponent<MapHex>().terrain == target){ return hex; } else { foreach(GameObject subHex in hex.GetComponent<MapHex>().neighborList){ if(!openList.Contains (subHex)){ openList.Add(subHex); } } } } while(openList.Count > 0){ foreach(GameObject hex in openList){ if(hex.GetComponent<MapHex>().terrain == target){ return hex; } else{ tempRem.Add(hex); closedList.Add(hex); foreach(GameObject subHex in hex.GetComponent<MapHex>().neighborList){ if(!openList.Contains (subHex) && !closedList.Contains (subHex)){ tempAdd.Add(subHex); } } } } foreach(GameObject hex in tempAdd){ openList.Add (hex); } foreach(GameObject hex in tempRem){ openList.Remove (hex); } tempAdd.Clear (); tempRem.Clear (); } return null; }