private IEnumerator MoveRoutine() { while (true) { if (isMyTurn) { Direction?direction = null; if (Input.GetKey(KeyCode.RightArrow) || queuedKeyPress == KeyCode.RightArrow) { direction = Direction.EAST; } else if (Input.GetKey(KeyCode.LeftArrow) || queuedKeyPress == KeyCode.LeftArrow) { direction = Direction.WEST; } else if (Input.GetKey(KeyCode.UpArrow) || queuedKeyPress == KeyCode.UpArrow) { direction = Direction.NORTH; } else if (Input.GetKey(KeyCode.DownArrow) || queuedKeyPress == KeyCode.DownArrow) { direction = Direction.SOUTH; } queuedKeyPress = null; if (direction.HasValue) { actionSetter = () => { turnActions.Clear(); Step moveAction = controller.Move(direction.Value, ref actionFailedInfo); if (moveAction != null) { turnActions.Add(moveAction); } }; ConfirmAction(); } } yield return(new WaitForSeconds(0.1f)); } }
public Turn OnTurn() { var steps = new List <Step>(); if (CurrentHp > 0) { //Direction? direction = DirectionExtensions.RelativeDirection(controller.Row, controller.Col, player.Row, player.Col); Direction?direction = DirectionExtensions.RelativeDirection(transform.position, player.transform.position); if (direction == null) { if (controller.Elevation > player.Elevation && player.IsClimbing && player.Climbing == controller.Climbing) { direction = controller.Climbing.Value.Opposite(); } else { direction = player.Climbing; } } if (direction != null) { Step moveStep = controller.Move(direction.Value); if (moveStep != null) { steps.Add(moveStep); } } if (!controller.IsClimbing) { steps.Add(AttackMyTile()); } } return(new Turn(steps, GameManager.standardTurnTime)); }