Exemple #1
0
        public void CreateWhiteRookTest()
        {
            var pieceFactory = new WhitePieceFactory();
            var whiteRook    = pieceFactory.Create("rook");

            Assert.IsNotNull(whiteRook);
        }
Exemple #2
0
        public void CreateWhiteKnightTest()
        {
            var pieceFactory = new WhitePieceFactory();
            var whiteKnight  = pieceFactory.Create("knight");

            Assert.IsNotNull(whiteKnight);
        }
Exemple #3
0
        public void CreateWhiteBishopTest()
        {
            var pieceFactory = new WhitePieceFactory();
            var whiteBishop  = pieceFactory.Create("bishop");

            Assert.IsNotNull(whiteBishop);
        }
Exemple #4
0
        public void CreateWhiteKingTest()
        {
            var pieceFactory = new WhitePieceFactory();
            var whiteKing    = pieceFactory.Create("king");

            Assert.IsNotNull(whiteKing);
        }
Exemple #5
0
        public void CreateWhiteQueenTest()
        {
            var pieceFactory = new WhitePieceFactory();
            var whiteQueen   = pieceFactory.Create("queen");

            Assert.IsNotNull(whiteQueen);
        }
Exemple #6
0
        public void WhiteFactoryNullTest()
        {
            var pieceFactory = new WhitePieceFactory();
            var nullPiece    = pieceFactory.Create("noPiece");

            Assert.IsNull(nullPiece);
        }
Exemple #7
0
        public void CreateWhitePawnTest()
        {
            var pieceFactory = new WhitePieceFactory();

            var whitePawn = pieceFactory.Create("pawn");

            Assert.IsNotNull(whitePawn);
        }
Exemple #8
0
    public static void Default(ChessBoard board, List <ChessPiece> whitePieces, List <ChessPiece> blackPieces, out ChessPiece whiteKing, out ChessPiece blackKing)
    {
        ChessFactory whiteFactory = new WhitePieceFactory();
        ChessFactory blackFactory = new BlackPieceFactory();

        for (int i = 0; i < 8; i++)
        {
            whitePieces.Add(whiteFactory.CreatePiece <Pawn>(board, i, 1));
        }
        whitePieces.Add(whiteFactory.CreatePiece <Rook>(board, 0, 0));
        whitePieces.Add(whiteFactory.CreatePiece <Rook>(board, 7, 0));
        whitePieces.Add(whiteFactory.CreatePiece <Knight>(board, 1, 0));
        whitePieces.Add(whiteFactory.CreatePiece <Knight>(board, 6, 0));
        whitePieces.Add(whiteFactory.CreatePiece <Bishop>(board, 2, 0));
        whitePieces.Add(whiteFactory.CreatePiece <Bishop>(board, 5, 0));
        whitePieces.Add(whiteFactory.CreatePiece <Queen>(board, 3, 0));
        whiteKing = whiteFactory.CreatePiece <King>(board, 4, 0);
        whitePieces.Add(whiteKing);

        for (int i = 0; i < 8; i++)
        {
            blackPieces.Add(blackFactory.CreatePiece <Pawn>(board, i, 6));
        }
        blackPieces.Add(blackFactory.CreatePiece <Rook>(board, 0, 7));
        blackPieces.Add(blackFactory.CreatePiece <Rook>(board, 7, 7));
        blackPieces.Add(blackFactory.CreatePiece <Knight>(board, 1, 7));
        blackPieces.Add(blackFactory.CreatePiece <Knight>(board, 6, 7));
        blackPieces.Add(blackFactory.CreatePiece <Bishop>(board, 2, 7));
        blackPieces.Add(blackFactory.CreatePiece <Bishop>(board, 5, 7));
        blackPieces.Add(blackFactory.CreatePiece <Queen>(board, 3, 7));
        blackKing = blackFactory.CreatePiece <King>(board, 4, 7);
        blackPieces.Add(blackKing);

        board.uiPromotion.SetPromotionOptions <Queen>(1, new SpriteHolder {
            whiteSprite = GameManager.SpriteManager["whiteQueen"], blackSprite = GameManager.SpriteManager["blackQueen"], name = "Queen"
        });
        board.uiPromotion.SetPromotionOptions <Knight>(2, new SpriteHolder {
            whiteSprite = GameManager.SpriteManager["whiteKnight"], blackSprite = GameManager.SpriteManager["blackKnight"], name = "Knight"
        });
        board.uiPromotion.SetPromotionOptions <Rook>(3, new SpriteHolder {
            whiteSprite = GameManager.SpriteManager["whiteRook"], blackSprite = GameManager.SpriteManager["blackRook"], name = "Rook"
        });
        board.uiPromotion.SetPromotionOptions <Bishop>(4, new SpriteHolder {
            whiteSprite = GameManager.SpriteManager["whiteBishop"], blackSprite = GameManager.SpriteManager["blackBishop"], name = "Bishop"
        });
    }
Exemple #9
0
    public void Promote <T>() where T : ChessPiece
    {
        ChessFactory factory;

        if (GetTeam() == Team.White)
        {
            factory = new WhitePieceFactory();
        }
        else
        {
            factory = new BlackPieceFactory();
        }

        promoted = factory.CreatePiece <T>();
        promoted.SetPattern(out patterns);
        this.GetGameObject().GetComponent <SpriteRenderer>().sprite = promoted.SetSprite();
    }
Exemple #10
0
        public void CreateWhitePieceFactoryTest()
        {
            var pieceFactory = new WhitePieceFactory();

            Assert.IsNotNull(pieceFactory);
        }