|
|
@ -16,6 +16,7 @@ import wow.doge.mygame.game.entities.character.CharacterStates._ |
|
|
|
import wow.doge.mygame.game.entities.player.PlayerActor |
|
|
|
import wow.doge.mygame.implicits._ |
|
|
|
import wow.doge.mygame.subsystems.movement.ImMovementActor |
|
|
|
import wow.doge.mygame.utils.MovementDirection |
|
|
|
|
|
|
|
class IdleBehaviorFactory( |
|
|
|
env: PlayerActor.Env, |
|
|
@ -32,41 +33,43 @@ class IdleBehaviorFactory( |
|
|
|
Behaviors |
|
|
|
.receiveMessage[PlayerActor.Command] { |
|
|
|
|
|
|
|
case PlayerActor.HandleMovement(curStats, pressed) => |
|
|
|
case PlayerActor.HandleWalk(curStats, pressed, direction) => |
|
|
|
if (curStats.stamina.toInt > 0) { |
|
|
|
children.movementActor ! ImMovementActor.MoveLeft(pressed) |
|
|
|
children.movementActor ! (direction match { |
|
|
|
case MovementDirection.Forward => |
|
|
|
ImMovementActor.MoveUp(pressed) |
|
|
|
case MovementDirection.Backward => |
|
|
|
ImMovementActor.MoveDown(pressed) |
|
|
|
case MovementDirection.Left => ImMovementActor.MoveLeft(pressed) |
|
|
|
case MovementDirection.Right => |
|
|
|
ImMovementActor.MoveRight(pressed) |
|
|
|
}) |
|
|
|
if (pressed) nextStateFn(AliveSubstate.Moving(Walking)) |
|
|
|
else nextStateFn(AliveSubstate.Idle) |
|
|
|
} else { |
|
|
|
children.movementActor ! ImMovementActor.MoveLeft(false) |
|
|
|
children.movementActor ! ImMovementActor.StopMoving |
|
|
|
Behaviors.same |
|
|
|
} |
|
|
|
|
|
|
|
case PlayerActor.MoveLeft(pressed) => |
|
|
|
// case PlayerActor.Walk(pressed, Direction.Up) => Behaviors.same |
|
|
|
// case PlayerActor.Walk(pressed, Direction.Down) => Behaviors.same |
|
|
|
// case PlayerActor.Walk(pressed, Direction.Left) => Behaviors.same |
|
|
|
// case PlayerActor.Walk(pressed, Direction.Right) => Behaviors.same |
|
|
|
|
|
|
|
case PlayerActor.StopMoving => |
|
|
|
children.movementActor ! ImMovementActor.StopMoving |
|
|
|
Behaviors.same |
|
|
|
|
|
|
|
case PlayerActor.Walk(pressed, direction) => |
|
|
|
implicit val ec = props.scheduler.value |
|
|
|
for { |
|
|
|
curStats <- children.statsActor.ask(StatsActor.CurrentStats) |
|
|
|
res <- Future.successful( |
|
|
|
ctx.self ! PlayerActor.HandleMovement(curStats, pressed) |
|
|
|
_ <- Future.successful( |
|
|
|
ctx.self ! PlayerActor.HandleWalk(curStats, pressed, direction) |
|
|
|
) |
|
|
|
} yield res |
|
|
|
} yield () |
|
|
|
Behaviors.same |
|
|
|
|
|
|
|
case PlayerActor.MoveRight(pressed) => |
|
|
|
children.movementActor ! ImMovementActor.MoveRight(pressed) |
|
|
|
if (pressed) nextStateFn(AliveSubstate.Moving(Walking)) |
|
|
|
else nextStateFn(AliveSubstate.Idle) |
|
|
|
|
|
|
|
case PlayerActor.MoveUp(pressed) => |
|
|
|
children.movementActor ! ImMovementActor.MoveUp(pressed) |
|
|
|
if (pressed) nextStateFn(AliveSubstate.Moving(Walking)) |
|
|
|
else nextStateFn(AliveSubstate.Idle) |
|
|
|
|
|
|
|
case PlayerActor.MoveDown(pressed) => |
|
|
|
children.movementActor ! ImMovementActor.MoveDown(pressed) |
|
|
|
if (pressed) nextStateFn(AliveSubstate.Moving(Walking)) |
|
|
|
else nextStateFn(AliveSubstate.Idle) |
|
|
|
|
|
|
|
case PlayerActor.Jump => |
|
|
|
children.movementActor ! ImMovementActor.Jump |
|
|
|
ctx.self.ask( |
|
|
@ -151,15 +154,15 @@ class IdleBehaviorFactory( |
|
|
|
response match { |
|
|
|
case (status, stats) => |
|
|
|
status match { |
|
|
|
case StatsActor.Status.Dead => ctx.self ! PlayerActor.Die |
|
|
|
case StatsActor.Status.Alive => |
|
|
|
props.statsQueue |
|
|
|
.offer(stats) |
|
|
|
.foreach { _ => |
|
|
|
pprint.log(show"Published stats $stats") |
|
|
|
replyTo ! stats |
|
|
|
}(props.scheduler.value) |
|
|
|
case StatsActor.Status.Dead => ctx.self ! PlayerActor.Die |
|
|
|
case StatsActor.Status.Alive => () |
|
|
|
} |
|
|
|
props.statsQueue |
|
|
|
.offer(stats) |
|
|
|
.foreach { _ => |
|
|
|
pprint.log(show"Published stats $stats") |
|
|
|
replyTo ! stats |
|
|
|
}(props.scheduler.value) |
|
|
|
} |
|
|
|
Behaviors.same |
|
|
|
|
|
|
|