First-principles prediction of layered antiperovskite superconductors A2CNi4 (A = Al, Ga, and Sn)