Example #1
0
        private static void MovePart1Style(Pointish ship, Movement move)
        {
            switch (move.Act)
            {
            case "F":
                ship.Move(ship.Facing, move.Amount);
                break;

            case "E":
            case "N":
            case "W":
            case "S":
                var direction = PointParseUtils.ParseDirection(move.Act);
                ship.Move(direction, move.Amount);
                break;

            case "L":
            case "R":
                var rotation = PointParseUtils.ParseRotation(move.Act, move.Amount);
                ship.RotateFacing(rotation);
                break;

            default:
                throw new Exception("Act not impl: " + move.Act);
            }
        }
Example #2
0
        private static void MovePart2Style(Pointish ship, Movement move, Pointish waypoint)
        {
            switch (move.Act)
            {
            case "F":
                ship.Move(waypoint.Pos, move.Amount);
                break;

            case "E":
            case "N":
            case "W":
            case "S":
                var direction = PointParseUtils.ParseDirection(move.Act);
                waypoint.Move(direction, move.Amount);
                break;

            case "L":
            case "R":
                var rotation = PointParseUtils.ParseRotation(move.Act, move.Amount);
                waypoint.RotateOrientation(rotation);
                break;

            default:
                throw new Exception("Unknown act: " + move.Act);
            }
        }