예제 #1
0
    void defineAlti()
    {
        for (int idx = 0; idx < x; idx++)
        {
            for (int idy = 0; idy < y; idy++)
            {
                int alti = (int)((UnityEngine.Random.value * 4 - 1) * z / 4);

                map.Add(idx, idy, alti);
            }
        }
        interpol(interpolLev);
    }
예제 #2
0
    void interpol(int size = 1)
    {
        int   its = 0;
        float moy = 0;

        //int pond = 1;
        grid2D <int> newVals = new grid2D <int>();

        //**
        for (int idx = 0; idx < x; idx++)
        {
            for (int idy = 0; idy < y; idy++)
            {
                //coins
                //x - size ; y - size
                //x - size ; y + size
                //x + size ; y - size
                //x + size ; y + size
                //**
                for (int xx = idx - size; xx <= idx + size; xx++)
                {
                    for (int yy = idy - size; yy <= idy + size; yy++)
                    {
                        if (map.ContainsObject(idx, idy))
                        {
                            its++;
                            moy += map.GetItem(idx, idy);
                        }
                    }
                }
                //**/
                newVals.Add(idx, idy, (int)(moy /= (float)its));

                its = 1;
            }
        }

        map = newVals;
        //**/
    }