예제 #1
0
 public void RemovePoint()
 {
     addPoints = GameObject.Find("MoveBot").GetComponent <MoveInstructions>();
     addPoints.positions.RemoveAt(addPoints.positions.Count - 1);
     addPoints.ranges.RemoveAt(addPoints.ranges.Count - 1);
     addPoints.directions.RemoveAt(addPoints.directions.Count - 1);
 }
예제 #2
0
 // Update is called once per frame
 public void NextMove()
 {
     addPoints = GameObject.Find("MoveBot").GetComponent <MoveInstructions>();
     addPoints.positions.Add(startPoint.position);
     addPoints.ranges.Add(withinRange);
     addPoints.directions.Add(endPoint.position - startPoint.position);
 }
예제 #3
0
        public void Move(MoveInstructions input, int position)
        {
            var instruction = new Instruction(_pluto, _rover, input.ToString());

            _movementOperation.Execute(instruction);
            _rover.PosX.Should().Be(0);
            _rover.PosY.Should().Be(position);
        }
예제 #4
0
        public void TurnAndMove(TurnInstructions turnInstruction, MoveInstructions moveInstruction, int yPosition, int xPosition)
        {
            var firstInstruction  = new Instruction(_pluto, _rover, turnInstruction.ToString());
            var secondInstruction = new Instruction(_pluto, _rover, moveInstruction.ToString());

            _turnOperation.Execute(firstInstruction);
            _movementOperation.Execute(secondInstruction);
            _rover.PosY.Should().Be(yPosition);
            _rover.PosX.Should().Be(xPosition);
        }
예제 #5
0
    private void DetectAction()
    {
        robit    = GameObject.Find("MoveBot");
        instruct = robit.GetComponent <MoveInstructions>();
        Event currentEvent = Event.current;



        switch (currentEvent.type)
        {
        case EventType.MouseDown:
            Ray        ray = Camera.current.ScreenPointToRay(Event.current.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit))
            {
                i++;
                Vector3 temp = hit.point;

                //temp.y = robit.transform.position.y;
                Debug.Log(hit.point);
                instruct.positions.Add(temp);
                instruct.directions.Add(temp);
                instruct.ranges.Add(0.5f);
            }
            break;

        case EventType.KeyDown:
            if (currentEvent.keyCode == KeyCode.Backspace || currentEvent.keyCode == KeyCode.Delete)
            {
                if (i > 0)
                {
                    i--;
                }
            }

            break;
        }
    }
        private static string LongitudinalMovement(Rover rover, MoveInstructions instruction, Pluto pluto)
        {
            var displacement = 1;

            if (rover.CurrentDirection == "W")
            {
                displacement = -1;
            }

            if (AreMovingBackwards(instruction))
            {
                displacement *= -1;
            }

            if (pluto.Grid[GetNextXCoOrd(rover, displacement, pluto)][rover.PosY].IsObstacle)
            {
                return("IsObstacle");
            }

            rover.PosX = GetNextXCoOrd(rover, displacement, pluto);

            return(Success);
        }
예제 #7
0
 // Use this for initialization
 void Start()
 {
     Debug.Log("Showpoints starting up!");
     robit    = GameObject.Find("MoveBot");
     instruct = robit.GetComponent <MoveInstructions>();
 }
예제 #8
0
 public void Clear()
 {
     moveInstructions = MoveInstructions.neutral;
     actionInstructions = ActionInstructions.none;
     direction = Direction.Neutral;
     actedOn = false;
 }
 private static bool AreMovingBackwards(MoveInstructions instruction) => instruction.Equals(MoveInstructions.B);