I am building a strategy game where multiple units(5 - 20) fighting each other.
I have a game logic that calculate all the actions that been done on each turn, and send it to the game engine to animate.
Those are the possible actions:
- perform attack
- perform taking damage
- perform moving
- perform missing
- perform removing your self(dying)
How can I find what actions I can perform in parallel and what are not?
Those are the limitations that I have:
- units can only perform one action at a time.
- each action may have different times, even if its the same action
- Unit can perform the action
attack, only if the other unit performing the action
removing your self
- after unit performed the action:
removing your self, he cannot perform any other action.
Edit: Those are the situations that might happened:
- one unit is attacked by multiple units at once
- one unit taking damage while no units are attacking him
- all the units move at the same time
- all the units perform miss at the same time
This question is not about game design, but a programmatic solution to how I can find those parallel tiles of actions?
Reply to FrustratedWithFormsDesign, answer
Hi man, you took it to completely different direction, so I want to reply you here to clear things up.
This questions is not about how to make units to move in parallel. I also don't think that your suggestion is a good idea.
What you did with your own game this is actually, the right direction. It will be also wise to work in MVC and separate the view and game logics.
So to implement a game engine I would use a game thread that will dispatch tick events, based on chosen frame rate. Only the views should be listening for that thread and implement they view logic based on it.
In my game I am using Adobe Air framework with some native Java and Objective-C support for mobiles, but it's Air mostly. So all my animations are listening to onEnterFrameEvent, this would be tick in your example, and implement their animation logic.
My game logic is using a different worker(air threads implementations, it's more like a process) to generate all the actions on particular turn. And than it sands it to the game engine to animate. I do not ask how to implement the animations, it's handled by Air apis, and it doesn't meter in here.
Think about those problems:
unit a attacks unit b while unit b attacks unit c, while unit c is moving.
This will resolute with a mess on the screen.
I want it to be:
unit a attack unit b, unit b waits for a to finish attacking him to start attacking unit c, while unit c is moving. After a finish attacking unit b, unit b attacks unit c.
So the input of actions I received was:
- A attack
- B take damage
- B attack
- C take damage
- C move
And the output was two sets of animations
- A attack, C move, B take damage
- B attack, C take damage
This was a very simple example of how I would like to parallel my actions. I hope now it is more clear.