So I’m somewhat of a noobie to Unity. I’ve dabbled in it since Unity 3, but never actually made anything constructive or worth mentioning. I’ve been a C#, ASP.NET, and JAVA programmer by career for more than 5 years after graduating with my degree in Computer Science. So I want to throw out there that I do understand OOP. So hit me what the hard-truths here.
My question is such that I want to know standard practice when creating a hierarchy of classes and how they should extend or tie into MonoBehaviour classes.
Here is my particular situation in a hierarchy:
IPickupable (interface) > Item : Monobehaviour, IPickupable > Weapon : Item, IEquipable (interface) > Sword : Weapon
This is what I have now. I am putting MonoBehaviour at the bottom most layer in my class structure, such that when I create a new Sword() object, I must use Start().
The issue I am confused about, is everywhere I look, states that you should NOT use constructors in your classes that derive from MonoBehaviour. Well, when I create my dictionary of items from my database, I want to create a bunch of instances of swords for example, and store them in a collection. This is all happening in code and nothing is actually being rendered on screen or happening in the game yet.
Would it be more beneficial to build my class structure such that all game logic is contained within normal classes–then have a top level class which uses my top most logic class. For example, my example above would change to something like this:
SwordObject : Monobehaviour
private Sword sword;
In this way, my actual script that would be attached to a GameObject would still have access to all of the sword methods and data members, but my classes can be instantiated whenever and however I want.
I’m currently fighting with demons on how to go about this, and thought I would see if more experienced programmers with Game Logic and Unity could help me out with some best practices. I am a business logic programmer and only deal on a daily with accounting issues, APIs, mobile development, and web design, so game logic is all new to me. Thanks for your help, insight, suggestions, and feedback in advance!