Skip to main content
GameDev.net gamedev.net
🔒 Locked

Application of an entity system in a turn based strategy

Started by Aristotel Aug 3, 2013 at 5:55 PM 1 replies 2.2k views
Original Post
Aristotel
Aristotel

Hello GameDev,

currently I am working on a project with two friends where we decided to implement and use an entity system for a turn based strategy game like Advanced Wars.

The current problem we are having (or are rather discussing) is what is the best way of actually using the entity system? For context I am going to describe the flow of a single units turn.

  1. The player clicks the unit -> the unit is now selected and the possible move locations are highlighted
  2. The player clicks again to select a move location, after moving the possible targets are displayed
  3. The player clicks a valid target for the unit to attack
  4. The unit finishes its turn or is destroyed

Keep in mind that for each action where the player clicks the unit again it is equivalent of the wait command in AW (for now excluding the special case for artillery and loading units into transports).

The current idea we have is that each unit has a state component that stores the state the unit is in and for each click switches to the apropriate state (pretty standard, the current state is stored in a component instead of the object).

Another idea we have is instead of a single state component we use the actual components themself for handling unit state, in this case we can check if a unit has the (let's say) waitingForMove component and continue like above by adding and removing respective components.

My questions are:

Which approach will be more elegant?

Which approach will be more flexible?

Can you come up with a different approach?

This is the first time we are actually using an entity system for handling our objects so I wanted to see more perspectives on this matter.

Thank you for reading smile.png

P.S if you have any resources on the general application of the entity system to a turn based strategy, please do share

CySoftDev
CySoftDev

Your second idea, have a component for each state, sounds similar to the GoF State Pattern, which may be a good sign :)

BeerNutts
BeerNutts

Before even reading your options, in my head, I saw separate component's that set the entity's state. That way, you can have a system, say HandleWaitMoveSystem, that operates on only on units only with that component, and performs whatever actions they require.

That's just my initial thought on it without going very deep.

My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.