We investigate the influence of carbon-ion irradiation on the superconducting critical properties of MgB$_2$ thin films. MgB$_2$ films of two thicknesses viz. 400 nm (MB400nm) and 800 nm (MB800nm) were irradiated by 350 keV C ions having a wide range of fluence, 1 x 10$^{13}$ - 1 x 10$^{15}$ C atoms/cm$^2$. The mean projected range ($R_p$) of 350 keV C ions in MgB$_2$ is 560 nm, thus the energetic C ions will pass through the MB400nm, whereas the ions will remain into the MB800nm. The superconducting transition temperature ($T_c$), upper critical field ($H_{c2}$), $c$-axis lattice parameter, and corrected residual resistivity ($rho_{corr}$) of both the films showed similar trends with the variation of fluence. However, a disparate behavior in the superconducting phase transition was observed in the MB800nm when the fluence was larger than 1 x 10$^{14}$ C atoms/cm$^2$ because of the different Tcs between the irradiated and non-irradiated parts of the film. Interestingly, the superconducting critical properties, such as $T_c$, $H_{c2}$, and $J_c$, of the irradiated MgB$_2$ films, as well as the lattice parameter, were almost restored to those in the pristine state after a thermal annealing procedure. These results demonstrate that the atomic lattice distortion induced by C-ion irradiation is the main reason for the change in the superconducting properties of MgB$_2$ films.