Manager classes

Looks reasonable… you might get some benefit by extracting common methods into some kind of interface, which is a pattern that works really well with Unity and MonoBehaviors. MBs can then implement specific interfaces and be found because they implement those interfaces.

For instance, you might have an IAttackable interface that can represent a target that can be attacked. Some of its methods might be “what can hurt you?” and “you have been attacked by …” This also means when a projectile hits a collider it can say “Hey, do you implement the IAttackable interface?” and if you do, have I got some business for you. A wall might not implement IAttackable, unless it makes sense.

And of course you can always make Darkness implement IAttackable so that you can attack the darkness, a time-honored way of irritating your GM.

Personally I prefer something like an IDamageable, then something before that which decides how much damage, perhaps considering information other interfaces related to the thing attacking, the attack itself and the target, as well as any other concerns like buffs, debuffs, environment, etc…

At some point in any complex game there has to be some level of linkage. You can extract and abstract it to the point where it becomes almost impossible to reason about when it malfunctions, or you can hard-wire all of it which becomes a sort of brittle bugs and replicated code. Somewhere in between lies a happy medium, and everybody works differently. But it’s always good to consider all your tools, such as interfaces.

Other folks like inheritance, but in Unity that always seems brittle and far more irritating to work with than interfaces, but your mileage may vary.

3 Likes
How to get static game data for a subclass
Kindly Requesting Guidance for My Scripting Structure
Best way to have queued move actions for up to 10 players executing simultaneously?
How to make the architecture of the character doll?
Dealing with so many interactable objects
Referencing a Script through a Public String with GetComponent
Using a script as a class without object
Advice Needed for Monopoly Style Board Game
Calling function XXXX with no parameters but the function requires 1.
Will my idea for organizing different enemies work and is it best practice?
What are C# Interfaces? Can someone explain them in plain English?
(Suggestion) Which programming design is better for damaging the enemy?
Setup Enemy Class proper coding standard question.
How to implement Different weapon stats? (Best Practice?)
Issues with abstract members
Need help in turning mass chunk of code into smaller and more efficient ones
List of Scripts to Execute Issues
need some help with trigger/colliders and where/how to put them for an item pickup
Invoke Method Script
Pass Type In MonoBehaviour From Other Script
Add abilities to different unit types
How do I avoid a bunch of if statements and avoid a switch
Have an object contain a movement monobehaviour but let a different object execute it?
Inheritance problem
Should I extract this duplication into a superclass, interface, or separate component?
Colliders from multiple interactable objects
Attaching a Script to a ScriptableObject
Suggestions for using interfaces in Card Battler like Slay the Spire?
call Script with the same name but other code
Passing SO from one Script to another. (Question)
Why is my send message not working?
Understanding Interfaces. IPointerDownHandler
Identifying unittype among many different
How do I make a script call a variable from many instances of another script
InvalidCastException: Specified cast is not valid.
Problem getting reference to a specific class
How to get a variable value from another script(C#) without setting script name.
Question on approach for a top down 2d click to move/attack/interact game
How to check if a gameobjects class is implementing an interface
Calling functions from a separate, unique script using a ray cast.
Same OnEnable()/OnDisable() on multiple scripts? Calling same method name from one script
Architecture of a Spell System
Best way to decouple skill system from the other systems it influences?
Want to use interface for lootable items but don't know where to start
Finding array of current state game objects
How to make a list that can contain different variable types?
Setting a general code to access inherited variables for Buffs/Debuffs system
Is my approach is good for generics?
Is there other way around?
Create Inspector UI for parent class that changes depending on the type of child
Question on a (more or less) complex inventory/item system
How to make one gameobject immune to a script attached to a separate gameobject
Dealing with multiple types of items for an inventory
Incorporate a new functionality in many gameobject
Ambiguous/Universal Object Activation
Is it possible to cast as a Type from a string?
Get variable from other script with unknown name
How to do map colliders for 2D pixelart game?
How do I only check for specific game objects in a BoxCast?
Help with syncing multiple types of derived class using netcode for gameobjects
Weapons system
Convert Parent class to Child class from a method