コード例 #1
0
 static Func <string, string> RotateBasedOn(char x)
 {
     // Once the index is determined, rotate the string to the right one time,
     // plus a number of times equal to that index, plus one additional time
     // if the index was at least 4.
     return(s => {
         var i = s.IndexOf(x);
         s = RotateRight(i)(Right1(s));
         return i >= 4 ? Right1(s) : s;
     });
 }
コード例 #2
0
ファイル: InputParser.cs プロジェクト: Jesmv/martian-robots
    public static List <IMovement> parseMovementList(string line)
    {
        List <IMovement> movementList = new List <IMovement>();

        foreach (var item in line)
        {
            IMovement movement;

            switch (item)
            {
            case 'L':
                movement = new RotateLeft();
                break;

            case 'R':
                movement = new RotateRight();
                break;

            case 'F':
                movement = new MoveForward();
                break;

            case ' ':
                continue;

            default:
                throw new Exception("Invalid movement");
            }

            movementList.Add(movement);
        }

        return(movementList);
    }
コード例 #3
0
        private void UpdateCameraInput()
        {
            if (MouseCondition.Scrolled())
            {
                int scrollDelta = MouseCondition.ScrollDelta;
                _targetExp = MathHelper.Clamp(_targetExp - scrollDelta * _expDistance, _maxExp, _minExp);
            }

            if (RotateLeft.Pressed())
            {
                _targetRotation += MathHelper.Pi / 8f;
            }
            if (RotateRight.Pressed())
            {
                _targetRotation -= MathHelper.Pi / 8f;
            }

            _mouseWorld = Vector2.Transform(InputHelper.NewMouse.Position.ToVector2(), Matrix.Invert(GetView()));

            if (CameraDrag.Pressed())
            {
                _dragAnchor = _mouseWorld;
                _isDragged  = true;
            }
            if (_isDragged && CameraDrag.HeldOnly())
            {
                _xy        += _dragAnchor - _mouseWorld;
                _mouseWorld = _dragAnchor;
            }
            if (_isDragged && CameraDrag.Released())
            {
                _isDragged = false;
            }
        }
コード例 #4
0
ファイル: Form1.cs プロジェクト: zzfima/ImagesFilter
        private void rightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            IImageFilter filter = new RotateRight();
            var          img    = pictureBox1.Image;

            filter.Perform(img);
            pictureBox1.Image = img;
        }
コード例 #5
0
    public void RotateRightRobot(float orientation, float expect)
    {
        Robot robot = new Robot(8, 2, orientation);

        RotateRight movement = new RotateRight();

        movement.Move(robot);

        Assert.Equal(expect, robot.orientation);
    }
コード例 #6
0
ファイル: TurningTests.cs プロジェクト: erossini/PlutoRover
        public void RotateRight(int xCoordinate, int yCoordinate, char direction, string expected)
        {
            CompassDirection?compassDirection   = new DirectionFactory().Get(direction);
            IPosition        robotStartPosition = new Position(xCoordinate, yCoordinate, compassDirection);

            IRobotController robotController  = new RobotController(robotStartPosition, pluto);
            IRotate          robotCommand     = new RotateRight();
            IPosition        robotEndPosition = robotController.Move(robotCommand);

            Assert.AreEqual(expected, robotEndPosition.ToString());
        }
コード例 #7
0
    public void EnableAiScript(string in_scriptName)
    {
        _RotateRight = GetComponent<RotateRight>();
        _RotateLeft = GetComponent<RotateLeft>();

        if (in_scriptName.Equals("Right", StringComparison.InvariantCultureIgnoreCase) && _RotateRight != null)
        {
            _RotateRight.enabled = true;
            _RotateRight.Speed = Speed;
        }
        if (in_scriptName.Equals("Left", StringComparison.InvariantCultureIgnoreCase) && _RotateLeft != null)
        {
            _RotateLeft.enabled = true;
            _RotateLeft.Speed = Speed;
        }

    }
