コード例 #1
0
ファイル: ThudPiece.cs プロジェクト: vgeirnaert/boardsoup
        public void switchWith(ThudPiece argPiece, ThudBoard board)
        {
            foreach (NEIGHBOUR n in myNeighbours.Keys)
            {
                argPiece.setNeighbour(n, myNeighbours[n]);
            }

            board.addActor(argPiece);
            board.deleteFromBoard(this);
        }
コード例 #2
0
ファイル: ThudPiece.cs プロジェクト: vgeirnaert/boardsoup
        public void setNeighbour(NEIGHBOUR argNeighbour, ThudPiece argPiece, bool recursive)
        {
            if (myNeighbours.ContainsKey(argNeighbour))
            {
                myNeighbours[argNeighbour] = argPiece;
            }
            else
            {
                myNeighbours.Add(argNeighbour, argPiece);
            }

            if (recursive)
            {
                argPiece.setNeighbour(getOppositeNeighbour(argNeighbour), this, false);
            }
        }
コード例 #3
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]);
                        }
                    }
                }
            }
        }