示例#1
0
        public void Update(GameTime gameTime)
        {
            KeyboardObject.Update();
            MouseObject.Update();
            Vector2 movement = Vector2.Zero;

            if (state == HeroState.ISBLINK)
            {
                _blinktime += gameTime.ElapsedGameTime.TotalSeconds;
                if (_blinktime >= 1.0f)
                {
                    state      = HeroState.NORMAL;
                    _blinktime = 0.0f;
                }
            }

            UpdateKyeboardAndMouce(ref movement);
            CheckCanMove();

            _sprite.Position += movement;
            UpdateRay(movement);

            UpdateAnimation(gameTime);

            _weapon.SetRotation(MouseObject.Position + (Camera2D.GetInstance().Position - new Vector2(600, 450)));
            _weapon.Updata();
            _sprite.Update();
        }
示例#2
0
 private void UnHoverMouseObject()
 {
     if (_hoveredMouseObject != null)
     {
         _hoveredMouseObject.Exited();
     }
     _hoveredMouseObject = null;
 }
示例#3
0
        /// <summary>
        /// 마우스의 포인터 점을 변경합니다.
        /// </summary>
        /// <param name="ob"></param>
        /// <param name="point"></param>
        private void ChangePosition(MouseObject ob, Point point)
        {
            if (Adorner == null)
            {
                Adorner = new MouseAdorner((UIElement)Window.Content);

                FirstPosition.Key  = 0;
                SecondPosition.Key = 1;
            }

            ob.point = point;
            Adorner.AddObject(ob);
        }
示例#4
0
文件: Game1.cs 项目: ivanoreh/Ripply
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            simulator = new WaveSimulator(GraphicsDevice, spriteBatch, 500, 500, Content.Load <Effect>("simulation"), Content.Load <Effect>("drawing"));

            Pixel = new Texture2D(GraphicsDevice, 1, 1);
            Pixel.SetData <Color>(new Color[] { Color.White });

            Circle  = Content.Load <Texture2D>("circle");
            Picture = Content.Load <Texture2D>("pic");

            keyboard = new KeyboardObject();
            mouse    = new MouseObject(Content, "mouse");

            GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
        }
示例#5
0
        private static void get_PressedIngameKeys()
        {
            try
            {
                A_Collection.Hotkeys.IngameKeys.IsForceStandStill =
                    A_Collection.Hotkeys._PressedKeys.Contains(A_Tools.InputSimulator.IS_Keyboard.convert_KeyToSlimDxKey(A_Collection.Preferences.Hotkeys.Key1_ForceStandStill)) ||
                    A_Collection.Hotkeys._PressedKeys.Contains(A_Tools.InputSimulator.IS_Keyboard.convert_KeyToSlimDxKey(A_Collection.Preferences.Hotkeys.Key2_ForceStandStill));

                Key key_1 = A_Tools.InputSimulator.IS_Keyboard.convert_KeyToSlimDxKey(A_Collection.Preferences.Hotkeys.Key1_ForceMove);
                Key key_2 = A_Tools.InputSimulator.IS_Keyboard.convert_KeyToSlimDxKey(A_Collection.Preferences.Hotkeys.Key2_ForceMove);
                if (key_1 == Key.Unknown && key_2 == Key.Unknown)
                {
                    if (A_Collection.Hotkeys._pressedMouseButtons.Count > 0)
                    {
                        //try mouse read
                        MouseObject m_1 = A_Tools.InputSimulator.IS_Keyboard.convert_KeyToMouseObject(A_Collection.Preferences.Hotkeys.Key1_ForceMove);
                        MouseObject m_2 = A_Tools.InputSimulator.IS_Keyboard.convert_KeyToMouseObject(A_Collection.Preferences.Hotkeys.Key1_ForceMove);

                        A_Collection.Hotkeys.IngameKeys.isForceMove = A_Collection.Hotkeys._pressedMouseButtons.Contains(m_1) || A_Collection.Hotkeys._pressedMouseButtons.Contains(m_2);

                        //if (A_Collection.Hotkeys.IngameKeys.isForceMove)
                        //    System.Windows.MessageBox.Show("Force Move pressed!");
                    }
                }
                else
                {
                    A_Collection.Hotkeys.IngameKeys.isForceMove =
                        A_Collection.Hotkeys._PressedKeys.Contains(key_1) ||
                        A_Collection.Hotkeys._PressedKeys.Contains(key_2);
                }



                A_Collection.Hotkeys.IngameKeys.IsTownPortal =
                    A_Collection.Hotkeys._PressedKeys.Contains(A_Tools.InputSimulator.IS_Keyboard.convert_KeyToSlimDxKey(A_Collection.Preferences.Hotkeys.Key1_Townportal)) ||
                    A_Collection.Hotkeys._PressedKeys.Contains(A_Tools.InputSimulator.IS_Keyboard.convert_KeyToSlimDxKey(A_Collection.Preferences.Hotkeys.Key2_Townportal));
            }
            catch (Exception e)
            {
                A_Handler.Log.Exception.addExceptionLogEntry(e, A_Enums.ExceptionThread.ECollector);
            }
        }
示例#6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            MouseObject.Load(Content);

            defaultFont = Content.Load <SpriteFont>("DefaultFomt");
            MyContentManager.instance.defaultFont = defaultFont;

            enemy  = new Object.EnemyObject.enemy1(new Vector2(200, 200), 115, 85, new Vector2(5, 5), 0.0f, new Vector2(0, 0), new Vector2(1, 1), Color.White, true);
            enemy1 = new Object.EnemyObject.enemygGBL(new Vector2(400, 200), 115, 85, new Vector2(5, 5), 0.0f, new Vector2(0, 0), new Vector2(1, 1), Color.White, true);

            stage = new Object.StageObject.Stage1();

            Object.BoomEffectObject.boomEffect1 boom = new Object.BoomEffectObject.boomEffect1(new Vector2(100, 100));
            GameManager.GetInstance().AddBoomEffect(boom);

            GameManager.GetInstance().AddPlayer(hero);
            GameManager.GetInstance().AddEnemy(enemy);
            GameManager.GetInstance().AddEnemy(enemy1);
            // TODO: use this.Content to load your game content here
        }