コード例 #8
0
        public void FourRightRotations_ReturnsToTheSamePositionAndDirection(
            int posX,
            int posY,
            int dirX,
            int dirY)
        {
            this.plain.IsPositionValid(Arg.Any <int>(), Arg.Any <int>()).Returns(true);
            var rover   = new Rover(this.plain, (posX, posY), (dirX, dirY));
            var command = new RotateRight();

            command.Execute(rover);
            command.Execute(rover);
            command.Execute(rover);
            command.Execute(rover);
            Assert.Equal(posX, rover.Position.X);
            Assert.Equal(posY, rover.Position.Y);
            Assert.Equal(dirX, rover.Direction.X);
            Assert.Equal(dirY, rover.Direction.Y);
        }
コード例 #9
0
    private void SetupDefaultBindings()
    {
        MoveLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
        MoveLeft.AddDefaultBinding(InputControlType.DPadLeft);
        MoveRight.AddDefaultBinding(InputControlType.LeftStickRight);
        MoveRight.AddDefaultBinding(InputControlType.DPadRight);

        Jump.AddDefaultBinding(InputControlType.LeftBumper);

        IgniteJetpack.AddDefaultBinding(InputControlType.LeftTrigger);
        RotateLeft.AddDefaultBinding(InputControlType.LeftStickLeft);
        RotateRight.AddDefaultBinding(InputControlType.LeftStickRight);

        Shoot.AddDefaultBinding(InputControlType.RightTrigger);

        AimUp.AddDefaultBinding(InputControlType.RightStickUp);
        AimDown.AddDefaultBinding(InputControlType.RightStickDown);
        AimLeft.AddDefaultBinding(InputControlType.RightStickLeft);
        AimRight.AddDefaultBinding(InputControlType.RightStickRight);
    }
コード例 #10
0
        void ReleaseDesignerOutlets()
        {
            if (ImageView != null)
            {
                ImageView.Dispose();
                ImageView = null;
            }

            if (LoadButton != null)
            {
                LoadButton.Dispose();
                LoadButton = null;
            }

            if (RotateLeft != null)
            {
                RotateLeft.Dispose();
                RotateLeft = null;
            }

            if (RotateRight != null)
            {
                RotateRight.Dispose();
                RotateRight = null;
            }

            if (SaveButton != null)
            {
                SaveButton.Dispose();
                SaveButton = null;
            }

            if (SettingsButton != null)
            {
                SettingsButton.Dispose();
                SettingsButton = null;
            }
        }
コード例 #11
0
 public bool GetRotateRight(HandSide hand)
 {
     return(RotateRight.GetStateDown(hand == HandSide.Left ? SteamVR_Input_Sources.LeftHand : SteamVR_Input_Sources.RightHand));
 }
コード例 #12
0
 static string Right1(string s)
 {
     return(RotateRight(1)(s));
 }
コード例 #13
0
        private void UpdateCameraInput(Camera c, int index)
        {
            int x = InputHelper.NewMouse.X;
            int y = InputHelper.NewMouse.Y;

            if (!_isDragged && CameraContains(c, x, y) || _isDragged && _currentCamera == index)
            {
                _currentCamera = index;
                if (MouseCondition.Scrolled())
                {
                    int scrollDelta = MouseCondition.ScrollDelta;
                    SetZoom(c, MathF.Min(MathF.Max(GetZoom(c) - scrollDelta * 0.001f, 0.2f), 10f));
                }

                if (RotateLeft.Pressed())
                {
                    c.Rotation += MathHelper.PiOver4;
                }
                if (RotateRight.Pressed())
                {
                    c.Rotation -= MathHelper.PiOver4;
                }

                if (Forward.Held())
                {
                    c.Z -= 0.1f;
                }
                if (Backward.Held())
                {
                    c.Z += 0.1f;
                }

                if (IncreaseFocal.Held())
                {
                    var temp = c.Z / c.FocalLength;

                    c.FocalLength += 0.01f;

                    c.Z = c.FocalLength * temp;
                }
                if (DecreaseFocal.Held())
                {
                    var temp = c.Z / c.FocalLength;

                    c.FocalLength -= 0.01f;

                    c.Z = c.FocalLength * temp;
                }

                if (ResetCamera.Pressed())
                {
                    c.Scale       = new Vector2(1f, 1f);
                    c.XY          = new Vector2(0f, 0f);
                    c.Z           = 2f;
                    c.Rotation    = 0f;
                    c.FocalLength = 1f;
                }

                _mouseWorld = c.ScreenToWorld(x, y);

                if (CameraDrag.Pressed())
                {
                    _dragAnchor = _mouseWorld;
                    _isDragged  = true;
                }
                if (_isDragged && CameraDrag.HeldOnly())
                {
                    c.XY       += _dragAnchor - _mouseWorld;
                    _mouseWorld = _dragAnchor;
                }
                if (_isDragged && CameraDrag.Released())
                {
                    _isDragged = false;
                }
            }
        }
