Exemplo n.º 1
0
        void AttachComputer()
        {
            computer = new Computer();
            computer.OnMoveReady += delegate(Move bmove)
            {
                Piece pm = (Piece)Board._pieces[(bmove.From / 8) + "x" + (bmove.From % 8)];
                int c = bmove.To / 8, r = bmove.To % 8;
                canvas1.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(delegate()
                {
                    pm.Move(c, r);
                    statusTextBlock.Text = "Listo";

                    CheckAlert();
                }));
            };

            canvas1.OnMoveComplete += (int acol, int arow, int bcol, int brow, PieceColor color) =>
            {
                if (color == MainColor && Type != GameType.REPLAY)
                {
                    statusTextBlock.Text = "Pensando...";
                    computer.NextMove();
                }
            };
        }
Exemplo n.º 2
0
 public void ResetElements()
 {
     computer = null;
     canvas1.OnMoveComplete = null;
     History.Clear();
     result = "*";
     Board.whites = true;
     playerGrid.Visibility = System.Windows.Visibility.Collapsed;
     MenuItem item = (MenuItem)((MenuItem)menu1.Items[1]).Items[1];
     item.Header = "Reproducir";
     item.IsEnabled = false;
 }