Play animation on GameObject click

So, I currently have a scene where there are 5 boxes and single sphere. My sphere currently has a rotate animation. My problem is how can I make the cube rotate only after clicking all the 5 boxes, where if not all the boxes are clicked the sphere will not rotate?

Try this:

function Update() {
	if(Input.GetMouseButtonDown (0))
	{
		animation.Play("animation");
	}
}

You can edit this to your liking as this is the basic version.