コード例 #14
0
    // Update is called once per frame
    void Update()
    {
        // Set opacities initially to 0
        Color UnintrusiveLeftColor = UnintrusiveLeft.GetComponent <MeshRenderer>().material.color;

        UnintrusiveLeft.GetComponent <MeshRenderer>().material.color = new Color(UnintrusiveLeftColor.r, UnintrusiveLeftColor.g, UnintrusiveLeftColor.b, 0);
        Color LeftMaxColor = LeftMax.GetComponent <MeshRenderer>().material.color;

        LeftMax.GetComponent <MeshRenderer>().material.color = new Color(LeftMaxColor.r, LeftMaxColor.g, LeftMaxColor.b, 0);

        Color UnintrusiveRightColor = UnintrusiveRight.GetComponent <MeshRenderer>().material.color;

        UnintrusiveRight.GetComponent <MeshRenderer>().material.color = new Color(UnintrusiveRightColor.r, UnintrusiveRightColor.g, UnintrusiveRightColor.b, 0);
        Color RightMaxColor = RightMax.GetComponent <MeshRenderer>().material.color;

        RightMax.GetComponent <MeshRenderer>().material.color = new Color(RightMaxColor.r, RightMaxColor.g, RightMaxColor.b, 0);

        Color RotateLeftColor = RotateLeft.GetComponent <MeshRenderer>().material.color;

        RotateLeft.GetComponent <MeshRenderer>().material.color = new Color(RotateLeftColor.r, RotateLeftColor.g, RotateLeftColor.b, 0);

        Color RotateRightColor = RotateRight.GetComponent <MeshRenderer>().material.color;

        RotateRight.GetComponent <MeshRenderer>().material.color = new Color(RotateRightColor.r, RotateRightColor.g, RotateRightColor.b, 0);

        if (solution == Solution.Panels)
        {
            float reticleDistanceLeft  = 1 - (Vector3.Distance(RotateLeft.transform.position, reticlePointer.PointerTransform.forward * reticlePointer.maxReticleDistance) - 1.75f);
            float reticleDistanceRight = 1 - (Vector3.Distance(RotateRight.transform.position, reticlePointer.PointerTransform.forward * reticlePointer.maxReticleDistance) - 1.75f);
            reticleDistanceLeft  = Mathf.Clamp(reticleDistanceLeft, 0, 0.25f) * 4;
            reticleDistanceRight = Mathf.Clamp(reticleDistanceRight, 0, 0.25f) * 4;

            if (cameraControl.intrusivePanels) // Activate "intrusive" panels
            {
                Material[] leftMats = RotateLeft.GetComponent <Renderer>().materials;
                leftMats[0] = leftOpaquePanel;
                RotateLeft.GetComponent <Renderer>().materials          = leftMats;
                RotateLeft.GetComponent <MeshRenderer>().material.color = new Color(RotateLeftColor.r, RotateLeftColor.g, RotateLeftColor.b, 0);

                Material[] rightMats = RotateRight.GetComponent <Renderer>().materials;
                rightMats[0] = rightOpaquePanel;
                RotateRight.GetComponent <Renderer>().materials          = rightMats;
                RotateRight.GetComponent <MeshRenderer>().material.color = new Color(RotateRightColor.r, RotateRightColor.g, RotateRightColor.b, 0);
            }
            else
            {
                Material[] leftMats = RotateLeft.GetComponent <Renderer>().materials;
                leftMats[0] = leftPanel;
                RotateLeft.GetComponent <Renderer>().materials          = leftMats;
                RotateLeft.GetComponent <MeshRenderer>().material.color = new Color(RotateLeftColor.r, RotateLeftColor.g, RotateLeftColor.b, 0);

                Material[] rightMats = RotateRight.GetComponent <Renderer>().materials;
                rightMats[0] = rightPanel;
                RotateRight.GetComponent <Renderer>().materials          = rightMats;
                RotateRight.GetComponent <MeshRenderer>().material.color = new Color(RotateRightColor.r, RotateRightColor.g, RotateRightColor.b, 0);
            }

            if (GetComponent <CameraControl>().gradientsOn)
            {
                // Left side
                float LeftMaxOpacity = Mathf.Clamp(RotateLeft.GetComponent <PanelBehavior>().rotationSpeed, 3, 5) - 3;
                if (!greensOff)
                {
                    UnintrusiveLeft.GetComponent <MeshRenderer>().material.color = new Color(UnintrusiveLeftColor.r, UnintrusiveLeftColor.g, UnintrusiveLeftColor.b, RotateLeft.GetComponent <PanelBehavior>().rotationSpeed * 0.2f);
                }
                LeftMax.GetComponent <MeshRenderer>().material.color = new Color(LeftMaxColor.r, LeftMaxColor.g, LeftMaxColor.b, LeftMaxOpacity);

                // Right side
                float RightMaxOpacity = Mathf.Clamp(RotateRight.GetComponent <PanelBehavior>().rotationSpeed, 3, 5) - 3;
                if (!greensOff)
                {
                    UnintrusiveRight.GetComponent <MeshRenderer>().material.color = new Color(UnintrusiveRightColor.r, UnintrusiveRightColor.g, UnintrusiveRightColor.b, RotateRight.GetComponent <PanelBehavior>().rotationSpeed * 0.2f);
                }
                RightMax.GetComponent <MeshRenderer>().material.color = new Color(RightMaxColor.r, RightMaxColor.g, RightMaxColor.b, RightMaxOpacity);
            }
            if (visiblePanels)
            {
                RotateLeft.GetComponent <MeshRenderer>().material.color = new Color(RotateLeftColor.r, RotateLeftColor.g, RotateLeftColor.b, reticleDistanceLeft);

                RotateRight.GetComponent <MeshRenderer>().material.color = new Color(RotateRightColor.r, RotateRightColor.g, RotateRightColor.b, reticleDistanceRight);
            }
        }
        else if (solution == Solution.RotationMapping)
        {
            if (prevOrigin != orientation)
            {
                origin.transform.eulerAngles = new Vector3(origin.transform.eulerAngles.x, orientation, origin.transform.eulerAngles.z);
                transform.eulerAngles        = new Vector3(transform.eulerAngles.x, orientation + Vector3.SignedAngle(transform.forward, origin.transform.forward, transform.up), transform.eulerAngles.z);
                forward = origin.transform.forward;
            }

            //Debug.Log("Head rotation: " + GvrVRHelpers.GetHeadRotation().y);
            Vector3 reticleDirection  = Vector3.Normalize(transform.position + reticlePointer.MaxPointerEndPoint);
            float   orientationAngle  = Vector3.SignedAngle(forward, transform.forward, transform.up);
            float   rotationDirection = Vector3.SignedAngle(prevOrientation, reticleDirection, transform.up);
            //Debug.Log("Orientation angle: " + orientationAngle);
            //Debug.Log("Angle: " + angle);
            //Debug.Log(transform.eulerAngles.y);

            if (orientationAngle > -rotationMappingAngle && rotationDirection < 0)
            {
                if (GvrVRHelpers.GetHeadRotation().y * 360 < rotationMappingAngle)
                {
                    transform.eulerAngles = new Vector3(transform.eulerAngles.x, orientation + GvrVRHelpers.GetHeadRotation().y * 360, transform.eulerAngles.z);
                }
            }
            else if (orientationAngle < rotationMappingAngle && rotationDirection > 0)
            {
                if (GvrVRHelpers.GetHeadRotation().y * 360 > -rotationMappingAngle)
                {
                    transform.eulerAngles = new Vector3(transform.eulerAngles.x, orientation + GvrVRHelpers.GetHeadRotation().y * 360, transform.eulerAngles.z);
                }
            }

            prevOrientation = reticleDirection;
            prevOrigin      = orientation;
        }
    }