示例#7
0
        /// <summary>
        /// 마우스의 포인터 점을 변경합니다.
        /// </summary>
        /// <param name="ob"></param>
        /// <param name="point"></param>
        private void ChangePosition(MouseObject ob, Point point)
        {
            if (Adorner == null)
            {
                Adorner = new MouseAdorner((UIElement)Window.Content);

                FirstPosition.Key = 0;
                SecondPosition.Key = 1;
            }

            ob.point = point;
            Adorner.AddObject(ob);
        }
示例#8
0
 public bool GetButtonPress(MouseObject mouseObject, bool ignorePressStamp = false)
 {
     return false;
 }
示例#9
0
    void Update()
    {
        //Input events
        if (CurrentPlayerState == PlayerState.SorroundViewing)
        {
            return;
        }

        Ray        ray = _camera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit, Single.PositiveInfinity, LayerMask.GetMask("SorroundPhotoLocations")))
        {
            MouseObject hovered = hit.transform.GetComponent <MouseObject>();
            if (hovered != null)
            {
                if (_hoveredMouseObject != null)
                {
                    if (_hoveredMouseObject == hovered)
                    {
                        _hoveredMouseObject.Stayed();
                    }
                    else
                    {
                        UnHoverMouseObject();

                        _hoveredMouseObject = hovered;
                        _hoveredMouseObject.Hovered();
                    }
                }
                else
                {
                    _hoveredMouseObject = hovered;
                    _hoveredMouseObject.Hovered();
                }
            }
            else
            {
                UnHoverMouseObject();
            }
        }
        else
        {
            UnHoverMouseObject();
        }

        //Check if left/right mouse button was clicked or held
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit raycastHit;
            int        layer = 1 << 15;
            if (Physics.Raycast(ray, out raycastHit, 1000, layer))
            {
                if (!_isDraggingObject)
                {
                    RaycastHit floorHit;
                    int        floorLayer = 1 << 10;
                    if (Physics.Raycast(ray, out floorHit, float.PositiveInfinity, floorLayer))
                    {
                        StartDrag(raycastHit.transform.GetComponent <DragObject>());
                    }
                    else
                    {
                        Debug.Log("Attempted drag but didn't find floor reference point");
                    }
                }
            }
            else
            {
                _mouseLeftClickCheck = StartCoroutine(CheckForLeftClick(_mouseClickSpeed));
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            _mouseRightClickCheck = StartCoroutine(CheckForRightClick(_mouseClickSpeed));
        }

        if (Input.GetMouseButtonUp(0))
        {
            if (_isDraggingObject)
            {
                StopDrag();
            }
            else
            {
                if (_isLeftMouseClick)
                {
                    LeftMouseClicked();
                }
                _isLeftMouseClick = false;
                if (_mouseLeftClickCheck != null)
                {
                    StopCoroutine(_mouseLeftClickCheck);
                }
            }
        }

        if (Input.GetMouseButtonUp(1))
        {
            if (_isRightMouseClick)
            {
                RightMouseClicked();
            }
            _isRightMouseClick = false;
            if (_mouseRightClickCheck != null)
            {
                StopCoroutine(_mouseRightClickCheck);
            }
        }

        if (Input.GetMouseButton(0) && !_isLeftMouseClick)
        {
            if (_isDraggingObject)
            {
                RaycastHit floorHit;
                int        floorLayer = 1 << 10;
                if (Physics.Raycast(ray, out floorHit, float.PositiveInfinity, floorLayer))
                {
                    float   distance  = Vector3.Distance(_dragReferencePoint, floorHit.point);
                    Vector3 direction = (floorHit.point - _dragReferencePoint).normalized;
                    _dragObject.OnDrag(distance, direction);
                }
            }
            else
            {
                transform.Rotate(Vector3.up, _mouseMovementSpeed * Input.GetAxis("Mouse X"));
                _camera.transform.Rotate(Vector3.right, _mouseMovementSpeed * -Input.GetAxis("Mouse Y"));
                if (_camera.transform.localEulerAngles.y > 90)
                {
                    if (_camera.transform.localEulerAngles.x < 180)
                    {
                        float angle = 89 - _camera.transform.localEulerAngles.x;
                        _camera.transform.Rotate(Vector3.right, -angle);
                    }
                    else
                    {
                        float angle = 269 - _camera.transform.localEulerAngles.x;
                        _camera.transform.Rotate(Vector3.right, -angle);
                    }
                }
            }
        }

        if (Input.GetMouseButton(1) && !_isRightMouseClick)
        {
            transform.Translate(_mouseMovementSpeed * -Input.GetAxis("Mouse X"),
                                0,
                                _mouseMovementSpeed * -Input.GetAxis("Mouse Y"));
        }

        if (Input.GetAxis("Mouse ScrollWheel") != 0 && !PlayerUIController.Instance.ScrollLocked)
        {
            transform.Translate(_camera.transform.forward * Input.GetAxis("Mouse ScrollWheel") * _mouseScrollSpeed, Space.World);
        }

        _triggerFloor.position = new Vector3(transform.position.x, _triggerFloor.position.y, transform.position.z);
    }