It doesn't matter whether the attorney is on contingency or hourly. If he recovers his fees, then it may reduce the amount that he takes from his client. Regardless, if he is entitled to his fees, a court can order them. His fee agreement with his client is irrelevant.
However, it is very difficult to recover attorney's fees. New York follows what is called the American Rule, which essentially says that you not entitled to recover attorney's fees incurred in pursuing or defending against litigation
unless there is a statute or other exception that says that you can. For example, there is a rule that allows the court to grant attorney's fees if the other side engages in frivolous conduct (ie if one side files a motion that has no legitimate basis, the other side can recover fees for the time it took to answer the motion). A court may order fees if there is bad faith on the part of the plaintiff in bringing a lawsuit with no merit, forcing a defendant to engage counsel. The right to fees may be part of a contract
due to a relationship between the parties (for example, a lease
usually contains a provision that a landlord gets x amount in attorney's fees if they have to take the tenant to court for failure to pay rent). But generally in a standard civil case, there is no right to recovery unless there is a special rule or it is part of a contract.