Пример #1
0
        public override List<Point> NextMovements(BaseFigure[,] grid, bool inclusiveAttackMoves)
        {
            List<Point> result = new List<Point>();

            int direction = 1;
            if (Team == Player.Teams.TeamWhite) direction = -1;

            try {
                if (grid[X, Y + direction] == null) result.Add(new Point(X, Y + direction)); //Normal movement
            } catch (IndexOutOfRangeException) {}

            try {
                if(((Y == 6 && Team == Player.Teams.TeamWhite) || (Y == 1 && Team == Player.Teams.TeamBlack)) //Pawn is on start position
                        && grid[X, Y + direction] == null //And can move 1 step
                        && grid[X, Y + 2 * direction] == null) //And can move 2 steps
                    result.Add(new Point(X, Y + 2 * direction));
            } catch (IndexOutOfRangeException) {}

            try {
                if(inclusiveAttackMoves && grid[X + 1, Y + direction] != null && grid[X + 1, Y + direction].Team != Team) //Move diagonal & attack enemy
                    result.Add(new Point(X + 1, Y + direction));
            } catch(IndexOutOfRangeException) { }

            try {
                if(inclusiveAttackMoves && grid[X - 1, Y + direction] != null && grid[X - 1, Y + direction].Team != Team) //Move diagonal & attack enemy
                    result.Add(new Point(X - 1, Y + direction));
            } catch(IndexOutOfRangeException) { }

            return result;
        }
Пример #2
0
 public override List<Point> NextMovements(BaseFigure[,] grid, bool inclusiveAttackMoves)
 {
     List<Point> result = new List<Point>();
     AddBishopMovement(grid, result, inclusiveAttackMoves);
     AddRookMovement(grid, result, inclusiveAttackMoves);
     //return EraseDuplicateEntries(result);
     return result;
 }
Пример #3
0
        public override List<Point> NextMovements(BaseFigure[,] grid, bool inclusiveAttackMoves)
        {
            List<Point> curList = new List<Point>();
            try {
                for(int x = 1; x < GameLogic.GRID_SIZE; x++) {
                    int newX = X + x;
                    int newY = Y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int x = 1; x < GameLogic.GRID_SIZE; x++) {
                    int newX = X - x;
                    int newY = Y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int y = 1; y < GameLogic.GRID_SIZE; y++) {
                    int newX = X;
                    int newY = Y + y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int y = 1; y < GameLogic.GRID_SIZE; y++) {
                    int newX = X;
                    int newY = Y - y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            return curList;
        }
Пример #4
0
        private void AddBishopMovement(BaseFigure[,] grid, List<Point> curList, bool inclusiveAttackMoves)
        {
            try {
                for(int i = 1; i < GameLogic.GRID_SIZE; i++) {
                    int newX = X + i;
                    int newY = Y + i;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int i = 1; i < GameLogic.GRID_SIZE; i++) {
                    int newX = X + i;
                    int newY = Y - i;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int i = 1; i < GameLogic.GRID_SIZE; i++) {
                    int newX = X - i;
                    int newY = Y + i;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int i = 1; i < GameLogic.GRID_SIZE; i++) {
                    int newX = X - i;
                    int newY = Y - i;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }
        }
Пример #5
0
 public override List<Point> NextMovements(BaseFigure[,] grid, bool inclusiveAttackMoves)
 {
     List<Point> result = new List<Point>();
     try { if(grid[X + 1, Y + 1] == null ||  (grid[X + 1, Y + 1].Team != Team    && inclusiveAttackMoves))   result.Add(new Point(X + 1, Y + 1)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X + 1, Y] == null     ||  (grid[X + 1, Y].Team != Team        && inclusiveAttackMoves))   result.Add(new Point(X + 1, Y)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X + 1, Y - 1] == null ||  (grid[X + 1, Y - 1].Team != Team    && inclusiveAttackMoves))   result.Add(new Point(X + 1, Y - 1)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X, Y + 1] == null     ||  (grid[X, Y + 1].Team != Team        && inclusiveAttackMoves))   result.Add(new Point(X, Y + 1)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X, Y - 1] == null     ||  (grid[X, Y - 1].Team != Team        && inclusiveAttackMoves))   result.Add(new Point(X, Y - 1)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X - 1, Y + 1] == null ||  (grid[X - 1, Y + 1].Team != Team    && inclusiveAttackMoves))   result.Add(new Point(X - 1, Y + 1)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X - 1, Y] == null     ||  (grid[X - 1, Y].Team != Team        && inclusiveAttackMoves))   result.Add(new Point(X - 1, Y)); } catch(IndexOutOfRangeException) { }
     try { if(grid[X - 1, Y - 1] == null ||  (grid[X - 1, Y - 1].Team != Team    && inclusiveAttackMoves))   result.Add(new Point(X - 1, Y - 1)); } catch(IndexOutOfRangeException) { }
     return result;
 }
Пример #6
0
 public Field(BaseFigure figure)
 {
     this.Figure = figure;
 }
Пример #7
0
        private void AddRookMovement(BaseFigure[,] grid, List<Point> curList, bool inclusiveAttackMoves)
        {
            try {
                for(int x = 1; x < GameLogic.GRID_SIZE; x++) {
                    int newX = X + x;
                    int newY = Y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int x = 1; x < GameLogic.GRID_SIZE; x++) {
                    int newX = X - x;
                    int newY = Y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int y = 1; y < GameLogic.GRID_SIZE; y++) {
                    int newX = X;
                    int newY = Y + y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }

            try {
                for(int y = 1; y < GameLogic.GRID_SIZE; y++) {
                    int newX = X;
                    int newY = Y - y;
                    if(grid[newX, newY] != null) {
                        if(grid[newX, newY].Team != Team && inclusiveAttackMoves)
                            curList.Add(new Point(newX, newY));
                        break;
                    }
                    curList.Add(new Point(newX, newY));
                }
            } catch(IndexOutOfRangeException) { }
        }
Пример #8
0
 public BaseFigure[,] ConvertGameGridToBaseFigureGrid()
 {
     BaseFigure[,] resultGrid = new BaseFigure[GRID_SIZE, GRID_SIZE];
     for (int y = 0; y < GRID_SIZE; y++) {
         for (int x = 0; x < GRID_SIZE; x++) {
             resultGrid[x, y] = _gameGrid[x, y].Figure;
         }
     }
     return resultGrid;
 }
Пример #9
0
 public abstract List<Point> NextMovements(BaseFigure[,] grid, bool inclusiveAttackMoves);