I doubt it affected much. Honestly, most people who wanted to play Pokémon on the 3DS had already bought one for X/Y long before, and bought Sun or Moon when it came out. I've downloaded games here and there, sure, but I bought Y, Omega Ruby, Alpha Sapphire, Sun, and Moon, as they released. I didn't buy Ultra Moon/Ultra Sun because of the huge similarity to their predecessors, and for no reason other than that would I have not bought them, too.
I'm sure a lot of people pirated Sun/Moon, but a lot of people most definitely pirated X/Y as well, even though piracy was beyond a pretty large paywall at that time with Gateway.