Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to implement a sequential Action system like in 'Civilization' games?

Discussion in 'Scripting' started by Abdo023, Sep 13, 2021.

  1. Abdo023

    Abdo023

    Joined:
    Dec 18, 2017
    Posts:
    64
    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?
     
    Last edited: Sep 14, 2021
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,760
    Lethn likes this.
  3. Abdo023

    Abdo023

    Joined:
    Dec 18, 2017
    Posts:
    64
    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?
     
  4. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,760
    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();