In my game, I have a player, ennemies and tiles like Mario. And each entity has a different behavior when it touches a tile. For exemple, when my player walks on spike he dies. But a certain type of ennemy can walk on spike without dying.
Is there a good way to write this interaction between objets in OOP. I mean without cast, without breaking OCP principle and not having to write every behavior in every objects. Is there a design pattern for this purpose ?