In Turn-Based games like ‘Civilization’ when you click ‘Next Turn’ all the units on the map perform actions one after another. These actions could be moving, fighting or building. How can I implement a system like that where a unit doesn’t perform its action unless the previous one finishes?
We were just talking about this same exact thing over the weekend here:
That guy is making a twitch game but all the same steps apply, a generic “do until done” type interface, and a queue of those actions on a per-unit basis, or at the overall game level.
I read your answer in the other thread. You mentioned using Timers or Coroutines to make it sequence through all its necessary steps over time. Did you mean that each action whether it’s Move() or Shoot() would exist inside a coroutine and after the action is finished the coroutine would call the next action and so on?
Also, What happens after the unit itself finishes all its actions, would it signal back to the manager object in order to start the next unit?
I would make each one a class, and who cares how it is done internally. It’s either Update() or a Coroutine, but either way it would do absolutely NOTHING until it received the Begin() call from the ITurnAction interface.
Exactly, via the interface that the main manager is always calling: ITurnAction.CheckDone();