Exemplo n.º 1
0
        private void GenerateTree()
        {
            var perlin = new CUnityRandomMap(m_numCols, m_numRows);

            perlin.Generate();

            var type        = (int)CPCGLayer.Block;
            var scaleHeight = 1.0f / BlockPercent;
            var noneType    = (int)CForestBlockSubType.None;

            for (int col = 0; col < m_numCols; col++)
            {
                for (int row = 0; row < m_numRows; row++)
                {
                    var height = perlin[col, row];

                    //不是树
                    if (height > BlockPercent)
                    {
                        m_grid.FillData(col, row, type, noneType, true);
                        continue;
                    }

                    height *= scaleHeight;
                    var subType = GetSubTypeAtHeight(height);
                    m_grid.FillData(col, row, type, (int)subType, false);
                }
            }
        }
Exemplo n.º 2
0
        private void GenerateDecal()
        {
            var perlin = new CUnityRandomMap(m_numCols, m_numRows);

            perlin.Generate();

            var type        = (int)CPCGLayer.Decal;
            var scaleHeight = 1.0f / DecalPercent;
            var noneType    = 0;

            for (int col = 0; col < m_numCols; col++)
            {
                for (int row = 0; row < m_numRows; row++)
                {
                    var height = perlin[col, row];

                    //没有在放置范围
                    if (height > DecalPercent)
                    {
                        m_grid.FillData(col, row, type, noneType, true);
                        continue;
                    }

                    height *= scaleHeight;
                    var subType = GetSubTypeAtHeight(height);
                    m_grid.FillData(col, row, type, subType, true);
                }
            }
        }