Пример #1
0
        public Map(int size, float maxValue, int octaves, float persistence, MapTextureType textureType)
        {
            this.size     = size;
            this.maxValue = (maxValue < 1) ? 1 : maxValue;

            GenerateMap(octaves, persistence, textureType);
        }
        private void GenerateMap()
        {
            int            size        = (int)mapSizeControl.Value;
            int            maxValue    = (int)numericUpDown_maxValue.Value;
            int            octaves     = (int)numericUpDown_octaves.Value;
            float          persistence = (float)trackBar_persistence.Value / 20;
            MapTextureType textureType = (MapTextureType)comboBox_mapTexture.SelectedIndex;

            generatedMap = new Map(size, maxValue, octaves, persistence, textureType);

            mapPanel = new MapPanel(generatedMap);
            panel_mapPanelContainer.Controls.Clear();
            panel_mapPanelContainer.Controls.Add(mapPanel);
        }
Пример #3
0
        public void GenerateMap(int octaves, float persistence, MapTextureType textureType)
        {
            mapNodes = new Node[size, size];

            MapGenerator gen = new MapGenerator(size, maxValue, octaves, persistence, textureType);

            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    mapNodes[i, j]      = new Node(i, j);
                    mapNodes[i, j].cost = gen.GetValues()[i, j];
                }
            }
            SetupNeighbours();
        }
        public MapGenerator(int size, float maxValue, int octaves, float persistence, MapTextureType textureType)
        {
            this.size        = size;
            this.maxValue    = maxValue;
            this.textureType = textureType;
            this.octaves     = octaves;
            this.persistence = persistence;

            value = new float[size, size];
            for (int i = 0; i < size; i++)
            {
                for (int j = 0; j < size; j++)
                {
                    value[i, j] = 0;
                }
            }

            Perlin();
            FinalizeValues();
        }