Example #1
0
    public static void CreatePiecePrefabAndInitialize(Vector2Int squareIndex, PieceType pieceType, TeamColor teamColor,
                                                      ChessGridInfo grid, ChessPlayer player)
    {
        Piece       newPiece = CreateChessPiece(squareIndex, pieceType, grid, player);
        PieceEntity entity   = PieceFactory.CreatePiecePrefab(pieceType.ToString()).GetComponent <PieceEntity>();

        IMovable pieceMovementType = PieceFactory.GetMovementType(pieceType.ToString()) == MovementType.MovesInLine ?
                                     new MoveInLine() as IMovable : new Jump();

        newPiece.SetData(squareIndex, squareIndex, pieceType, teamColor, false, pieceMovementType, entity);
        player.AddPiece(newPiece);
    }