[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / input / handler / keyboard / GoRightKeyboardInputHandler.kt
1 package ru.deadsoftware.cavedroid.game.input.handler.keyboard
3 import ru.deadsoftware.cavedroid.MainConfig
4 import ru.deadsoftware.cavedroid.game.GameScope
5 import ru.deadsoftware.cavedroid.game.input.IKeyboardInputHandler
6 import ru.deadsoftware.cavedroid.game.input.KeyboardInputHandler
7 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
8 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
9 import ru.deadsoftware.cavedroid.game.mobs.Mob
10 import ru.deadsoftware.cavedroid.game.mobs.MobsController
11 import ru.deadsoftware.cavedroid.game.mobs.player.Player
12 import javax.inject.Inject
14 @GameScope
15 @KeyboardInputHandler
16 class GoRightKeyboardInputHandler @Inject constructor(
17 private val mainConfig: MainConfig,
18 private val mobsController: MobsController
19 ) : IKeyboardInputHandler {
21 override fun checkConditions(action: KeyboardInputAction): Boolean {
22 return action.actionKey is KeyboardInputActionKey.Right &&
23 (mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
24 }
26 override fun handle(action: KeyboardInputAction) {
27 if (action.isKeyDown) {
28 mobsController.player.velocity.x = mobsController.player.speed
29 mobsController.player.setDir(Mob.Direction.RIGHT)
30 } else {
31 mobsController.player.velocity.x = 0f
32 }
33 }
34 }