コード例 #1
0
ファイル: TileOrientation.cs プロジェクト: Zabanya/SharpFlame
 public static double GetRotatedAngle(sTileOrientation Orientation, double Angle)
 {
     Position.XY_dbl pos = new Position.XY_dbl((Math.Cos(Angle) + 1.0) / 2.0, (Math.Sin(Angle) + 1.0) / 2.0);
     Position.XY_dbl _dbl = GetTileRotatedPos_dbl(Orientation, pos);
     _dbl.X = (_dbl.X * 2.0) - 1.0;
     _dbl.Y = (_dbl.Y * 2.0) - 1.0;
     return Math.Atan2(_dbl.Y, _dbl.X);
 }
コード例 #2
0
ファイル: clsBrush.cs プロジェクト: Zabanya/SharpFlame
 private void PerformAction(clsMap.clsAction Action, sPosNum PosNum, modMath.sXY_int LastValidNum)
 {
     if (Action.Map == null)
     {
         Debugger.Break();
     }
     else
     {
         modMath.sXY_int posNum = this.GetPosNum(PosNum);
         Action.Effect = 1.0;
         int introduced11 = modMath.Clamp_int(this.Tiles.YMin + posNum.Y, 0, LastValidNum.Y);
         int introduced12 = modMath.Clamp_int(this.Tiles.YMax + posNum.Y, 0, LastValidNum.Y);
         int num4 = introduced12 - posNum.Y;
         for (int i = introduced11 - posNum.Y; i <= num4; i++)
         {
             Action.PosNum.Y = posNum.Y + i;
             int index = i - this.Tiles.YMin;
             int introduced13 = modMath.Clamp_int(this.Tiles.XMin[index] + posNum.X, 0, LastValidNum.X);
             int introduced14 = modMath.Clamp_int(this.Tiles.XMax[index] + posNum.X, 0, LastValidNum.X);
             int num5 = introduced14 - posNum.X;
             for (int j = introduced13 - posNum.X; j <= num5; j++)
             {
                 modMath.sXY_int _int2;
                 Action.PosNum.X = posNum.X + j;
                 if (Action.UseEffect && (this.Tiles.ResultRadius > 0.0))
                 {
                     switch (this._Shape)
                     {
                         case enumShape.Circle:
                         {
                             if (!this._Alignment)
                             {
                                 goto Label_01DD;
                             }
                             Position.XY_dbl _dbl = new Position.XY_dbl((double) Action.PosNum.X, (double) Action.PosNum.Y);
                             Position.XY_dbl _dbl2 = new Position.XY_dbl(posNum.X - 0.5, posNum.Y - 0.5);
                             Position.XY_dbl _dbl3 = _dbl - _dbl2;
                             Action.Effect = 1.0 - (_dbl3.GetMagnitude() / (this.Tiles.ResultRadius + 0.5));
                             break;
                         }
                         case enumShape.Square:
                         {
                             if (!this._Alignment)
                             {
                                 goto Label_02A3;
                             }
                             double introduced15 = Math.Abs((double) (Action.PosNum.X - (posNum.X - 0.5)));
                             Action.Effect = 1.0 - (Math.Max(introduced15, Math.Abs((double) (Action.PosNum.Y - (posNum.Y - 0.5)))) / (this.Tiles.ResultRadius + 0.5));
                             break;
                         }
                     }
                 }
                 goto Label_02FF;
             Label_01DD:
                 _int2 = posNum - Action.PosNum;
                 Action.Effect = 1.0 - (_int2.ToDoubles().GetMagnitude() / (this.Tiles.ResultRadius + 0.5));
                 goto Label_02FF;
             Label_02A3:
                 int introduced16 = Math.Abs((int) (Action.PosNum.X - posNum.X));
                 Action.Effect = 1.0 - (((double) Math.Max(introduced16, Math.Abs((int) (Action.PosNum.Y - posNum.Y)))) / (this.Tiles.ResultRadius + 0.5));
             Label_02FF:
                 Action.ActionPerform();
             }
         }
     }
 }
