public override void Move(MovableComponent movable, int direction) { var position = movable.IntPosition; while (MovableComponent.CanMove(position + Constants.Directions[direction])) { position += Constants.Directions[direction]; } movable.Move(position); }
public override void Idle(MovableComponent movable) { foreach (var i in new int[] { 0, 2, 1, 3 }) { var direction = (movable.Direction + i) % 4; if (movable.CanMove(direction)) { movable.Move(direction); return; } } }
private void Move() { var index = this.index; do { var direction = sequence[index] - '0'; if (checks[direction]) { movable.Move(direction); this.index = index; break; } else { index = (index + 1) % sequence.Length; } } while (index != this.index); }
public virtual void Move(MovableComponent movable, int direction) => movable.Move(direction);