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);
            }
        }
Esempio n. 2
0
        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);
        }
Esempio n. 4
0
        public bool IsPositionAllowed(IRobotState robotState)
        {
            var xCoordinate = robotState.GetX();
            var yCoordinate = robotState.GetY();

            return(CheckXCoordinate(xCoordinate) && CheckYCoordinate(yCoordinate));
        }
Esempio n. 5
0
        public void DisplayRobotState(IRobotState robotState, IRobotPose robotPose)
        {
            //Debug.WriteLine("RobotDashboard: DisplayRobotState()   state: " + robotState.ToString());

            robotStateDashboard1.StateDataBlock.Post(robotState);
            robotStateDashboard1.PoseDataBlock.Post(robotPose);
        }
Esempio n. 6
0
 public IRobotState Perform(IRobotState currentState)
 {
     if (!currentState.IsPlaced())
     {
         return(currentState);
     }
     return(this.orientationTurner.Turn(currentState));
 }
Esempio n. 7
0
        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));
        }
Esempio n. 8
0
        public IRobotState Perform(IRobotState currentState)
        {
            if (currentState.IsPlaced())
            {
                return(this.moveAttempter.Attempt(currentState));
            }

            return(currentState);
        }
Esempio n. 9
0
        public IRobotState Attempt(IRobotState currentState)
        {
            var newState = this.moveStateTransformer.Transform(currentState);

            if (this.tableDimensions.IsPositionAllowed(newState))
            {
                return(newState);
            }

            return(currentState);
        }
Esempio n. 10
0
        public void SelectRobot_ShouldFireEvent()
        {
            IRobotState robot = null;

            viewModel.RobotSelected += (_, e) =>
            {
                robot = e.Robot;
            };

            viewModel.SelectRobot();

            Assert.Equal(robotMock.Object, robot);
        }
Esempio n. 11
0
        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);
        }
Esempio n. 12
0
        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);
        }
    }
Esempio n. 14
0
 public void DisplayRobotState(IRobotState robotState, IRobotPose robotPose)
 {
     Debug.WriteLine("HttpServer: DisplayRobotState()   state: " + robotState.ToString());
 }
Esempio n. 15
0
 public void Update(ICommandPerformer commandPerformer)
 {
     this.robotState = commandPerformer.Perform(this.robotState);
 }
Esempio n. 16
0
 public RobotListItemViewModel(IRobotState robot)
 {
     this.robot = robot;
     this.robot.PropertyChanged += robot_PropertyChanged;
 }
Esempio n. 17
0
 public RobotListItemEventArgs(IRobotState robot)
 {
     this.Robot = robot;
 }
Esempio n. 18
0
 public ToyRobot(IRobotState robotState)
 {
     this.robotState = robotState;
 }
Esempio n. 19
0
 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);
 }
Esempio n. 20
0
 public void DisplayRobotState(IRobotState robotState, IRobotPose robotPose)
 {
     Debug.WriteLine("HttpServer: DisplayRobotState()   state: " + robotState.ToString());
 }