示例#1
0
        public void MoveWestSubtractFromXAxis()
        {
            var robot       = new Robot(new Position(1, 0, "W"));
            var moveForward = new MoveForward();

            robot.CurrentPosition = moveForward.Move(robot.CurrentPosition);

            Assert.AreEqual(0, robot.CurrentPosition.X);
        }
示例#2
0
        public void MoveEastAddToXAxis()
        {
            var robot       = new Robot(new Position(1, 0, "E"));
            var moveForward = new MoveForward();

            robot.CurrentPosition = moveForward.Move(robot.CurrentPosition);

            Assert.AreEqual(2, robot.CurrentPosition.X);
        }
示例#3
0
        public void MoveSouthSubtractFromYAxis()
        {
            var robot       = new Robot(new Position(0, 1, "S"));
            var moveForward = new MoveForward();

            robot.CurrentPosition = moveForward.Move(robot.CurrentPosition);

            Assert.AreEqual(0, robot.CurrentPosition.Y);
        }
示例#4
0
        public void MoveNorthAddToYAxis()
        {
            var robot       = new Robot(new Position(0, 1, "N"));
            var moveForward = new MoveForward();

            robot.CurrentPosition = moveForward.Move(robot.CurrentPosition);

            Assert.AreEqual(2, robot.CurrentPosition.Y);
        }
示例#5
0
    public void MoveForwardRobotTest(float x, float y, float orientation, string expect)
    {
        Robot robot = new Robot(x, y, orientation);

        MoveForward movement = new MoveForward();

        movement.Move(robot);

        Assert.Equal(expect, robot.GetPosition());
    }
示例#6
0
    void FixedUpdate()
    {
        // turn the ship
        Quaternion rotation = transform.rotation;
        float      z        = rotation.eulerAngles.z;

        z += swing * Time.fixedDeltaTime;
        myRigidBody.MoveRotation(z);

        // move forward
        moveScript.Move(Time.fixedDeltaTime);
    }
示例#7
0
    public void PlayBlockCode()
    {
        var instance = new MoveForward();

        //will run the block code for the play button
        Debug.Log("Play Button Clicked");

        //play button works with incuding the code in the "on click" on the play button object
        button.GetComponent <Button>().onClick.AddListener(delegate { instance.Move(bike); });

        //what this does is add the code to the bike object but
        //you want to add the bike to the code as a game object
        //you still need it since theres an error in the code??
        //instance = bike.AddComponent<MoveForward>();
    }
示例#8
0
    void FixedUpdate()
    {
        if (target == null)
        {
            target = GameObject.FindGameObjectWithTag("Player").transform;
            if (target == null)
            {
                return;
            }
        }

        var   myAngle       = RotationHelper.GetAngleFromQuaternion(transform.rotation);
        var   angleToTarget = RotationHelper.GetAngleFromToTarget(transform.position, target.position);
        var   diff          = RotationHelper.GetDifferenceBetweenAngles(myAngle, angleToTarget);
        float nextAngle     = transform.rotation.eulerAngles.z;

        if (diff > 0)
        {
            var mod = turnSpeed * Time.fixedDeltaTime;
            if (mod > diff)
            {
                mod = diff;
            }
            nextAngle += mod;
        }
        else if (diff < 0)
        {
            var mod = turnSpeed * Time.fixedDeltaTime;
            if (mod < diff)
            {
                mod = diff;
            }
            nextAngle -= mod;
        }

        myRigidBody.MoveRotation(nextAngle);

        moveScript.Move(Time.fixedDeltaTime);
    }
示例#9
0
 void FixedUpdate()
 {
     moveScript.Move(Time.fixedDeltaTime);
 }
示例#10
0
 public void Move_in_the_right_direction_when_command_is_given(RoverPosition startPosition, int command, Coordinates result)
 {
     Assert.Equal(result, MoveForward.Move(command, startPosition));
 }