public IRobotState Transform(IRobotState currentState) { var robotStateBuilder = this.robotStateBuilderFactory.CreateBuilderFromPrototype(currentState); var compassDirection = currentState.GetCompassDirection(); switch (compassDirection) { case CompassDirection.North: return(SetNewY(robotStateBuilder, currentState.GetY() + 1)); case CompassDirection.East: return(SetNewX(robotStateBuilder, currentState.GetX() + 1)); case CompassDirection.South: return(SetNewY(robotStateBuilder, currentState.GetY() - 1)); case CompassDirection.West: return(SetNewX(robotStateBuilder, currentState.GetX() - 1)); default: var exceptionMessage = string.Format( "unexpected compass direction: {{0}} for attempting move", compassDirection); throw new Exception(exceptionMessage); } }
public IRobotState Turn(IRobotState currentState) { var robotStateBuilder = this.robotStateBuilderFactory.CreateBuilderFromPrototype(currentState); var compassDirection = currentState.GetCompassDirection(); switch (compassDirection) { case CompassDirection.North: return(robotStateBuilder.WithCompassDirection(CompassDirection.East).Build()); case CompassDirection.East: return(robotStateBuilder.WithCompassDirection(CompassDirection.South).Build()); case CompassDirection.South: return(robotStateBuilder.WithCompassDirection(CompassDirection.West).Build()); case CompassDirection.West: return(robotStateBuilder.WithCompassDirection(CompassDirection.North).Build()); default: var exceptionMessage = string.Format("unexpected compass direction {0}", compassDirection); throw new Exception(exceptionMessage); } }
public void DisplayRobotState(IRobotState robotState, IRobotPose robotPose) { //Debug.WriteLine("RobotDashboard: DisplayRobotState() state: " + robotState.ToString()); robotStateDashboard1.StateDataBlock.Post(robotState); robotStateDashboard1.PoseDataBlock.Post(robotPose); }
public bool IsPositionAllowed(IRobotState robotState) { var xCoordinate = robotState.GetX(); var yCoordinate = robotState.GetY(); return(CheckXCoordinate(xCoordinate) && CheckYCoordinate(yCoordinate)); }
public IRobotState Perform(IRobotState currentState) { if (!currentState.IsPlaced()) { return(currentState); } return(this.orientationTurner.Turn(currentState)); }
public IRobotStateBuilder CreateBuilderFromPrototype(IRobotState robotState) { var xCoordinate = robotState.GetX(); var yCoordinate = robotState.GetY(); var orientation = new Orientation(robotState.GetCompassDirection()); return(new RobotStateBuilder(xCoordinate, yCoordinate, orientation)); }
public IRobotState Perform(IRobotState currentState) { if (currentState.IsPlaced()) { return(this.moveAttempter.Attempt(currentState)); } return(currentState); }
public IRobotState Attempt(IRobotState currentState) { var newState = this.moveStateTransformer.Transform(currentState); if (this.tableDimensions.IsPositionAllowed(newState)) { return(newState); } return(currentState); }
public void SelectRobot_ShouldFireEvent() { IRobotState robot = null; viewModel.RobotSelected += (_, e) => { robot = e.Robot; }; viewModel.SelectRobot(); Assert.Equal(robotMock.Object, robot); }
public IRobotState Perform(IRobotState currentState) { var newState = this.robotStateFactory.Create( this.xCoordinate, this.yCoordinate, this.orientation); if (this.tableDimensions.IsPositionAllowed(newState)) { return(newState); } return(currentState); }
public IRobotState Perform(IRobotState currentState) { if (currentState.IsPlaced()) { var reportString = string.Format( "{0},{1},{2}", currentState.GetX(), currentState.GetY(), currentState.GetOrientation().GetDescription()); this.textOutputter.WriteLine(reportString); } return(currentState); }
void Awake() { rb = GetComponent <Rigidbody2D>(); prevVelocity = rb.velocity; animatorComponent = GetComponent <Animator>(); Commands = new List <Command>(); oldCommands = new List <Command>(); pauseState = new PauseState(gameObject); playState = new PlayState(gameObject); currentState = pauseState; commands = new List <Command>(); anim = GetComponent <Animator>(); thrusterComponent = GetComponent <AudioSource>(); // reset position when a goal is made if (isPreview == false) { Goal.OnGoalScored += new Goal.GoalScored(ResetRobotAfterScore); } }
public void DisplayRobotState(IRobotState robotState, IRobotPose robotPose) { Debug.WriteLine("HttpServer: DisplayRobotState() state: " + robotState.ToString()); }
public void Update(ICommandPerformer commandPerformer) { this.robotState = commandPerformer.Perform(this.robotState); }
public RobotListItemViewModel(IRobotState robot) { this.robot = robot; this.robot.PropertyChanged += robot_PropertyChanged; }
public RobotListItemEventArgs(IRobotState robot) { this.Robot = robot; }
public ToyRobot(IRobotState robotState) { this.robotState = robotState; }
public RobotStateTests() { executionServiceMock.Setup(x => x.Execute(programMock.Object, robotMock.Object)).Returns(defaultExecutorMock.Object); this.robotState = new RobotState(executionServiceMock.Object, robotMock.Object, new Mock <IRobotLog>().Object); }