private object DoPlace(PlaceOptions options, RootComponent scene) { if (_robot == null) { _robot = new RobotEntity(); _robot.AttachTo(scene); } _robot.Place(new Vector(options.PosX, options.PosY, 0f), options.Facing); Console.WriteLine($"Robot is at {_robot.GetPosition().X}, {_robot.GetPosition().Y} " + $"facing {Orientation.FromVector(_robot.GetOrientation()).CardinalDirection}"); return(null); }
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}"); }