private int NeedToFillSandAt( WorldGenerator worldGenerator, IntRect area, int i, int j) { ALandLayerGenerator altitudeLandLayerGenerator = worldGenerator.Generators["altitude"]; bool[,] subAreaBool = new bool[3, 3]; int[,] subAreaInt = new int[3, 3]; int maxValue = int.MinValue; int minValue = int.MaxValue; for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { double preAltitude = altitudeLandLayerGenerator.GetPowerAt(new Vector2f(area.Left + j + x, area.Top + i + y)); int altitude = (int)Math.Round(preAltitude); maxValue = Math.Max(maxValue, altitude); minValue = Math.Min(minValue, altitude); subAreaInt[y + 1, x + 1] = altitude; } } bool needToFill = false; if (subAreaInt[1, 1] != maxValue) { for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { if (subAreaInt[y, x] != maxValue) { subAreaBool[y, x] = false; } else { subAreaBool[y, x] = true; } } } needToFill = ALandLayerGenerator.NeedToFill(ref subAreaBool); } if (needToFill) { return(maxValue); } return(subAreaInt[1, 1]); }
public static int NeedToFillLandAt( int[,] mountainArea, IntRect area, int i, int j) { bool[,] subAreaBool = new bool[3, 3]; int[,] subAreaInt = new int[3, 3]; int maxValue = int.MinValue; int minValue = int.MaxValue; for (int y = -1; y < 2; y++) { for (int x = -1; x < 2; x++) { int altitude = mountainArea[i + y + 2, j + x + 2]; maxValue = Math.Max(maxValue, altitude); minValue = Math.Min(minValue, altitude); subAreaInt[y + 1, x + 1] = altitude; } } bool needToFill = false; if (subAreaInt[1, 1] != maxValue) { for (int y = 0; y < 3; y++) { for (int x = 0; x < 3; x++) { if (subAreaInt[y, x] != maxValue) { subAreaBool[y, x] = false; } else { subAreaBool[y, x] = true; } } } needToFill = ALandLayerGenerator.NeedToFill(ref subAreaBool); } if (needToFill) { return(maxValue); } return(subAreaInt[1, 1]); }