コード例 #3
0
ファイル: frmGenerator.cs プロジェクト: Zabanya/SharpFlame
        public void btnGenerateLayout_Click(Object sender, EventArgs e)
        {
            lstResult.Items.Clear();
            btnGenerateLayout.Enabled = false;
            lstResult_AddText("Generating layout.");
            Application.DoEvents();

            StopTrying = false;

            int LoopCount = 0;

            Generator.ClearLayout();

            Generator.GenerateTileset = null;
            Generator.Map = null;

            Generator.TopLeftPlayerCount = PlayerCount;

            switch ( cboSymmetry.SelectedIndex )
            {
                case 0: //none
                    Generator.SymmetryBlockCountXY.X = 1;
                    Generator.SymmetryBlockCountXY.Y = 1;
                    Generator.SymmetryBlockCount = 1;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryIsRotational = false;
                    break;
                case 1: //h rotation
                    Generator.SymmetryBlockCountXY.X = 2;
                    Generator.SymmetryBlockCountXY.Y = 1;
                    Generator.SymmetryBlockCount = 2;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    Generator.SymmetryBlocks[1].XYNum = new sXY_int(1, 0);
                    Generator.SymmetryBlocks[1].Orientation = new TileOrientation(true, true, false);
                    Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    Generator.SymmetryIsRotational = true;
                    break;
                case 2: //v rotation
                    Generator.SymmetryBlockCountXY.X = 1;
                    Generator.SymmetryBlockCountXY.Y = 2;
                    Generator.SymmetryBlockCount = 2;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    Generator.SymmetryBlocks[1].XYNum = new sXY_int(0, 1);
                    Generator.SymmetryBlocks[1].Orientation = new TileOrientation(true, true, false);
                    Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    Generator.SymmetryIsRotational = true;
                    break;
                case 3: //h flip
                    Generator.SymmetryBlockCountXY.X = 2;
                    Generator.SymmetryBlockCountXY.Y = 1;
                    Generator.SymmetryBlockCount = 2;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    Generator.SymmetryBlocks[1].XYNum = new sXY_int(1, 0);
                    Generator.SymmetryBlocks[1].Orientation = new TileOrientation(true, false, false);
                    Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    Generator.SymmetryIsRotational = false;
                    break;
                case 4: //v flip
                    Generator.SymmetryBlockCountXY.X = 1;
                    Generator.SymmetryBlockCountXY.Y = 2;
                    Generator.SymmetryBlockCount = 2;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    Generator.SymmetryBlocks[1].XYNum = new sXY_int(0, 1);
                    Generator.SymmetryBlocks[1].Orientation = new TileOrientation(false, true, false);
                    Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    Generator.SymmetryIsRotational = false;
                    Generator.SymmetryIsRotational = false;
                    break;
                case 5: //4x rotation
                    Generator.SymmetryBlockCountXY.X = 2;
                    Generator.SymmetryBlockCountXY.Y = 2;
                    Generator.SymmetryBlockCount = 4;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    Generator.SymmetryBlocks[0].ReflectToNum[1] = 2;
                    Generator.SymmetryBlocks[1].XYNum = new sXY_int(1, 0);
                    Generator.SymmetryBlocks[1].Orientation = new TileOrientation(true, false, true);
                    Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[1].ReflectToNum[0] = 3;
                    Generator.SymmetryBlocks[1].ReflectToNum[1] = 0;
                    Generator.SymmetryBlocks[2].XYNum = new sXY_int(0, 1);
                    Generator.SymmetryBlocks[2].Orientation = new TileOrientation(false, true, true);
                    Generator.SymmetryBlocks[2].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[2].ReflectToNum[0] = 0;
                    Generator.SymmetryBlocks[2].ReflectToNum[1] = 3;
                    Generator.SymmetryBlocks[3].XYNum = new sXY_int(1, 1);
                    Generator.SymmetryBlocks[3].Orientation = new TileOrientation(true, true, false);
                    Generator.SymmetryBlocks[3].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[3].ReflectToNum[0] = 2;
                    Generator.SymmetryBlocks[3].ReflectToNum[1] = 1;
                    Generator.SymmetryIsRotational = true;
                    break;
                case 6: //hv flip
                    Generator.SymmetryBlockCountXY.X = 2;
                    Generator.SymmetryBlockCountXY.Y = 2;
                    Generator.SymmetryBlockCount = 4;
                    Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(Generator.SymmetryBlockCount - 1) + 1];
                    Generator.SymmetryBlocks[0].XYNum = new sXY_int(0, 0);
                    Generator.SymmetryBlocks[0].Orientation = new TileOrientation(false, false, false);
                    Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    Generator.SymmetryBlocks[0].ReflectToNum[1] = 2;
                    Generator.SymmetryBlocks[1].XYNum = new sXY_int(1, 0);
                    Generator.SymmetryBlocks[1].Orientation = new TileOrientation(true, false, false);
                    Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    Generator.SymmetryBlocks[1].ReflectToNum[1] = 3;
                    Generator.SymmetryBlocks[2].XYNum = new sXY_int(0, 1);
                    Generator.SymmetryBlocks[2].Orientation = new TileOrientation(false, true, false);
                    Generator.SymmetryBlocks[2].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[2].ReflectToNum[0] = 3;
                    Generator.SymmetryBlocks[2].ReflectToNum[1] = 0;
                    Generator.SymmetryBlocks[3].XYNum = new sXY_int(1, 1);
                    Generator.SymmetryBlocks[3].Orientation = new TileOrientation(true, true, false);
                    Generator.SymmetryBlocks[3].ReflectToNum = new int[(((int)Math.Round((double)(((double)Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    Generator.SymmetryBlocks[3].ReflectToNum[0] = 2;
                    Generator.SymmetryBlocks[3].ReflectToNum[1] = 1;
                    Generator.SymmetryIsRotational = false;
                    break;
                default:
                    MessageBox.Show("Select symmetry");
                    btnGenerateLayout.Enabled = true;
                    return;
            }

            if ( Generator.TopLeftPlayerCount * Generator.SymmetryBlockCount < 2 )
            {
                MessageBox.Show("That configuration only produces 1 player.");
                btnGenerateLayout.Enabled = true;
                return;
            }
            if ( Generator.TopLeftPlayerCount * Generator.SymmetryBlockCount > 10 )
            {
                MessageBox.Show("That configuration produces more than 10 players.");
                btnGenerateLayout.Enabled = true;
                return;
            }

            Generator.TileSize.X = ValidateTextbox(txtWidth, 48.0D, 250.0D, 1.0D);
            Generator.TileSize.Y = ValidateTextbox(txtHeight, 48.0D, 250.0D, 1.0D);
            if ( Generator.SymmetryBlockCount == 4 )
            {
                if ( Generator.TileSize.X != Generator.TileSize.Y && Generator.SymmetryIsRotational )
                {
                    MessageBox.Show("Width and height must be equal if map is rotated on two axes.");
                    btnGenerateLayout.Enabled = true;
                    return;
                }
            }
            Generator.PlayerBasePos = new sXY_int[Generator.TopLeftPlayerCount];
            double BaseMin = 12.0D;
            Position.XY_dbl BaseMax =
                new Position.XY_dbl(Math.Min(Generator.TileSize.X / Generator.SymmetryBlockCountXY.X, Generator.TileSize.X - 12.0D),
                    Math.Min(Generator.TileSize.Y / Generator.SymmetryBlockCountXY.Y, Generator.TileSize.Y - 12.0D));
            Generator.PlayerBasePos[0] = new sXY_int(ValidateTextbox(txt1x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                ValidateTextbox(txt1y, BaseMin, BaseMax.X, App.TerrainGridSpacing));
            if ( Generator.TopLeftPlayerCount >= 2 )
            {
                Generator.PlayerBasePos[1] = new sXY_int(ValidateTextbox(txt2x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                    ValidateTextbox(txt2y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                if ( Generator.TopLeftPlayerCount >= 3 )
                {
                    Generator.PlayerBasePos[2] = new sXY_int(ValidateTextbox(txt3x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                        ValidateTextbox(txt3y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                    if ( Generator.TopLeftPlayerCount >= 4 )
                    {
                        Generator.PlayerBasePos[3] = new sXY_int(ValidateTextbox(txt4x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                            ValidateTextbox(txt4y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                        if ( Generator.TopLeftPlayerCount >= 5 )
                        {
                            Generator.PlayerBasePos[4] = new sXY_int(ValidateTextbox(txt5x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                                ValidateTextbox(txt5y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                            if ( Generator.TopLeftPlayerCount >= 6 )
                            {
                                Generator.PlayerBasePos[5] = new sXY_int(ValidateTextbox(txt6x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                                    ValidateTextbox(txt6y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                                if ( Generator.TopLeftPlayerCount >= 7 )
                                {
                                    Generator.PlayerBasePos[6] = new sXY_int(ValidateTextbox(txt7x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                                        ValidateTextbox(txt7y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                                    if ( Generator.TopLeftPlayerCount >= 8 )
                                    {
                                        Generator.PlayerBasePos[7] = new sXY_int(ValidateTextbox(txt8x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                                            ValidateTextbox(txt8y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                                        if ( Generator.TopLeftPlayerCount >= 9 )
                                        {
                                            Generator.PlayerBasePos[8] = new sXY_int(
                                                ValidateTextbox(txt9x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                                                ValidateTextbox(txt9y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                                            if ( Generator.TopLeftPlayerCount >= 10 )
                                            {
                                                Generator.PlayerBasePos[9] =
                                                    new sXY_int(ValidateTextbox(txt10x, BaseMin, BaseMax.X, App.TerrainGridSpacing),
                                                        ValidateTextbox(txt10y, BaseMin, BaseMax.Y, App.TerrainGridSpacing));
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Generator.LevelCount = ValidateTextbox(txtLevels, 3.0D, 5.0D, 1.0D);
            Generator.BaseLevel = ValidateTextbox(txtBaseLevel, -1.0D, Generator.LevelCount - 1, 1.0D);
            Generator.JitterScale = 1;
            Generator.MaxLevelTransition = 2;
            Generator.PassagesChance = ValidateTextbox(txtLevelFrequency, 0.0D, 100.0D, 1.0D);
            Generator.VariationChance = ValidateTextbox(txtVariation, 0.0D, 100.0D, 1.0D);
            Generator.FlatsChance = ValidateTextbox(txtFlatness, 0.0D, 100.0D, 1.0D);
            Generator.BaseFlatArea = ValidateTextbox(txtBaseArea, 1.0D, 16.0D, 1.0D);
            Generator.NodeScale = 4.0F;
            Generator.WaterSpawnQuantity = ValidateTextbox(txtWaterQuantity, 0.0D, 9999.0D, 1.0D);
            Generator.TotalWaterQuantity = ValidateTextbox(txtConnectedWater, 0.0D, 9999.0D, 1.0D);

            Application.DoEvents();
            LoopCount = 0;
            clsResult Result = default(clsResult);
            do
            {
                Result = new clsResult("");
                Result = Generator.GenerateLayout();
                if ( !Result.HasProblems )
                {
                    clsResult HeightsResult = FinishHeights();
                    Result.Add(HeightsResult);
                    if ( !HeightsResult.HasProblems )
                    {
                        lstResult_AddResult(Result);
                        lstResult_AddText("Done.");
                        btnGenerateLayout.Enabled = true;
                        break;
                    }
                }
                LoopCount++;
                lstResult_AddText("Attempt " + Convert.ToString(LoopCount) + " failed.");
                Application.DoEvents();
                if ( StopTrying )
                {
                    Generator.Map = null;
                    lstResult_AddResult(Result);
                    lstResult_AddText("Stopped.");
                    btnGenerateLayout.Enabled = true;
                    return;
                }
                lstResult_AddResult(Result);
                lstResult_AddText("Retrying...");
                Application.DoEvents();
                Generator.ClearLayout();
            } while ( true );
            lstResult_AddResult(Result);
        }
コード例 #4
0
ファイル: frmGenerator.cs プロジェクト: pcdummy/SharpFlame
        private void btnGenerateLayout_Click(object sender, EventArgs e)
        {
            this.lstResult.Items.Clear();
            this.btnGenerateLayout.Enabled = false;
            this.lstResult_AddText("Generating layout.");
            Application.DoEvents();
            this.StopTrying = false;
            this.Generator.ClearLayout();
            this.Generator.GenerateTileset = null;
            this.Generator.Map = null;
            this.Generator.TopLeftPlayerCount = this.PlayerCount;
            switch (this.cboSymmetry.SelectedIndex)
            {
                case 0:
                    this.Generator.SymmetryBlockCountXY.X = 1;
                    this.Generator.SymmetryBlockCountXY.Y = 1;
                    this.Generator.SymmetryBlockCount = 1;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryIsRotational = false;
                    break;

                case 1:
                    this.Generator.SymmetryBlockCountXY.X = 2;
                    this.Generator.SymmetryBlockCountXY.Y = 1;
                    this.Generator.SymmetryBlockCount = 2;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    this.Generator.SymmetryBlocks[1].XYNum = new modMath.sXY_int(1, 0);
                    this.Generator.SymmetryBlocks[1].Orientation = new TileOrientation.sTileOrientation(true, true, false);
                    this.Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    this.Generator.SymmetryIsRotational = true;
                    break;

                case 2:
                    this.Generator.SymmetryBlockCountXY.X = 1;
                    this.Generator.SymmetryBlockCountXY.Y = 2;
                    this.Generator.SymmetryBlockCount = 2;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    this.Generator.SymmetryBlocks[1].XYNum = new modMath.sXY_int(0, 1);
                    this.Generator.SymmetryBlocks[1].Orientation = new TileOrientation.sTileOrientation(true, true, false);
                    this.Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    this.Generator.SymmetryIsRotational = true;
                    break;

                case 3:
                    this.Generator.SymmetryBlockCountXY.X = 2;
                    this.Generator.SymmetryBlockCountXY.Y = 1;
                    this.Generator.SymmetryBlockCount = 2;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    this.Generator.SymmetryBlocks[1].XYNum = new modMath.sXY_int(1, 0);
                    this.Generator.SymmetryBlocks[1].Orientation = new TileOrientation.sTileOrientation(true, false, false);
                    this.Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    this.Generator.SymmetryIsRotational = false;
                    break;

                case 4:
                    this.Generator.SymmetryBlockCountXY.X = 1;
                    this.Generator.SymmetryBlockCountXY.Y = 2;
                    this.Generator.SymmetryBlockCount = 2;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    this.Generator.SymmetryBlocks[1].XYNum = new modMath.sXY_int(0, 1);
                    this.Generator.SymmetryBlocks[1].Orientation = new TileOrientation.sTileOrientation(false, true, false);
                    this.Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    this.Generator.SymmetryIsRotational = false;
                    break;

                case 5:
                    this.Generator.SymmetryBlockCountXY.X = 2;
                    this.Generator.SymmetryBlockCountXY.Y = 2;
                    this.Generator.SymmetryBlockCount = 4;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    this.Generator.SymmetryBlocks[0].ReflectToNum[1] = 2;
                    this.Generator.SymmetryBlocks[1].XYNum = new modMath.sXY_int(1, 0);
                    this.Generator.SymmetryBlocks[1].Orientation = new TileOrientation.sTileOrientation(true, false, true);
                    this.Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[1].ReflectToNum[0] = 3;
                    this.Generator.SymmetryBlocks[1].ReflectToNum[1] = 0;
                    this.Generator.SymmetryBlocks[2].XYNum = new modMath.sXY_int(0, 1);
                    this.Generator.SymmetryBlocks[2].Orientation = new TileOrientation.sTileOrientation(false, true, true);
                    this.Generator.SymmetryBlocks[2].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[2].ReflectToNum[0] = 0;
                    this.Generator.SymmetryBlocks[2].ReflectToNum[1] = 3;
                    this.Generator.SymmetryBlocks[3].XYNum = new modMath.sXY_int(1, 1);
                    this.Generator.SymmetryBlocks[3].Orientation = new TileOrientation.sTileOrientation(true, true, false);
                    this.Generator.SymmetryBlocks[3].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[3].ReflectToNum[0] = 2;
                    this.Generator.SymmetryBlocks[3].ReflectToNum[1] = 1;
                    this.Generator.SymmetryIsRotational = true;
                    break;

                case 6:
                    this.Generator.SymmetryBlockCountXY.X = 2;
                    this.Generator.SymmetryBlockCountXY.Y = 2;
                    this.Generator.SymmetryBlockCount = 4;
                    this.Generator.SymmetryBlocks = new clsGenerateMap.sSymmetryBlock[(this.Generator.SymmetryBlockCount - 1) + 1];
                    this.Generator.SymmetryBlocks[0].XYNum = new modMath.sXY_int(0, 0);
                    this.Generator.SymmetryBlocks[0].Orientation = new TileOrientation.sTileOrientation(false, false, false);
                    this.Generator.SymmetryBlocks[0].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[0].ReflectToNum[0] = 1;
                    this.Generator.SymmetryBlocks[0].ReflectToNum[1] = 2;
                    this.Generator.SymmetryBlocks[1].XYNum = new modMath.sXY_int(1, 0);
                    this.Generator.SymmetryBlocks[1].Orientation = new TileOrientation.sTileOrientation(true, false, false);
                    this.Generator.SymmetryBlocks[1].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[1].ReflectToNum[0] = 0;
                    this.Generator.SymmetryBlocks[1].ReflectToNum[1] = 3;
                    this.Generator.SymmetryBlocks[2].XYNum = new modMath.sXY_int(0, 1);
                    this.Generator.SymmetryBlocks[2].Orientation = new TileOrientation.sTileOrientation(false, true, false);
                    this.Generator.SymmetryBlocks[2].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[2].ReflectToNum[0] = 3;
                    this.Generator.SymmetryBlocks[2].ReflectToNum[1] = 0;
                    this.Generator.SymmetryBlocks[3].XYNum = new modMath.sXY_int(1, 1);
                    this.Generator.SymmetryBlocks[3].Orientation = new TileOrientation.sTileOrientation(true, true, false);
                    this.Generator.SymmetryBlocks[3].ReflectToNum = new int[(((int) Math.Round((double) (((double) this.Generator.SymmetryBlockCount) / 2.0))) - 1) + 1];
                    this.Generator.SymmetryBlocks[3].ReflectToNum[0] = 2;
                    this.Generator.SymmetryBlocks[3].ReflectToNum[1] = 1;
                    this.Generator.SymmetryIsRotational = false;
                    break;

                default:
                    Interaction.MsgBox("Select symmetry", MsgBoxStyle.ApplicationModal, null);
                    this.btnGenerateLayout.Enabled = true;
                    return;
            }
            if ((this.Generator.TopLeftPlayerCount * this.Generator.SymmetryBlockCount) < 2)
            {
                Interaction.MsgBox("That configuration only produces 1 player.", MsgBoxStyle.ApplicationModal, null);
                this.btnGenerateLayout.Enabled = true;
            }
            else if ((this.Generator.TopLeftPlayerCount * this.Generator.SymmetryBlockCount) > 10)
            {
                Interaction.MsgBox("That configuration produces more than 10 players.", MsgBoxStyle.ApplicationModal, null);
                this.btnGenerateLayout.Enabled = true;
            }
            else
            {
                this.Generator.TileSize.X = this.ValidateTextbox(this.txtWidth, 48.0, 250.0, 1.0);
                this.Generator.TileSize.Y = this.ValidateTextbox(this.txtHeight, 48.0, 250.0, 1.0);
                if ((this.Generator.SymmetryBlockCount == 4) && ((this.Generator.TileSize.X != this.Generator.TileSize.Y) & this.Generator.SymmetryIsRotational))
                {
                    Interaction.MsgBox("Width and height must be equal if map is rotated on two axes.", MsgBoxStyle.ApplicationModal, null);
                    this.btnGenerateLayout.Enabled = true;
                }
                else
                {
                    clsResult result;
                    this.Generator.PlayerBasePos = new modMath.sXY_int[(this.Generator.TopLeftPlayerCount - 1) + 1];
                    double min = 12.0;
                    double x = Math.Min((double) (((double) this.Generator.TileSize.X) / ((double) this.Generator.SymmetryBlockCountXY.X)), (double) (this.Generator.TileSize.X - 12.0));
                    Position.XY_dbl _dbl = new Position.XY_dbl(x, Math.Min((double) (((double) this.Generator.TileSize.Y) / ((double) this.Generator.SymmetryBlockCountXY.Y)), (double) (this.Generator.TileSize.Y - 12.0)));
                    this.Generator.PlayerBasePos[0] = new modMath.sXY_int(this.ValidateTextbox(this.txt1x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt1y, min, _dbl.X, 128.0));
                    if (this.Generator.TopLeftPlayerCount >= 2)
                    {
                        this.Generator.PlayerBasePos[1] = new modMath.sXY_int(this.ValidateTextbox(this.txt2x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt2y, min, _dbl.Y, 128.0));
                        if (this.Generator.TopLeftPlayerCount >= 3)
                        {
                            this.Generator.PlayerBasePos[2] = new modMath.sXY_int(this.ValidateTextbox(this.txt3x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt3y, min, _dbl.Y, 128.0));
                            if (this.Generator.TopLeftPlayerCount >= 4)
                            {
                                this.Generator.PlayerBasePos[3] = new modMath.sXY_int(this.ValidateTextbox(this.txt4x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt4y, min, _dbl.Y, 128.0));
                                if (this.Generator.TopLeftPlayerCount >= 5)
                                {
                                    this.Generator.PlayerBasePos[4] = new modMath.sXY_int(this.ValidateTextbox(this.txt5x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt5y, min, _dbl.Y, 128.0));
                                    if (this.Generator.TopLeftPlayerCount >= 6)
                                    {
                                        this.Generator.PlayerBasePos[5] = new modMath.sXY_int(this.ValidateTextbox(this.txt6x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt6y, min, _dbl.Y, 128.0));
                                        if (this.Generator.TopLeftPlayerCount >= 7)
                                        {
                                            this.Generator.PlayerBasePos[6] = new modMath.sXY_int(this.ValidateTextbox(this.txt7x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt7y, min, _dbl.Y, 128.0));
                                            if (this.Generator.TopLeftPlayerCount >= 8)
                                            {
                                                this.Generator.PlayerBasePos[7] = new modMath.sXY_int(this.ValidateTextbox(this.txt8x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt8y, min, _dbl.Y, 128.0));
                                                if (this.Generator.TopLeftPlayerCount >= 9)
                                                {
                                                    this.Generator.PlayerBasePos[8] = new modMath.sXY_int(this.ValidateTextbox(this.txt9x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt9y, min, _dbl.Y, 128.0));
                                                    if (this.Generator.TopLeftPlayerCount >= 10)
                                                    {
                                                        this.Generator.PlayerBasePos[9] = new modMath.sXY_int(this.ValidateTextbox(this.txt10x, min, _dbl.X, 128.0), this.ValidateTextbox(this.txt10y, min, _dbl.Y, 128.0));
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    this.Generator.LevelCount = this.ValidateTextbox(this.txtLevels, 3.0, 5.0, 1.0);
                    this.Generator.BaseLevel = this.ValidateTextbox(this.txtBaseLevel, -1.0, (double) (this.Generator.LevelCount - 1), 1.0);
                    this.Generator.JitterScale = 1;
                    this.Generator.MaxLevelTransition = 2;
                    this.Generator.PassagesChance = this.ValidateTextbox(this.txtLevelFrequency, 0.0, 100.0, 1.0);
                    this.Generator.VariationChance = this.ValidateTextbox(this.txtVariation, 0.0, 100.0, 1.0);
                    this.Generator.FlatsChance = this.ValidateTextbox(this.txtFlatness, 0.0, 100.0, 1.0);
                    this.Generator.BaseFlatArea = this.ValidateTextbox(this.txtBaseArea, 1.0, 16.0, 1.0);
                    this.Generator.NodeScale = 4f;
                    this.Generator.WaterSpawnQuantity = this.ValidateTextbox(this.txtWaterQuantity, 0.0, 9999.0, 1.0);
                    this.Generator.TotalWaterQuantity = this.ValidateTextbox(this.txtConnectedWater, 0.0, 9999.0, 1.0);
                    Application.DoEvents();
                    int num2 = 0;
                    while (true)
                    {
                        result = new clsResult("");
                        result = this.Generator.GenerateLayout();
                        if (!result.HasProblems)
                        {
                            clsResult resultToAdd = this.FinishHeights();
                            result.Add(resultToAdd);
                            if (!resultToAdd.HasProblems)
                            {
                                this.lstResult_AddResult(result);
                                this.lstResult_AddText("Done.");
                                this.btnGenerateLayout.Enabled = true;
                                break;
                            }
                        }
                        num2++;
                        this.lstResult_AddText("Attempt " + Conversions.ToString(num2) + " failed.");
                        Application.DoEvents();
                        if (this.StopTrying)
                        {
                            this.Generator.Map = null;
                            this.lstResult_AddResult(result);
                            this.lstResult_AddText("Stopped.");
                            this.btnGenerateLayout.Enabled = true;
                            return;
                        }
                        this.lstResult_AddResult(result);
                        this.lstResult_AddText("Retrying...");
                        Application.DoEvents();
                        this.Generator.ClearLayout();
                    }
                    this.lstResult_AddResult(result);
                }
            }
        }