DEADSOFTWARE

Inventory class
[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.IGameInputHandler
6 import ru.deadsoftware.cavedroid.game.input.action.KeyboardInputAction
7 import ru.deadsoftware.cavedroid.game.input.action.keys.KeyboardInputActionKey
8 import ru.deadsoftware.cavedroid.game.mobs.Mob
9 import ru.deadsoftware.cavedroid.game.mobs.MobsController
10 import ru.deadsoftware.cavedroid.game.mobs.player.Player
11 import javax.inject.Inject
13 @GameScope
14 class GoRightKeyboardInputHandler @Inject constructor(
15 private val mainConfig: MainConfig,
16 private val mobsController: MobsController
17 ) : IGameInputHandler<KeyboardInputAction> {
19 override fun checkConditions(action: KeyboardInputAction): Boolean {
20 return action.actionKey is KeyboardInputActionKey.Right &&
21 (mobsController.player.controlMode == Player.ControlMode.WALK || !mainConfig.isTouch)
22 }
24 override fun handle(action: KeyboardInputAction) {
25 if (action.isKeyDown) {
26 mobsController.player.velocity.x = mobsController.player.speed
27 mobsController.player.setDir(Mob.Direction.RIGHT)
28 } else {
29 mobsController.player.velocity.x = 0f
30 }
31 }
32 }