예제 #1
0
        public void CreateBlackKnightTest()
        {
            var pieceFactory = new BlackPieceFactory();
            var blackKnight  = pieceFactory.Create("knight");

            Assert.IsNotNull(blackKnight);
        }
예제 #2
0
        public void CreateBlackKingTest()
        {
            var pieceFactory = new BlackPieceFactory();
            var blackKing    = pieceFactory.Create("king");

            Assert.IsNotNull(blackKing);
        }
예제 #3
0
        public void CreateBlackQueenTest()
        {
            var pieceFactory = new BlackPieceFactory();
            var blackQueen   = pieceFactory.Create("queen");

            Assert.IsNotNull(blackQueen);
        }
예제 #4
0
        public void CreateBlackRookTest()
        {
            var pieceFactory = new BlackPieceFactory();
            var blackRook    = pieceFactory.Create("rook");

            Assert.IsNotNull(blackRook);
        }
예제 #5
0
        public void CreateBlackBishopTest()
        {
            var pieceFactory = new BlackPieceFactory();
            var blackBishop  = pieceFactory.Create("bishop");

            Assert.IsNotNull(blackBishop);
        }
예제 #6
0
        public void BlackFactoryNullTest()
        {
            var pieceFactory = new BlackPieceFactory();
            var nullPiece    = pieceFactory.Create("noPiece");

            Assert.IsNull(nullPiece);
        }
예제 #7
0
        public void CreateBlackPawnTest()
        {
            var pieceFactory = new BlackPieceFactory();

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

            Assert.IsNotNull(blackPawn);
        }
예제 #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"
        });
    }
예제 #9
0
파일: Pawn.cs 프로젝트: skyexzs/ChessUnity
    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();
    }
예제 #10
0
        public void CreateBlackPieceFactoryTest()
        {
            var pieceFactory = new BlackPieceFactory();

            Assert.IsNotNull(pieceFactory);
        }