This thesis provides a comprehensive view of the physics of charmed hadrons in high-energy proton-proton and heavy-ion collisions. Given their large masses, charm quarks are produced in the early stage of a heavy-ion collision and they subsequently experience the full system evolution probing the colour-deconfined medium called quark-gluon plasma (QGP) created in such collisions. In this thesis, the mechanisms of charm-quark in-medium energy loss and hadronisation are discussed via the measurements of the production of charm mesons with (Ds+) and without (D+) strange-quark content in different colliding systems, using data collected by the ALICE experiment at the CERN LHC. The participation of the charm quark and its possible thermalisation in the QGP are studied via measurements of azimuthal anisotropies in the production of D+ mesons. Finally, the prospects for future measurements with the upgraded ALICE experimental apparatus and with more refined machine learning techniques are presented.