Advertisement
Guest User

Untitled

a guest
Jun 19th, 2016
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1.    public void Scan(float[,] _heightMap,int size,float waterLevel)
  2.     {
  3.         islandList.Clear();
  4.         MakeDeepCopy(_heightMap);
  5.        float minVal = CalculateMinVal(waterLevel);
  6.         for(int i=0; i < size; i++)
  7.             for (int j = 0; j < size; j++)
  8.             {
  9.                 if (heightMap[i, j] >= minVal)
  10.                 {
  11.                     islandPartsList.Add(new IslandNode(i,j, heightMap[i, j]));
  12.                     heightMap[i, j] = 0;
  13.                    newPos = FindNeighbour(i, j, minVal);
  14.                     if (newPos.x != -1 && newPos.y != -1)
  15.                     {
  16.                         Next(newPos, minVal);
  17.                         if(islandPartsList.Count > 10)
  18.                             islandList.Add(new Island(islandPartsList));
  19.                         islandPartsList.Clear();
  20.                     }
  21.                 }
  22.             }
  23.     }
  24.  
  25.     private void Next(Vector2 pos, float minVal)
  26.     {
  27.         islandPartsList.Add(new IslandNode((int)pos.x,(int)pos.y, heightMap[(int)pos.x, (int)pos.y]));
  28.         heightMap[(int)pos.x, (int)pos.y] = 0;
  29.         for (int i = 0; i < 3; i++)
  30.         {
  31.              newPos = FindNeighbour((int)pos.x, (int)pos.y, minVal);
  32.             if (newPos.x != -1 && newPos.y != -1)
  33.             {
  34.                 Next(newPos,minVal);
  35.             }
  36.         }
  37.        
  38.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement