public GameForm(Difficulity difficulity) { InitializeComponent(); Ai = new AI(difficulity); status = GameStatus.X_turn; this.SizeChanged += (sender, e) => { CenterizeAllControls(); }; GameFinished += OnGameFinished; AIthread = new Thread(AI); //Debug waste helpL.Enabled = false; EasyB.Enabled = false; MediumB.Enabled = false; HardB.Enabled = false; PvPB.Enabled = false; ReWriteB.Enabled = false; Undo.Enabled = false; helpL.Visible = false; EasyB.Visible = false; MediumB.Visible = false; HardB.Visible = false; PvPB.Visible = false; ReWriteB.Visible = false; Undo.Visible = false; //end of debug waste this.difficulity = difficulity; if (Program.Game == null) { Program.Game = this; } else { this.Close(); this.Dispose(); return; } ThreadPool.init(); CheckForIllegalCrossThreadCalls = false; IsXTurn = true; ended = false; game = new GameLogic(); cellsP = new PictureBox[3, 3]; // Box1.Click+= CellClick; cellsP[0, 0] = Box1; cellsP[0, 1] = Box2; cellsP[0, 2] = Box3; cellsP[1, 0] = Box4; cellsP[1, 1] = Box5; cellsP[1, 2] = Box6; cellsP[2, 0] = Box7; cellsP[2, 1] = Box8; cellsP[2, 2] = Box9; Ximg = Box1.BackgroundImage; Oimg = Box2.BackgroundImage; clearImg = Box3.BackgroundImage; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (!(i == 0 && j == 0)) { cellsP[i, j].Click += CellClick; } } } Clear(); PvPB.FlatStyle = FlatStyle.Popup; this.FormClosing += (x, y) => { if (Program.Game == this) { Program.Game = null; } }; this.BackColor = Color.Empty; this.BackgroundImage = null; Color left, right; left = Color.Salmon; right = Color.DarkViolet; if (this.difficulity == Difficulity.easy) { left = Color.Green; right = Color.White; } if (this.difficulity == Difficulity.medium) { left = Color.Orange; right = Color.Green; } if (this.difficulity == Difficulity.hard) { left = Color.Red; right = Color.Orange; } if (this.difficulity == Difficulity.pvp) { left = Color.Navy; right = Color.Red; } Bitmap bitmap = CreateGradient(left, right, new Tools.Imageing.Resolution(Width, Height)); this.BackgroundImage = Image.FromHbitmap(bitmap.GetHbitmap()); CenterizeAllControls(); }
private Position BruteForce(GameLogic gl, CellE me) { return(new Position(-1, -1)); }