コード例 #15
0
        public FileContentResult ImageEditRequest([FromBody] string RequestData)
        {
            //map request to DTO RequestModel
            JObject model = new JObject();

            try
            {
                model = JObject.Parse(RequestData);
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.ToString());
            }
            RequestModel request = new RequestModel();

            try
            {
                request.ImageData  = model["ImageData"].ToString();
                request.Operations = model["Operations"].ToObject <List <JObject> >();
            }
            catch (Exception ex)
            {
                throw new SystemException("Invalid String", ex);
            }


            //create data stream
            var imageDataByteArray = Convert.FromBase64String(request.ImageData);

            var imageDataStream = new MemoryStream(imageDataByteArray);

            imageDataStream.Position = 0;

            //Save edited image result here
            var imageOutStream = new MemoryStream();

            ImageFactory imageFactory = new ImageFactory();

            imageFactory.Load(imageDataStream);

            foreach (JObject JOp in request.Operations)
            {
                if (JOp.ContainsKey("Resize"))
                {
                    var    JTemp  = JOp["Resize"];
                    Resize resize = JTemp.ToObject <Resize>();
                    resize.PerformAction(imageFactory);
                }
                else if (JOp.ContainsKey("Filter"))
                {
                    var    JTemp  = JOp["Filter"];
                    Filter filter = JTemp.ToObject <Filter>();
                    filter.PerformAction(imageFactory);
                }
                else if (JOp.ContainsKey("Flip"))
                {
                    var  JTemp = JOp["Flip"];
                    Flip flip  = JTemp.ToObject <Flip>();
                    flip.PerformAction(imageFactory);
                }
                else if (JOp.ContainsKey("RotateRight"))
                {
                    var         JTemp  = JOp["RotateRight"];
                    RotateRight rotate = JTemp.ToObject <RotateRight>();
                    rotate.PerformAction(imageFactory);
                }
                else if (JOp.ContainsKey("RotateDegrees"))
                {
                    var           JTemp         = JOp["RotateDegrees"];
                    RotateDegrees rotateDegrees = JTemp.ToObject <RotateDegrees>();
                    rotateDegrees.PerformAction(imageFactory);
                }
                else if (JOp.ContainsKey("Thumbnail"))
                {
                    var       JTemp     = JOp["Thumbnail"];
                    Thumbnail thumbnail = JTemp.ToObject <Thumbnail>();
                    thumbnail.PerformAction(imageFactory);
                }
            }
            imageFactory.Save(imageOutStream);

            return(File(imageOutStream.ToArray(), "image/png"));
        }
