Sounds like your having Ecological Damage from high production bases. Reduce your production number, any base from around 73 and under will keep your Ecology Damage at Zero. Anything above that and you get the hoards, usually Locusts, from the Fungus.
Good defenses: Must have Neural Amplifier & Perimeter defense. Foils are not good defensive units. Infantry or HoverTanks are Ideal. In addition, if your going to have High production bases, better get Psi defense for your units.
I had a Hovertank--thats 1 tank--with Psi defense as armour with AAA abiltyand it withstood 15Locusts without even a scratch.
Hope this helps.