Ejemplo n.º 1
0
        public static RectGrid BiomeMap(RectGrid input, Project proj, int cutoff, float equator, int[] newRank)
        {
            RectGrid moistureGrid = Biomes.moisture(input, proj, cutoff);
            RectGrid tempGrid     = Biomes.Temperature(input, equator);
            RectGrid biomeGrid    = new RectGrid(input.Height, input.Width);

            int[,] converted = new int[6, 6];

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 6; j++)
                {
                    converted[i, j] = newRank[biomeTable[i, j]];
                }
            }

            int tempDex;
            int moistDex;

            for (int row = 0; row < input.Height; row++)
            {
                for (int col = 0; col < input.Width; col++)
                {
                    if (input.getTile(row, col).Value < proj.SeaLevel)
                    {
                        biomeGrid.getTile(row, col).Rank = 9;
                        continue;
                    }
                    moistDex = (int)(moistureGrid.getTile(row, col).Value * 5);
                    tempDex  = (int)(tempGrid.getTile(row, col).Value * 5);
                    biomeGrid.getTile(row, col).Rank = converted[moistDex, tempDex];
                }
            }

            return(biomeGrid);
        }
Ejemplo n.º 2
0
        public void renderGrid()
        {
            if (selectedNode == null)
            {
                return;
            }
            Graphics   g = testPanel.CreateGraphics();
            SolidBrush b = new SolidBrush(Color.Red);

            GridDisplayEquiRect.Hexagon[] hexList = currentProject.EquiDisp.dispHex;
            GeoGrid geo = new GeoGrid(currentProject.Frequency);

            PointF[] curHex = new PointF[6];
            float    offX   = testPanel.Width / 2.0f;
            float    offY   = testPanel.Height / 2.0f;
            int      brightness;

            RectGrid moisture = Biomes.moisture(selectedNode.getOutputGrid(), currentProject, 6);

            currentProject.EquiDisp.RectToGeo(moisture, geo);

            //currentProject.EquiDisp.RectToGeo(selectedNode.getOutputGrid(), geo);


            //geo = Biomes.seaLevel(geo, currentProject);
            //currentProject.EquiDisp.LoadGrid(geo);

            /*Tile[] mates = geo.neighbors(0,geo.getFrequency()-1,1);
             * for(int i=0; i<mates.Length; i++)
             * {
             *  mates[i].Value = 0.1f * i;
             * }*/

            for (int i = 0; i < hexList.Length; i++)
            {
                brightness = (int)(hexList[i].tile.Value * 255);
                b.Color    = Color.FromArgb(brightness, brightness, brightness);
                if (!hexList[i].isEdge)
                {
                    for (int j = 0; j < 6; j++)
                    {
                        curHex[j] = new PointF(offX + hexList[i].equiVec[j].X * (testPanel.Width / 2.0f), offY + hexList[i].equiVec[j].Y * (testPanel.Height / 2.0f));
                    }
                    g.FillPolygon(b, curHex);
                }
                else
                {
                    for (int j = 0; j < 6; j++)
                    {
                        if (hexList[i].equiVec[j].X <= 0)
                        {
                            curHex[j] = new PointF(testPanel.Width + offX + hexList[i].equiVec[j].X * (testPanel.Width / 2.0f), offY + hexList[i].equiVec[j].Y * (testPanel.Height / 2.0f));
                        }
                        else
                        {
                            curHex[j] = new PointF(offX + hexList[i].equiVec[j].X * (testPanel.Width / 2.0f), offY + hexList[i].equiVec[j].Y * (testPanel.Height / 2.0f));
                        }
                    }
                    g.FillPolygon(b, curHex);
                    for (int j = 0; j < 6; j++)
                    {
                        if (hexList[i].equiVec[j].X >= 0)
                        {
                            curHex[j] = new PointF(-testPanel.Width + offX + hexList[i].equiVec[j].X * (testPanel.Width / 2.0f), offY + hexList[i].equiVec[j].Y * (testPanel.Height / 2.0f));
                        }
                        else
                        {
                            curHex[j] = new PointF(offX + hexList[i].equiVec[j].X * (testPanel.Width / 2.0f), offY + hexList[i].equiVec[j].Y * (testPanel.Height / 2.0f));
                        }
                    }
                    g.FillPolygon(b, curHex);
                }
            }
            counterDB++;
            testPanel.Update();
        }