// Calculate the NetDifference around a cell private float netDiff(int x, int z) { float diff = 0f; float[,] array = elevation.worldArray; float[] cellsAround = Support.CellsAllAround(x, z, WorldX, WorldZ, array); foreach (float element in cellsAround) { diff += Mathf.Abs(array[x, z] - element); } return(diff / cellsAround.Length); }