jmmk / clash-attack-sim

https://jmmk.github.io/clash-attack-sim/
Other
3 stars 1 forks source link

Allow choosing which unit to spawn #13

Open jmmk opened 9 years ago

jmmk commented 9 years ago

Currently archers are implemented as a random chance to spawn on left-click. Instead, there should be a choice between spawning an archer or barbarian.

jmmk commented 9 years ago

There will be a selector at the bottom with each available unit type. When a unit is clicked, it should become the "active" unit if not already. Left clicks on the battlefield after the change will add one of the active unit.

jmmk commented 9 years ago

Each selector is an entity with a selector component with fields [active entity]. Active is a boolean whether the selector is active or not and entity is a keyword of which entity it refers to.

When a selector is clicked, the current active selector is change to inactive and the new active selector is changed to active (unless it is already active, in which case nothing changes)

When a click happens on the battlefield, it get the active selector and spawns an entity according to the entity field of the selector component.

jmmk commented 9 years ago

Another option would be to use reagent for things like the selectors. Is it more complicated to have the two running in tandem? Is it easier/harder to shoehorn selectors into the game's ECS rather than use a more traditional GUI approach?