Ejemplo n.º 1
0
        private static void TestRobot()
        {
            RobotEntity robot;
            BoardEntity board;

            var scene = new RootComponent()
                        .Attach(board = new BoardEntity())
                        .Attach(robot = new RobotEntity());

            robot.Place(new Vector(3f, 3f, 0f), CardinalDirection.South);
            robot.Move();
            robot.Move();

            Console.WriteLine($"Robot position: {robot.GetPosition().X}, {robot.GetPosition().Y}");
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateLeft();
            robot.RotateLeft();
            robot.Move();

            Console.WriteLine($"Robot position: {robot.GetPosition().X}, {robot.GetPosition().Y}");
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.Move();

            Console.WriteLine($"Robot position: {robot.GetPosition().X}, {robot.GetPosition().Y}");
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            // Console.WriteLine($"Robot is spawned: {robot.IsSpawned}");

            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateLeft();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");

            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
            robot.RotateRight();
            Console.WriteLine($"Robot orientation: {Orientation.FromVector(robot.GetOrientation()).CardinalDirection}");
        }
Ejemplo n.º 2
0
 private object DoLeft(LeftOptions options)
 {
     _robot.RotateLeft();
     return(null);
 }