コード例 #1
0
        public override void Execute(object parameter)
        {
            if (CanSelect())
            {
                //ConsoleManager.Show();
                //Console.WriteLine("Hello FROM tILES!");

                Pieces = (parameter as BoardVM).Pieces;
                Tiles  = (parameter as BoardVM).Tiles;

                //Pieces.Clear();
                Utils.RedrawTiles();

                foreach (var tile in GameBusiness.selectedTiles)
                {
                    if (tile == cellVM)
                    {
                        GameBusiness.movesForSelectedPiece.Sort(
                            (move1, move2) => - move1.TakenPieces.Count.CompareTo(move2.TakenPieces.Count));

                        foreach (var move in GameBusiness.movesForSelectedPiece)
                        {
                            if (move.FinalLocation.Equals(tile.Location))
                            {
                                foreach (var piece in move.TakenPieces)
                                {
                                    Pieces.Remove(piece);
                                }
                                break;
                            }
                        }

                        GameBusiness.selectedPiece.Piece.PieceLocation = tile.Location;
                        break;
                    }
                }
                GameBusiness.IsKing(GameBusiness.selectedPiece);
                if (GameBusiness.IsFinal(Pieces))
                {
                    BoardVM.CurentWindows.StartNewGame();
                }
                GameBusiness.ChangePlayer();
                (parameter as BoardVM).IsPlayer1 = true;

                GameBusiness.selectedPiece.IsSelected = System.Windows.Media.Colors.Black;
            }
        }