The Mecha Sonic fight is pretty easy. To make your life easier, you could use Protect as your first move. Don't bother with Fira, Attack or Scan. Mecha Sonic self destructs when its HP dips below 200. Make sure to have at least 2000 HP when that happens. If you heal as soon as your HP drops below 2000, you'll be fine.
As for Eggman, use Protect as your first move. When the Master Emerald is sealed, use Attack. You should also use this time to use Healer if your HP is below 2000. When and only when the Master Emerald is charging, use G. Beam, Triple Shot and Purple Vortex. When you have less EP than is required to use G. Beam, move on to Triple Shot, and then to Purple Vortex. Don't bother using Fira or Scan.