I am working on a 2d game in unity3d (c#) with the character controlled by the arrow keys and with 2 action buttons.
My problem is simple, I can solve it, but the solution seems bit dirty to me. I am using a very simple state machine, the hero is moving in horizontal or vertical way (floor and ladder)
my current state extending is:
HeroState -> HeroStateStatic -> HeroStateMovement
Then I extend static or movement to final states:
HeroStateMovement -> HeroStateRunning or HeroStateStatic -> HeroStateLookUp
however I am always calling a huge external function (in Hero class) which decides what to do next and then switch the state
I believe I should have this reasoning within the state itself but states at ladder has different set of checks and possible choices then states at floor and I don’t know how to rework those classes to have all necessary code written just one (that’s why now is in hero and not in the states) … is there anything like cross-extending technique?
(I know how to use abstract classes and interfaces but it probably does not solve my trouble)
thanks for your help