5. If the complex conjugate of the complex number $z$ is $\bar{z}$, and $|z|=1$, and $A$ $=(-1,0)$ and $B=(0,-1)$ are fixed points, then the function $f(z)$ $=|(z+1)(\bar{z}-i)|$ takes its maximum value when the figure formed by points $Z, A, B$ on the complex plane is ( ).
(A) Isosceles triangle
(B) Right triangle
(C) Isosceles right triangle
(כ) Equilateral triangle
5.C.

Let $z=\cos \theta+i \sin \theta$, then
$$
\begin{aligned}
f(z) & =|(z+1)(\bar{z}-i)| \\
& =|(\cos \theta+1+i \sin \theta)[\cos \theta-i(\sin \theta+1)]| \\
& =|1+\sin \theta+\cos \theta+i(1+\sin \theta+\cos \theta)| \\
& =\sqrt{2\left[1+\sqrt{2} \sin \left(\theta+\frac{\pi}{4}\right)\right]^{2}} .
\end{aligned}
$$

When $\theta=2 k \pi+\frac{\pi}{4}$ (where $k \in \mathbb{Z}$), $f(z)$ reaches its maximum value $2+\sqrt{2}$. At this time, $z=\cos \frac{\pi}{4}+i \sin \frac{\pi}{4}$. Therefore, the figure formed by points $Z, A, B$ is an equilateral triangle.