Beispiel #1
0
        private void AIOnlineWoker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (isAIOnlineWin == true)
            {
                isAIOnlineWin = false;
                return;
            }

            Button b = (Button)grid.Children[12 * (int)AI_online.X + (int)AI_online.Y];

            if ((int)AI_online.X % 2 == 0 && (int)AI_online.Y % 2 == 0 || (int)AI_online.X % 2 != 0 && (int)AI_online.Y % 2 != 0)
            {
                setBackground(b, p1);
            }
            else
            {
                setBackground(b, p1_1);
            }

            player1.mark((int)AI_online.X, (int)AI_online.Y);

            BoardMerge[(int)AI_online.X, (int)AI_online.Y] = 2;

            online_me.X = (int)AI_online.X;
            online_me.Y = (int)AI_online.Y;

            MainWindow.socket.Emit("MyStepIs", JObject.FromObject(new { row = (int)AI_online.X, col = (int)AI_online.Y }));
        }
Beispiel #2
0
        private void myWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            Button b = (Button)grid.Children[12 * (int)AI.X + (int)AI.Y];

            if ((int)AI.X % 2 == 0 && (int)AI.Y % 2 == 0 || (int)AI.X % 2 != 0 && (int)AI.Y % 2 != 0)
            {
                setBackground(b, p2);
            }
            else
            {
                setBackground(b, p2_1);
            }

            player2.mark((int)AI.X, (int)AI.Y);

            BoardMerge[(int)AI.X, (int)AI.Y] = 2;

            int result2 = player2.check((int)AI.X, (int)AI.Y);

            if (result2 != 0)
            {
                MessageBox.Show("AI win!");
                //highlight dong win
                highlight(player2, result2, p2_h);
                isWin = true;
            }
        }