Hello, everyone, I’m a beginner programmer and I’ve been following a guide about FSM’s online, but after a while I got lost on the code. I should be able to figure out whats wrong from a simple translation, but it wasn’t well received by the SO community (saying I simply wanted an easy way for the answer). The problem I’m having is that a direct translation doesn’t seem to work. Mainly on how they implemented delegate classes. In addition, in my code, some classes are lacking lines of code and the classes don’t connect with each other.
I’m currently reading State · Design Patterns Revisited · Game Programming Patterns
and having trouble doing the code from (using ctrl-f)
“A state interface” to “the State pattern in its entirety.”
Additional info: Using Unity 4.6, C# language, Current code I have is quite lengthy but is available upon request.
Currently Tried
// ===================================
3 Classes,
1 Monobehaviour / Delegate Class - where an instance of stateclass always returns null
1 State Interface
1 State Class that implements the interface
-After another 4 hours, I still do not understand how to properly translate the delegate part into c#, or if the classes even follows the same syntax (i.e. the interface on the authors side has a constructor defined, but I am restricted from creating constructors in my code)
// tbh I’d rather not have to post the code itself till I see a translation and try it myself. I want to study the correct format rather than have people correct my rather poorly implemented version. And once that’s done, and it still doesn’t work. Ill try my best to pinpoint the error and post an easier code to read.