コード例 #16
0
 public Playercontroller()
 {
     this.MoveForwardCommand = new MoveForward(this);
     this.RotateLeftCommand  = new RotateLeft(this);
     this.RotateRightCommand = new RotateRight(this);
 }
    // Method for handling global events in the Unity Editor.
    static void GlobalEventHandler()
    {
        // If a reference to the rig exists.
        if (Rig != null)
        {
            // Set Rig movements based on key combinations.
            Rig.MovingForward  = MoveForward.KeyCombinationDown();
            Rig.MovingBackward = MoveBackward.KeyCombinationDown();
            Rig.MovingLeft     = MoveLeft.KeyCombinationDown();
            Rig.MovingRight    = MoveRight.KeyCombinationDown();
            Rig.RotatingLeft   = RotateLeft.KeyCombinationDown();
            Rig.RotatingRight  = RotateRight.KeyCombinationDown();
            Rig.LookingUp      = LookUp.KeyCombinationDown();
            Rig.LookingDown    = LookDown.KeyCombinationDown();
        }

        // If a reference to the lefthand controller exists.
        if (LeftHandController != null)
        {
            // Presses up on the primary 2D axis for the lefthand controller.
            if (LeftAxisUp.KeyCombinationClick())
            {
                LeftHandController.Primary2DAxis.TouchAxisUp();
            }

            // Presses down on the primary 2D axis for the lefthand controller.
            if (LeftAxisDown.KeyCombinationClick())
            {
                LeftHandController.Primary2DAxis.TouchAxisDown();
            }

            // Presses left on the primary 2D axis for the lefthand controller.
            if (LeftAxisLeft.KeyCombinationClick())
            {
                LeftHandController.Primary2DAxis.TouchAxisLeft();
            }

            // Presses right on the primary 2D axis for the lefthand controller.
            if (LeftAxisRight.KeyCombinationClick())
            {
                LeftHandController.Primary2DAxis.TouchAxisRight();
            }

            // Touches or untouhces the primary 2D axis for the lefthand controller.
            if (LeftAxisTouch.KeyCombinationClick())
            {
                LeftHandController.Primary2DAxis.Touch = !LeftHandController.Primary2DAxis.Touch;
            }

            // Clicks or unclicks the primary 2D axis for the lefthand controller.
            if (LeftAxisClick.KeyCombinationClick())
            {
                LeftHandController.Primary2DAxis.Click = !LeftHandController.Primary2DAxis.Click;
            }

            // Clicks or unclicks the trigger button for the lefthand controller.
            if (LeftTriggerButton.KeyCombinationClick())
            {
                LeftHandController.Trigger.Button = !LeftHandController.Trigger.Button;
            }

            // Clicks or unclicks the grip button for the lefthand controller.
            if (LeftGripButton.KeyCombinationClick())
            {
                LeftHandController.Grip.Button = !LeftHandController.Grip.Button;
            }

            // Clicks or unclicks the primary button for the lefthand controller.
            if (LeftPrimaryButton.KeyCombinationClick())
            {
                LeftHandController.PrimaryButton.Button = !LeftHandController.PrimaryButton.Button;
            }
        }

        // If a reference to the righthand controller exists.
        if (RightHandController != null)
        {
            // Presses up on the primary 2D axis for the righthand controller.
            if (RightAxisUp.KeyCombinationClick())
            {
                RightHandController.Primary2DAxis.TouchAxisUp();
            }

            // Presses down on the primary 2D axis for the righthand controller.
            if (RightAxisDown.KeyCombinationClick())
            {
                RightHandController.Primary2DAxis.TouchAxisDown();
            }

            // Presses left on the primary 2D axis for the righthand controller.
            if (RightAxisLeft.KeyCombinationClick())
            {
                RightHandController.Primary2DAxis.TouchAxisLeft();
            }

            // Presses right on the primary 2D axis for the righthand controller.
            if (RightAxisRight.KeyCombinationClick())
            {
                RightHandController.Primary2DAxis.TouchAxisRight();
            }

            // Touches or untouhces the primary 2D axis for the righthand controller.
            if (RightAxisTouch.KeyCombinationClick())
            {
                RightHandController.Primary2DAxis.Touch = !RightHandController.Primary2DAxis.Touch;
            }

            // Clicks or unclicks the primary 2D axis for the righthand controller.
            if (RightAxisClick.KeyCombinationClick())
            {
                RightHandController.Primary2DAxis.Click = !RightHandController.Primary2DAxis.Click;
            }

            // Clicks or unclicks the trigger button for the righthand controller.
            if (RightTriggerButton.KeyCombinationClick())
            {
                RightHandController.Trigger.Button = !RightHandController.Trigger.Button;
            }

            // Clicks or unclicks the grip button for the righthand controller.
            if (RightGripButton.KeyCombinationClick())
            {
                RightHandController.Grip.Button = !RightHandController.Grip.Button;
            }

            // Clicks or unclicks the primary button for the righthand controller.
            if (RightPrimaryButton.KeyCombinationClick())
            {
                RightHandController.PrimaryButton.Button = !RightHandController.PrimaryButton.Button;
            }
        }
    }