Example #1
0
        private bool ProcessBlockForPawn(int x, int y)
        {
            Block b = cb.GetBlockByChessPosition(new Point(x, y));

            if (b != null)
            {
                if (b.GetPiece() == null)
                {
                    return(false);
                }
                else
                {
                    if (b.GetPiece().GetPieceColor() == OrigBlock.GetPiece().GetPieceColor())
                    {
                        return(false);
                    }
                    else
                    {
                        ValidBlocks.Add(b);
                        return(true);
                    }
                }
            }
            return(false);
        }
Example #2
0
        internal override ArrayList CalculatePositions(Block block, bool SupportPosition)
        {
            base.CalculatePositions(block, SupportPosition);

            if (SupportPosition)
            {
                return(this.CalculateKillingPositions(block, SupportPosition));
            }
            else
            {
                if (player.GetPlayerType() == PlayerType.PLAYER1)
                {
                    if (OrigBlock.GetChessPosition().Y == 1)
                    {
                        GoDown(block.GetChessPosition(), 2);
                    }
                    else
                    {
                        GoDown(block.GetChessPosition(), 1);
                    }

                    GoLeftDown(block.GetChessPosition(), false);
                    GoRightDown(block.GetChessPosition(), false);
                }
                else if (player.GetPlayerType() == PlayerType.PLAYER2)
                {
                    if (OrigBlock.GetChessPosition().Y == 6)
                    {
                        GoUp(block.GetChessPosition(), 2);
                    }
                    else
                    {
                        GoUp(block.GetChessPosition(), 1);
                    }

                    GoLeftUp(block.GetChessPosition(), false);
                    GoRightUp(block.GetChessPosition(), false);
                }


                return(ValidBlocks);
            }
        }
Example #3
0
        protected new  bool ProcessBlock(int x, int y)
        {
            Block b = cb.GetBlockByChessPosition(new Point(x, y));

            if (b != null)
            {
                Piece piece = b.GetPiece();
                if (piece != null)
                {
                    if (piece.GetPieceColor() == OrigBlock.GetPiece().GetPieceColor())
                    {
                        return(false);
                    }
                }

                ValidBlocks.Add(b);
                return(false);
            }
            return(false);
        }
        private void CastlePositions()
        {
            if (OrigBlock == null)
            {
                return;
            }

            Piece piece = OrigBlock.GetPiece();

            if (piece == null)
            {
                return;
            }

            // It must be KING
            if (piece.GetPieceType() != PieceType.KING)
            {
                return;
            }

            // Must be able to castle
            if (!piece.GetCanCastle())
            {
                return;
            }

            Point point = OrigBlock.GetChessPosition();

            bool GotPiece = false;

            if (CanCastle(new Point(0, point.Y)))
            {
                for (int i = point.X - 1; i > 0; i--)
                {
                    Block b = cb.GetBlockByChessPosition(new Point(i, point.Y));

                    if (b.GetPiece() != null)
                    {
                        GotPiece = true;
                    }
                }

                if (!GotPiece)
                {
                    ValidBlocks.Add(cb.GetBlockByChessPosition(new Point(point.X - 2, point.Y)));
                }
            }


            GotPiece = false;

            if (CanCastle(new Point(7, point.Y)))
            {
                for (int i = point.X + 1; i < 7; i++)
                {
                    Block b = cb.GetBlockByChessPosition(new Point(i, point.Y));

                    if (b.GetPiece() != null)
                    {
                        GotPiece = true;
                    }
                }

                if (!GotPiece)
                {
                    ValidBlocks.Add(cb.GetBlockByChessPosition(new Point(point.X + 2, point.Y)));
                }
            }
        }