Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void Scan(float[,] _heightMap,int size,float waterLevel)
- {
- islandList.Clear();
- MakeDeepCopy(_heightMap);
- float minVal = CalculateMinVal(waterLevel);
- for(int i=0; i < size; i++)
- for (int j = 0; j < size; j++)
- {
- if (heightMap[i, j] >= minVal)
- {
- islandPartsList.Add(new IslandNode(i,j, heightMap[i, j]));
- heightMap[i, j] = 0;
- newPos = FindNeighbour(i, j, minVal);
- if (newPos.x != -1 && newPos.y != -1)
- {
- Next(newPos, minVal);
- if(islandPartsList.Count > 10)
- islandList.Add(new Island(islandPartsList));
- islandPartsList.Clear();
- }
- }
- }
- }
- private void Next(Vector2 pos, float minVal)
- {
- islandPartsList.Add(new IslandNode((int)pos.x,(int)pos.y, heightMap[(int)pos.x, (int)pos.y]));
- heightMap[(int)pos.x, (int)pos.y] = 0;
- for (int i = 0; i < 3; i++)
- {
- newPos = FindNeighbour((int)pos.x, (int)pos.y, minVal);
- if (newPos.x != -1 && newPos.y != -1)
- {
- Next(newPos,minVal);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement