Hello!
I’ve got two questions\issues about architecture orgranisation. Im pretty sure there are common methods to solve them but right now im sort of stuck =\
Character is able to walk between rooms. When he toches an interactable object, iinfo icon appears. If actions button is pressed(while icon appears) the action starts
Breif idea of current architecture:
- Sort of MVC is used from https://www.toptal.com/unity-unity3d/unity-with-mvc-how-to-level-up-your-game-development There is big class Application , that contains instances for classes Controllers, Models and Views. Controllers contains all Controllerrs, Models contas models and so on. Application is a base class for components instead of Monobehavior. So each component is able to get to another like Application.Controller.PlayerController
- Also messenger is used to notify some other classes https://wiki.unity3d.com/index.php/Advanced_CSharp_Messenger
So for exaple, when character collides with some object:
- View of the object sends notification with Action (it contains type of acton and required button)
- ActionManager recives it and store it in PreparedAction field
- ActionManager checks every Update if required button is clicked
- If So the action is started (you could see th code below0):
So I need to add a new case for each new action. It should be better if all actions implement the same interface with StartAction() method for example.
But there is a problem:
1) Each action involve several different classes. For example: If tv is turned on, animation should be started and sound should be played. If room is changed, then roomcontroller should aactivete new, player change position, and volume of the tv should be not so big, as it is in the diffrent room. What is the good way for different layers of code interactions? How should SoundManager be informed if tv is turned on and ect? Is messenger a good way? Or eventargs list for each class?
2) What is the good way to organise classes? Current implementation is not good becouse changes of one class affects many other (as a class could be called by app.comtroller.RoomsController). I understand that controller could contain instances for a model and a view for the same objects, but how two controllers should interact?