private void Click(object sender, MouseButtonEventArgs e) { Point x = e.MouseDevice.GetPosition(this); int xx = (int)x.X / 64; int yy = (int)x.Y / 64; if (b.board[xx, yy].av == 1 && selected == false) { b.board[xx, yy].selected = true; selected = true; sx = xx; sy = yy; } else if (selected)//jesli zaznaczony { //foreach (var p in whitePieces) // znajdz ktory Piece p = whitePieces.Find(item => item.x == sx && item.y == sy); { if (p.x == sx && p.y == sy) //jw { if (p.movement(b, sx, sy, xx, yy, true)) // sprawdz logike { if (b.board[xx, yy].av == 2) // zbijanie { for (int bl = 0; bl < blackPieces.Count; bl++) { if (blackPieces[bl].x == xx && blackPieces[bl].y == yy) { blackPieces.RemoveAt(bl); } } } p.x = xx; p.y = yy; b.board[xx, yy].av = 1; b.board[sx, sy].av = 0; b.board[sx, sy].c = '1'; b.board[xx, yy].c = p.c; selected = false; client.SendMove(string.Format("{0} {1} {2} {3}", sx, sy, xx, yy), "gracz2@pawel"); //adapter.ComputeAnswer(b, b.board[sx, sy].character, b.board[sx, sy].number, b.board[xx, yy].character, b.board[xx, yy].number); b.startpos = false; //ruch komputera foreach (var bl in blackPieces) { if (bl.x == adapter.answer[0] && bl.y == adapter.answer[1]) { if (b.board[adapter.answer[2], adapter.answer[3]].av == 1) { for (int wh = 0; wh < whitePieces.Count; wh++) { if (whitePieces[wh].x == adapter.answer[2] && whitePieces[wh].y == adapter.answer[3]) { whitePieces.RemoveAt(wh); } } } bl.x = adapter.answer[2]; bl.y = adapter.answer[3]; b.board[adapter.answer[0], adapter.answer[1]].c = '1'; b.board[adapter.answer[2], adapter.answer[3]].c = bl.c; b.board[adapter.answer[0], adapter.answer[1]].av = 0; b.board[adapter.answer[2], adapter.answer[3]].av = 2; } } Console.WriteLine(b.FEN()); b.AV(); } else { selected = false; } } else { selected = false; } } } else { selected = false; } C1.Children.Clear(); b.draw(C1, dc); foreach (var p in whitePieces) { p.draw(C1); } foreach (var p in blackPieces) { p.draw(C1); } }