Avoid relying on dynamic_cast in libtiled

It's not needed anymore since the layer type is stored now. This allows
libtiled to be used without RTTI.