It's all about modality (though, some more context is definitely needed):
To express unreal present you are to use the 2nd conditional sentences with would + bare infinitive in the main part:
If I were the richest man in the world, I would be the happiest one. (right now-present moment)
To express unreal (hypothetical) situation or state in the past, you are to opt for the 3d conditional with would have+participle2:
If I had been rich 10 years ago, I would have been famous then.-it's all about the past
Sometimes you may face mixed conditionals:
If Jerry were smart (always, including the moment of speaking), he would have passed his test last year (past event).
If Jim had applied for this possition (past event), he would be working here right now instead of you (present situation).
Hope you got the idea))