Ejemplo n.º 1
0
        private void createBoard()
        {
            //make pieces
            for (int x = 0; x < 15; x++)
            {
                for (int y = 0; y < 15; y++)
                {
                    if (!isCorner(x, y))
                    {
                        bool even = false;
                        if ((x % 2 == 0 && y % 2 == 0) || (x % 2 == 1 && y % 2 == 1))
                        {
                            even = true;
                        }

                        BoardPiece tp = new BoardPiece(x * 66 + offset, y * 66 + offset, even);
                        tp.setLogic(logic);
                        tp.setBoardPosition(x, y);
                        this.addActor(tp);
                        pieces[x, y] = tp;
                    }
                }
            }

            // set neighbours
            for (int x = 0; x < 15; x++)
            {
                for (int y = 0; y < 15; y++)
                {
                    if (pieceExists(x, y))
                    {
                        ThudPiece current = pieces[x, y];

                        if (pieceExists(x, y - 1))
                        {
                            current.setNeighbour(NEIGHBOUR.NORTH, pieces[x, y - 1]);
                        }

                        if (pieceExists(x + 1, y - 1))
                        {
                            current.setNeighbour(NEIGHBOUR.NORTHEAST, pieces[x + 1, y - 1]);
                        }

                        if (pieceExists(x + 1, y))
                        {
                            current.setNeighbour(NEIGHBOUR.EAST, pieces[x + 1, y]);
                        }

                        if (pieceExists(x + 1, y + 1))
                        {
                            current.setNeighbour(NEIGHBOUR.SOUTHEAST, pieces[x + 1, y + 1]);
                        }

                        if (pieceExists(x, y + 1))
                        {
                            current.setNeighbour(NEIGHBOUR.SOUTH, pieces[x, y + 1]);
                        }

                        if (pieceExists(x - 1, y + 1))
                        {
                            current.setNeighbour(NEIGHBOUR.SOUTHWEST, pieces[x - 1, y + 1]);
                        }

                        if (pieceExists(x - 1, y))
                        {
                            current.setNeighbour(NEIGHBOUR.WEST, pieces[x - 1, y]);
                        }

                        if (pieceExists(x - 1, y - 1))
                        {
                            current.setNeighbour(NEIGHBOUR.NORTHWEST, pieces[x - 1, y - 1]);
                        }
                    }
                }
            }
        }