I have three classes of C# things. One is a PuzzleController, another is a CameraGlide, and the last is a CameraRotate. Just a quick summary of what the 3 classes are. Controller has all the puzzle variables, trigger actions, stuff to send to UI, and controls what state the puzzle is in. CameraGlide moves the camera from one point to another while looking at a point. CameraRotate allows the player to mouse drag the mouse around a point and zoom in/out.
What I want to do is this:
-Player walks into trigger
-Camera disables 3rdPersonCamera
-Camera glides from behind player to predetermined puzzle location
-Tells the Controller when the camera has reached the puzzle position
-PuzzleController turns off the glide and turns on the Rotate
-Player out of trigger
-Turn off CameraRotate
-CameraGlides from where it is to the player
-Tells the controller when the camera has reached the player position
-Turn back on 3rdPersonCamera
The problem is the sequence of events. CameraGlide and CameraRotate should be PuzzleController agnostic (there different classes of controllers at different levels). So I don’t want to hard code anything into Glide Update() something like:
Because now this Glide class only works with the one type of controller. Similarly I don’t want a constantly running update in the PuzzleController checking the status of the Glide like:
Since this would be constantly checking when it only needs to be when the player has triggered the puzzle.
Ideally I want to use some kind of Delegate/Listener that any PuzzleController can add to their own code so that when it triggers it tells the CameraGlide, and listens for CameraGlide to send back that it’s at the location. The problem is I’m terrible at Listeners and I’m not sure how to add it while keeping CameraGlide and CameraRotate agnostic.