예제 #1
0
        static void DiamondStep(float[,] arr, int range, int sx, int sz, int x, int z, int reach, MathLib.UCL_Random rnd)
        {
            //Debug.LogWarning("diamondStep x:" + x +",z:" + z);
            int   count = 0;
            float avg   = 0.0f;

            if (x - reach >= 0)
            {
                avg += arr[x - reach + sx, z + sz];
                count++;
            }
            if (x + reach < range)
            {
                avg += arr[x + reach + sx, z + sz];
                count++;
            }
            if (z - reach >= 0)
            {
                avg += arr[x + sx, z - reach + sz];
                count++;
            }
            if (z + reach < range)
            {
                avg += arr[x + sx, z + reach + sz];
                count++;
            }
            float val = reach / (float)range;

            avg += rnd.Range(-val, val);
            avg /= count;
            arr[x + sx, z + sz] = avg;
        }
예제 #2
0
        static void SquareStep(float[,] arr, int range, int x, int z, int reach, MathLib.UCL_Random rnd)
        {
            int   count = 0;
            float avg   = 0.0f;

            if (x - reach >= 0 && z - reach >= 0)
            {
                avg += arr[x - reach, z - reach];
                count++;
            }
            if (x - reach >= 0 && z + reach < range)
            {
                avg += arr[x - reach, z + reach];
                count++;
            }
            if (x + reach < range && z - reach >= 0)
            {
                avg += arr[x + reach, z - reach];
                count++;
            }
            if (x + reach < range && z + reach < range)
            {
                avg += arr[x + reach, z + reach];
                count++;
            }
            float val = reach / (float)range;

            avg      += rnd.Range(-val, val);
            avg      /= count;
            arr[x, z] = avg;
        }