In GCC4, it seems that for a controller, a same command always has a same meaning.
For example, for the TeapotController, if 'w' is pressed down, the controller will always dispatch EvtData_StartThrust and will do nothing else.
I'm writting a simple tile-based strategy game. In the game, the player can drag the world scene, and this drag may have different meanings:
- If the player drags a tile while there's no unit on it, or there's a moved unit on it, the drag means that he wants to move the whole scene to somewhere (for a better vision).
- If the player drags a tile while there is a unit that hasn't moved on it, the drag means that he wants to move the unit without moving the scene.
I've considered some ways to deal with it:
- Write a controller which simply dispatch something like "EvtDataDrag" when the scene is dragged. It's the scripts' job to find a proper way to deal with the event.
I don't know if this is good because the controller almost translates nothing, and the scripts' job will be heavy when the logic gets more complex.
- Write a controller which detects the states of the game and dispatch "EvtDataDragScene" or "EvtDataMoveUnit" in proper conditions.
This may be bad because the controller seems to know too much.
- Write two controllers, one for the scene and one for the unit. When dragged, the controller for scene will always dispatch "EvtDataDragScene", and the controller for unit will always dispatch "EvtDataMoveUnit".
This seems to be hard to code because a single drag may activate both the controllers. This should be avoided but I don't know how.
Which way is good? Or is there another better way?
For example, for the TeapotController, if 'w' is pressed down, the controller will always dispatch EvtData_StartThrust and will do nothing else.
I'm writting a simple tile-based strategy game. In the game, the player can drag the world scene, and this drag may have different meanings:
- If the player drags a tile while there's no unit on it, or there's a moved unit on it, the drag means that he wants to move the whole scene to somewhere (for a better vision).
- If the player drags a tile while there is a unit that hasn't moved on it, the drag means that he wants to move the unit without moving the scene.
I've considered some ways to deal with it:
- Write a controller which simply dispatch something like "EvtDataDrag" when the scene is dragged. It's the scripts' job to find a proper way to deal with the event.
I don't know if this is good because the controller almost translates nothing, and the scripts' job will be heavy when the logic gets more complex.
- Write a controller which detects the states of the game and dispatch "EvtDataDragScene" or "EvtDataMoveUnit" in proper conditions.
This may be bad because the controller seems to know too much.
- Write two controllers, one for the scene and one for the unit. When dragged, the controller for scene will always dispatch "EvtDataDragScene", and the controller for unit will always dispatch "EvtDataMoveUnit".
This seems to be hard to code because a single drag may activate both the controllers. This should be avoided but I don't know how.
Which way is good? Or is there another better way?