예제 #1
0
 private void _generateNoise(System.Random rng, TerrainData data)
 {
     int width = data.Width;
     int height = data.Height;
     for (int y = 0; y < height; y++)
     {
         for(int x = 0; x < width; x++)
         {
             data.SetValue(x, y, rng.NextDouble() < m_randomFillChance ? 1 : 0);
         }
     }
 }
예제 #2
0
    private void _circleCull(TerrainData data)
    {
        int centerX = m_width / 2;
        int centerY = m_height / 2;
        Vector2 center = new Vector2(centerX, centerY);
        int radius = Mathf.Min(m_width, m_height) / 2;

        for (int y = 0; y < m_height; y++)
        {
            for (int x = 0; x < m_width; x++)
            {
                Vector2 point = new Vector2(x, y);
                if ((point - center).magnitude > radius)
                    data.SetValue(x, y, 0);
            }
        }
    }
예제 #3
0
    private void _smoothMap(System.Random rng, TerrainData data)
    {
        int width = data.Width;
        int height = data.Height;

        int[,] newData = new int[width,height];

        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                int filledCount = data.FilledNeighbors(x, y);
                if (filledCount > 4)
                {
                    data.SetValue(x, y, 1);
                }
                else if(filledCount < 4)
                {
                    data.SetValue(x, y, 0);
                }
            }
        }
    }