Im trying to create a simple " give order to Sprite, make Sprite do thing" game much like rimworld or oxygen not included.
So far I have two controllers type objects, on for the player and one for each Sprite. When a Sprite is selected, the player controller takes a reference of the Sprite and sets a Boolean variable hasMoveOrder to true when the player clicks on a spot.
My code right now is filled with if/else statements in order to get this to work. Once I add more work orders like digging, building, etc, a thousand if statements starts to get sloppy. The question is what kind of data structure or algorithms can I use to make this more efficient? Would an enumeration of the Sprite states be fine and just switch through them when the Sprite gets a new work order? Or would something more complex like a state machine make sense?
↧