Ejemplo n.º 1
0
        /// <summary>
        /// 柏林噪声产生地形数据,
        /// </summary>
        private void GenerateTerrain()
        {
            var perlin = new CPerlinMap(m_numCols, m_numRows);

            perlin.Generate();

            //处理高地
            //存储高地的数据
            //1代表是高地, 0代表高地被平了
            int[,] hillGrid = new int[m_numCols, m_numRows];

            var type = (int)CPCGLayer.Terrain;

            for (int x = 0; x < m_numCols; x++)
            {
                for (int z = 0; z < m_numRows; z++)
                {
                    CForestTerrainSubType subType = GetSubTypeAtHeight(perlin[x, z]);
                    m_grid.FillData(x, z, type, (int)subType, CForestUtil.GetTerrainTypeWalkable(subType));
                    hillGrid[x, z] = 0;
                    if (subType == CForestTerrainSubType.Hill)
                    {
                        hillGrid[x, z] = 1;
                    }
                }
            }


            m_cell.SmoothOnce(hillGrid);
            var hillType = (int)CForestTerrainSubType.Hill;
            var landType = (int)CForestTerrainSubType.Land1;

            m_floodFill.Process(hillGrid, 11, 1, 0);
            //将处理过后的数据返还给assets
            for (int x = 0; x < m_numCols; x++)
            {
                for (int z = 0; z < m_numRows; z++)
                {
                    var subType = m_grid.GetNodeSubType(x, z);
                    if (subType == hillType && hillGrid[x, z] == 0)
                    {
                        m_grid.FillData(x, z, type, landType, true);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 柏林噪声产生地形数据
 /// </summary>
 public void Generate(int cols, int rows)
 {
     m_map = new CPerlinMap(cols, rows);
     m_map.Generate();
 }