Esempio n. 1
0
        /// <summary>
        /// Primary update method.
        /// </summary>
        /// <param name="gameTime">This game time variable is updated automagically.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardState keystate = Keyboard.GetState();

            BasicModel tempModel = _models[0];

            _movementDataReporter = ShipMovement.MoveShip(_movementDataReporter, gameTime, ref tempModel);
            _models[0]            = tempModel;

            if (keystate.IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            if (_cameraType == CameraType.TargetCamera)
            {
                _camera.Update();
            }

            if (_cameraType == CameraType.FreeCamera)
            {
                _lastMouseState = ((FreeCamera)_camera).FreeCameraUpdate(gameTime, _camera, _lastMouseState);
            }

            _movementDataReporter = MouseGestures.CheckMouseClicked(_models, _boardPlane, _movementDataReporter, _camera, GraphicsDevice);



            base.Update(gameTime);
        }
Esempio n. 2
0
        /// <summary>
        /// Move/pan the camera around.
        /// </summary>
        private void PanCamera()
        {
            KeyboardState keystate   = Keyboard.GetState();
            MouseState    mouseState = Mouse.GetState();

            float cameraPanSpeed    = 14;
            float cameraUpDownSpeed = 500;

            if (mouseState.ScrollWheelValue < lastScrollValue)
            {
                cameraHeight += cameraUpDownSpeed;
            }

            if (mouseState.ScrollWheelValue > lastScrollValue && cameraHeight > 0)
            {
                cameraHeight -= cameraUpDownSpeed;
            }

            Vector3 deltaPosition = MouseGestures.RightMouseDown(cameraPanSpeed);

            if (mouseState.MiddleButton.Equals(ButtonState.Pressed))
            {
                cameraHeight = resetView;
            }

            lastScrollValue = mouseState.ScrollWheelValue;

            this.Position = Vector3.Lerp(this.Position,
                                         new Vector3(this.Position.X, cameraHeight, this.Position.Z),
                                         .1f);


            this.Position += deltaPosition;
            this.Target   += deltaPosition;
        }
Esempio n. 3
0
        private void AddMouseGesture(MouseGestures mg, Point pos)
        {
            if (mg == MouseGestures.None)
            {
                return;
            }

            if (mg != this.lastMouseGesture)
            {
                this.mouseGestures.Add(mg);
                this.mouseGesturesLocations.Add(pos);
                this.lastMouseGesture = mg;
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Injects a pressed mouse button.
        /// </summary>
        /// <param name="mb">The mouse button.</param>
        public void InjectMouseDown(MouseButton mb)
        {
            this.pressedMouseButtons[mb] = true;
            this.lastPressedMouseButton  = mb;
            this.lastMouseHeldTime       = this.MiyagiSystem.LastUpdate;

            // MouseGestures
            if (mb == this.MouseGesturesButton)
            {
                this.oldMouseGesturePositon = this.mouseLocation;
                this.lastMouseGesture       = MouseGestures.None;
                this.mouseGestures          = new List <MouseGestures>();
                this.mouseGesturesLocations = new List <Point>();
            }

            if (this.MouseDown != null)
            {
                this.MouseDown(this, new MouseButtonEventArgs(mb, this.mouseLocation));
            }
        }
Esempio n. 5
0
 void mouseGestures_Gesture(object sender, MouseGestures.MouseGestureEventArgs e)
 {
     if (e.Gesture.Motions == "R")
     {
         if (currentTabIndex+1 < tabControl.TabCount)
         {
             currentTabIndex++;
         }
     }
     if (e.Gesture.Motions == "L")
     {
         if (currentTabIndex > 0 )
         {
             currentTabIndex--;
         }
     }
     if (e.Gesture.Motions == "UD")
     {
         Application.Exit();
     }
     tabControl.SelectedIndex = currentTabIndex;
 }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if(currentEvent == null){
        }else if (currentEvent.type == EventType.MouseDown) {
            initialPosition = -Input.mousePosition;
            points.Clear();
            points.Add(initialPosition);
        } else if(currentEvent.type == EventType.MouseDrag) {
            currentPosition = -Input.mousePosition;
            points.Add(currentPosition);
        }

        if(gameObject.name == "player2"){
            if(currentEvent != null && currentEvent.type == EventType.MouseUp) {
                var recognizer = gameObject.AddComponent<HMMRecognizer>();
                var mouseGestures = new MouseGestures();
                var gesture = mouseGestures.GetGestureFromPoints(points);

        //				foreach(int g in gesture.HmmDirections)
        //					Debug.Log(g);
                try {
                    var hmm = recognizer.hmmEvalute(gesture.HmmDirections);
                    Debug.Log(string.Format("Recognized gesture: {0}", hmm));

                    gameObject.SendMessage("handleGesture", hmm, SendMessageOptions.DontRequireReceiver);
                }
                catch (UnityException e) {
                    Debug.Log(e);
                }

                GameObject.Destroy(recognizer);
            }
        }
    }