How to translate a OOP class diagram to a unity game/unity code

Iv’e been coding games in c#, visual studio using OOP. Before starting a project i’ve always liked to draw up a class diagram to get an idea of how everything, the classes and objects are going to be connected.

And now after transitioning to Unity and scripting, i’m a bit confused to how i’m supposed to organize my scripts and connect them and the GameObjects. So i’ve come to understand that Unity consists of GameObjects in the scene, which consists of components, which a script is.

And lastly, i’m now starting a project on a 3D Tower Defense game and have drawn a class diagram as i would have for a Visual Studio game. How do i translate this to GameObjects, components and scripts in unity, thank you.

For the towers:

public abstract class Tower : MonoBehaviour { }
    [SerializeField] protected float _fireRate;
    [SerializeField] protected float _damage;
public class MachineGun : Tower { }
public class LaserGun : Tower { }

and for the enemies:

public abstract class Enemy : MonoBehaviour
    [SerializeField] protected float _health;
public class Tank : Enemy { }
public class Archer : Enemy { }

Then you can store generic tower / enemy code in those respective classes and it’ll be the implementations of these classes - machinegun, lasergun, tank and archer - that you add to your game objects.

Well you didn’t show the class diagram so I’ll just make up an example of the easy way to do this.

For the tower AI you could make an abstract class, defining all the parameters required for a tower (e.g. fire rate, damage, etc.). Put in all the methods that you expect all towers to be doing (e.g. aiming at enemies) and define the methods that you expect each child to do differently as an abstract method (e.g. Shooting). Once you’re done, just put that script as a component to the tower gameobject and save it as a prefab.

You’ll also need Manager scripts and scripts that would handle the projectile of course, but I’ll leave you to figure that one out.