Example #1
0
        public override void HandleMouse(Microsoft.Xna.Framework.Input.MouseState mouse)
        {
            base.HandleMouse(mouse);

            if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                if (dragging == true)
                {
                    posPixel.X  += mouse.X - mouseX;
                    posPixel.Y  += mouse.Y - mouseY;
                    posPercent.X = posPixel.X / parentObject.SizePixels.Width;
                    posPercent.Y = posPixel.Y / parentObject.SizePixels.Height;
                    Resize(parentObject);
                }
                else if (imageDrawSpaces[(int)ImageNames.TitleBar].Contains(new Point(mouse.X - (int)posPixel.X, mouse.Y - (int)posPixel.Y)))
                {
                    dragging = true;
                }
            }
            else
            {
                dragging = false;
            }

            mouseY = mouse.Y;
            mouseX = mouse.X;
        }
Example #2
0
 protected override void OnIsMouseVisibleChanged()
 {
     Microsoft.Xna.Framework.Input.MouseState state = Microsoft.Xna.Framework.Input.Mouse.GetState();
     this._view.Window.CursorVisible = this.IsMouseVisible;
     System.Drawing.Point point = this._view.Window.PointToScreen(new System.Drawing.Point(state.X, state.Y));
     OpenTK.Input.Mouse.SetPosition((double)point.X, (double)point.Y);
 }
 protected override void MouseEnter(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     leftButtonDown      = false;
     dragging            = false;
     lastMousePosition.X = mouse.X;
     lastMousePosition.Y = mouse.Y;
 }
Example #4
0
 private void UpdateValuesFromState(ref MouseState newState)
 {
     Position = new Point(newState.X, newState.Y);
     Position = screen.FromPixelSpace(Position);
     ScrollWheelValue = newState.ScrollWheelValue;
     UpdateButtonStates(ref newState);
 }
Example #5
0
 public static Microsoft.Xna.Framework.Input.MouseState GetState()
 {
     Microsoft.Xna.Framework.Input.MouseState ms = Microsoft.Xna.Framework.Input.Mouse.GetState();
     return(new Microsoft.Xna.Framework.Input.MouseState(ms.X * 2, ms.Y * 2, ms.ScrollWheelValue,
                                                         ms.LeftButton, ms.MiddleButton, ms.RightButton,
                                                         ms.XButton1, ms.XButton2));
 }
Example #6
0
        public override void HandleMouse(Microsoft.Xna.Framework.Input.MouseState mouse)
        {
            //first check if a button was pressed
            base.HandleMouse(mouse);

            //now, if the click occured anywhere in the list items
            //make that the selected item.
            if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                leftButtonDown = true;
            }
            else
            {
                if (leftButtonDown == true) //a click has occured
                {
                    int oldselected = selected;
                    selected = (int)(((float)mouse.Y - posPixel.Y) / (float)itemHeight) + (int)scrollIndex;
                    if (selected == oldselected)    //clicking again should deselect the item.
                    {
                        selected = -1;
                    }
                    leftButtonDown = false;
                }
            }
        }
Example #7
0
 private void UpdateButtonStates(ref MouseState newState)
 {
     LeftButton = LeftButton.UpdateOnNativePressing(newState.LeftButton == ButtonState.Pressed);
     MiddleButton =
         MiddleButton.UpdateOnNativePressing(newState.MiddleButton == ButtonState.Pressed);
     RightButton = RightButton.UpdateOnNativePressing(newState.RightButton == ButtonState.Pressed);
     X1Button = X1Button.UpdateOnNativePressing(newState.XButton1 == ButtonState.Pressed);
     X2Button = X2Button.UpdateOnNativePressing(newState.XButton2 == ButtonState.Pressed);
 }
Example #8
0
        /// <summary>
        /// Permet de savoir quel bouton a été cliqué
        /// </summary>
        /// <param name="mouseState"></param>
        /// <returns></returns>
        public typeBtn getBtnClick(Microsoft.Xna.Framework.Input.MouseState mouseState)
        {
            typeBtn type = typeBtn.nul;

            foreach (Btn btn in this.listeBtn)
            {
                type = btn.isMouseIn(mouseState) ? btn.getType() : type;
            }

            return(type);
        }
Example #9
0
        private void UIDrawMethod(object instance, SpriteBatch sb)
        {
            string          modName = (string)(typeUIModItem.GetProperty("ModName", SGAmod.UniversalBindingFlags).GetValue(instance));
            CalculatedStyle style   = (CalculatedStyle)(typeUIModItem.GetMethod("GetInnerDimensions", SGAmod.UniversalBindingFlags).Invoke(instance, new object[] { }));

            if (modName == "SGAmod")
            {
                //Button

                Texture2D credits      = SGAmod.ExtraTextures[117];
                Vector2   buttonOffset = new Vector2(style.Width - 112, style.Height - 38);
                Rectangle boxSize      = new Rectangle(credits.Width / 2, 0, credits.Width / 2, credits.Height / 2);
                Vector2   pos          = style.Position() + buttonOffset;
                Rectangle inBox        = new Rectangle((int)pos.X, (int)pos.Y, boxSize.Width, boxSize.Height);

                sb.Draw(credits, style.Position() + buttonOffset, boxSize, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);


                if (inBox.Contains((int)Main.MouseScreen.X, (int)Main.MouseScreen.Y))
                {
                    instance.GetType().GetField("_tooltip", SGAmod.UniversalBindingFlags).SetValue(instance, "SGAmod Credits");
                    Microsoft.Xna.Framework.Input.MouseState mouseState = Microsoft.Xna.Framework.Input.Mouse.GetState();
                    if (mouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
                    {
                        Credits.CreditsManager.queuedCredits = true;
                        //Credits.CreditsManager.RollCredits();
                    }
                }


                //DynamicSpriteFontExtensionMethods.DrawString(sb, line.font, strrole, line.position, line.Colors.Item1, 0, new Vector2(strSize1.X, 0) / 2f, 1f, SpriteEffects.None, 0);



                //Dergon

                Texture2D Draken = ModContent.GetTexture("SGAmod/NPCs/TownNPCs/Dergon");
                int       frame  = (int)(Main.GlobalTime * 8f) % 7;

                Vector2 offset = new Vector2(180, style.Height - 10);
                //offset.Y += -frame*0.5f;//sprite is slightly offset


                Vector2 frameSize = new Vector2(Draken.Width, Draken.Height);

                Rectangle rect = new Rectangle(0, (int)(frame * (frameSize.Y / 7)), (int)frameSize.X, (int)(frameSize.Y / 7));

                SpriteEffects backAndForth = Main.GlobalTime % 38 < 19 ? SpriteEffects.None : SpriteEffects.FlipHorizontally;

                offset += new Vector2((Main.GlobalTime % 38) + (Main.GlobalTime % 38 < 19 ? 0 : ((Main.GlobalTime - 19) % 19) * -2), 0) * 12;

                sb.Draw(Draken, style.Position() + offset, rect, Color.White, 0, new Vector2(frameSize.X, frameSize.Y / 7f) / 2f, 0.50f, backAndForth, 0f);
            }
        }
Example #10
0
        private void HandleModifyMouseState(ref Microsoft.Xna.Framework.Input.MouseState mouseState)
        {
            var point = Control.MousePosition;

            var screen = mFrbControl.PointFromScreen(new System.Windows.Point(point.X, point.Y));
            var newMouseState = new Microsoft.Xna.Framework.Input.MouseState(
                MathFunctions.RoundToInt(screen.X),
                MathFunctions.RoundToInt(screen.Y),
                mouseState.ScrollWheelValue,
                mouseState.LeftButton,
                mouseState.MiddleButton,
                mouseState.RightButton,
                mouseState.XButton1,
                mouseState.XButton2);
            mouseState = newMouseState;
        }
Example #11
0
        public override void HandleMouse(Microsoft.Xna.Framework.Input.MouseState mouse)
        {
            base.HandleMouse(mouse);

            if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                currentState   = ButtonState.Pressed;
                leftButtonDown = true;
            }
            else if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released &&
                     leftButtonDown == true)
            {
                //handle on click.
                OnClick();
                currentState = ButtonState.MouseOver;
            }
        }
Example #12
0
        private void HandleModifyMouseState(ref Microsoft.Xna.Framework.Input.MouseState mouseState)
        {
            var point = Control.MousePosition;

            var screen        = mFrbControl.PointFromScreen(new System.Windows.Point(point.X, point.Y));
            var newMouseState = new Microsoft.Xna.Framework.Input.MouseState(
                MathFunctions.RoundToInt(screen.X),
                MathFunctions.RoundToInt(screen.Y),
                mouseState.ScrollWheelValue,
                mouseState.LeftButton,
                mouseState.MiddleButton,
                mouseState.RightButton,
                mouseState.XButton1,
                mouseState.XButton2);

            mouseState = newMouseState;
        }
Example #13
0
File: Gui.cs Project: hgrandry/Mgx
        public void Update(MouseState state, MouseState previousState)
        {
            // update focus

            var mouse = _ui.DrawMode == DrawMode.World ? UI.Mouse.WorldPosition : UI.Mouse.ScreenPosition;

            if (mouse.IsStriclyInside(_ui.Bounds))
            {
                _ui.Focus();
            }

            if (_ui.ActiveControl != null)
            {
                _ui.ActiveControl.Update();
            }

            _isUIFocused = _ui.FocusedControl != _ui;
            bool sceneFocused = false;

            if (!_isUIFocused && Scene.IsFocusable)
            {
                Scene.Update();
                sceneFocused = Scene.IsFocused;
            }

            IsFocused = _isUIFocused;
            var interactionFocus = sceneFocused || (_isUIFocused && _ui.FocusedControl.IsInteractive);

            if (interactionFocus != _previousInteractionFocus)
            {
                _previousInteractionFocus = interactionFocus;
                OnInteractionFocusChanged(interactionFocus);
            }

            // update press & release events

            if (state.LeftButton == ButtonState.Pressed && previousState.LeftButton == ButtonState.Released)
            {
                Press();
            }
            else if (state.LeftButton == ButtonState.Released && previousState.LeftButton == ButtonState.Pressed)
            {
                Release();
            }
        }
Example #14
0
        public void mouseControl()
        {
            Microsoft.Xna.Framework.Input.MouseState mouseState = Microsoft.Xna.Framework.Input.Mouse.GetState();

            if (Microsoft.Xna.Framework.Input.ButtonState.Pressed == mouseState.LeftButton)
            {
                inputGroup.Add(new inputObj((int)nonJoyTypes.mouse, "Left", 1));
            }

            if (Microsoft.Xna.Framework.Input.ButtonState.Pressed == mouseState.RightButton)
            {
                inputGroup.Add(new inputObj((int)nonJoyTypes.mouse, "Right", 1));
            }

            if (Microsoft.Xna.Framework.Input.ButtonState.Pressed == mouseState.MiddleButton)
            {
                inputGroup.Add(new inputObj((int)nonJoyTypes.mouse, "Middle", 1));
            }

            oldMouse = Microsoft.Xna.Framework.Input.Mouse.GetState();
        }
Example #15
0
        //public static bool operator == (MouseInfo left, MouseInfo right)
        //{
        //    return left.Console == right.Console && left.X == right.X && left.Y == right.Y;
        //}

        //public static bool operator !=(MouseInfo left, MouseInfo right)
        //{
        //    return left.Console != right.Console || left.X != right.X || left.Y != right.Y;
        //}

        /// <summary>
        /// Fills out the state of the mouse.
        /// </summary>
        /// <param name="gameTime"></param>
        public void ProcessMouse(Microsoft.Xna.Framework.GameTime gameTime)
        {
            Microsoft.Xna.Framework.Input.MouseState currentState = Microsoft.Xna.Framework.Input.Mouse.GetState();

            bool leftDown  = currentState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            bool rightDown = currentState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;

            bool newLeftClicked  = LeftButtonDown && !leftDown;
            bool newRightClicked = RightButtonDown && !rightDown;

            if (!newLeftClicked)
            {
                LeftDoubleClicked = false;
            }
            if (!newRightClicked)
            {
                RightDoubleClicked = false;
            }

            if (LeftClicked && newLeftClicked && gameTime.ElapsedGameTime.TotalMilliseconds < 1000)
            {
                LeftDoubleClicked = true;
            }
            if (RightClicked && newRightClicked && gameTime.ElapsedGameTime.TotalMilliseconds < 1000)
            {
                RightDoubleClicked = true;
            }

            LeftClicked           = newLeftClicked;
            RightClicked          = newRightClicked;
            _leftLastClickedTime  = gameTime.ElapsedGameTime;
            _rightLastClickedTime = gameTime.ElapsedGameTime;
            LeftButtonDown        = leftDown;
            RightButtonDown       = rightDown;

            ScrollWheelValueChange = ScrollWheelValue - currentState.ScrollWheelValue;
            ScrollWheelValue       = currentState.ScrollWheelValue;

            ScreenLocation = new Point(currentState.X, currentState.Y);
        }
Example #16
0
        public override void HandleMouse(Microsoft.Xna.Framework.Input.MouseState mouse)
        {
            int deltaX = lastMousePosition.X - mouse.X;
            int deltaY = lastMousePosition.Y - mouse.Y;

            if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                leftButtonDown = true;
                dragging       = true;
                CalculateCurrentValue(mouse.X, mouse.Y);
            }
            else if (mouse.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released && leftButtonDown == true)
            {
                leftButtonDown = false;
                dragging       = false;
                CalculateCurrentValue(mouse.X, mouse.Y);
            }

            lastMousePosition.X = mouse.X;
            lastMousePosition.Y = mouse.Y;

            base.HandleMouse(mouse);
        }
Example #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="gameTime"></param>
        public override void Update(GameTime gameTime)
        {
            if (XNArkanoidGame.mGameState != eGameState.DialogContinue)
            {
                return;
            }


            // Read mouse
            Microsoft.Xna.Framework.Input.MouseState st = Microsoft.Xna.Framework.Input.Mouse.GetState();

            // Check for player pressing A
            if ((Input.XInputHelper.GamePads[PlayerIndex.One].APressed || st.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) && PlayerContinues != null)
            {
                PlayerContinues(this, EventArgs.Empty);
            }

            // Refresh counter
            this.mCounter -= (float)gameTime.ElapsedGameTime.TotalSeconds;

            // Beep if counter changed
            if ((int)this.mCounter != mLastIntCounter)
            {
                Sound.Sound.Play(eSounds.menu_select2);
            }
            mLastIntCounter = (int)mCounter;

            // Check for counter reaching 0
            if (mCounter <= 0 && CounterReachedZero != null)
            {
                Sound.Sound.Play(eSounds.menu_advance);
                CounterReachedZero(this, EventArgs.Empty);
            }

            base.Update(gameTime);
        }
Example #18
0
 protected override void MouseEnter(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     mouseX   = mouse.X;
     mouseY   = mouse.Y;
     dragging = false;
 }
Example #19
0
        static ImmutableDictionary<Button, XnaButtonState> UpdateButtonsState(XnaMouseState state)
        {
            foreach (Button button in Enum.GetValues(typeof(Button)))
            {
                XnaButtonState newState;
                switch (button)
                {
                    case Button.Left:
                        newState = state.LeftButton;
                        break;
                    case Button.Right:
                        newState = state.RightButton;
                        break;
                    case Button.Middle:
                        newState = state.MiddleButton;
                        break;
                    case Button.XButton1:
                        newState = state.XButton1;
                        break;
                    case Button.XButton2:
                        newState = state.XButton2;
                        break;
                    default:
                        throw new NotImplementedException();
                }

                if (newState != buttonState[button])
                    buttonStateChange[button] = newState;
                else
                    buttonStateChange[button] = null;

                buttonState[button] = newState;
            }

            return buttonState.ToImmutableDictionary(k => k.Key, e => e.Value.Value);
        }
Example #20
0
 internal bool Contains(Microsoft.Xna.Framework.Input.MouseState mouseState)
 {
     return(DrawRect.Contains(new Point(mouseState.X, mouseState.Y)));
 }
Example #21
0
        public void update(Actor a, World w)
        {
            long ticks_now = System.DateTime.Now.Ticks / 10000;

            if (ticks_now > last_time_updated + update_interval)
            {
                last_time_updated    = ticks_now;
                cur_available_crafts = new List <CraftRecipe>();
                id_nearby_furniture  = w.collision_table.get_furniture_in_range(new Point((int)a.world_loc.X, (int)a.world_loc.Y), 120, w);
                for (int x = 0; x < Exilania.crafting_manager.recipes.Count; x++)
                {
                    if (check_is_recipe_valid(Exilania.crafting_manager.recipes[x], a, w))
                    {
                        cur_available_crafts.Add(Exilania.crafting_manager.recipes[x]);
                    }
                }
            }
            if (a.items.show_backpack)
            {
                crafting_area   = new Rectangle(Exilania.screen_size.X - 140, 60, 140, 10 + (50 * num_show));
                cur_mouse_state = Microsoft.Xna.Framework.Input.Mouse.GetState();
                Point mouse_loc = new Point(cur_mouse_state.X, cur_mouse_state.Y);

                if (crafting_area.Contains(mouse_loc))
                {
                    if (cur_mouse_state.ScrollWheelValue != last_mouse_state.ScrollWheelValue && ticks_now > last_scroll_frame + scroll_frame_delay)
                    {
                        last_scroll_frame = ticks_now;
                        if (cur_mouse_state.ScrollWheelValue > last_mouse_state.ScrollWheelValue)
                        {
                            first_show--;
                        }
                        else
                        {
                            first_show++;
                        }
                    }
                    if (first_show < 0)
                    {
                        first_show = 0;
                    }
                    if (first_show + num_show > cur_available_crafts.Count)
                    {
                        if (cur_available_crafts.Count > num_show)
                        {
                            first_show = cur_available_crafts.Count - num_show;
                        }
                        else
                        {
                            first_show = 0;
                        }
                    }
                    if (cur_click == -1)
                    {
                        hover_over = -1;
                        //mouse is hovering in the crafting area.
                        for (int x = first_show; x < num_show + first_show; x++)
                        {
                            Rectangle temp = new Rectangle(Exilania.screen_size.X - 60, 70 + (x - first_show) * 50, 46, 46);
                            if (temp.Contains(mouse_loc) && x < cur_available_crafts.Count)
                            {
                                hover_over = x;
                            }
                        }
                    }
                    else
                    {
                        hover_over = cur_click;
                    }
                    if (cur_mouse_state.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && last_time_bought + buy_delay <= ticks_now &&
                        cur_available_crafts.Count > 0 &&
                        ((cur_click > -1 && cur_available_crafts.Count > cur_click && cur_click_name == cur_available_crafts[cur_click].name) ||
                         (cur_click_name == "" && hover_over > -1 && cur_available_crafts.Count > hover_over)))
                    {
                        buys_in_a_row++;
                        if (buys_in_a_row == 1)
                        {
                            cur_click      = hover_over;
                            cur_click_name = cur_available_crafts[cur_click].name;
                        }
                        buy_delay -= 10;
                        if (buy_delay < 20)
                        {
                            buy_delay = 20;
                        }
                        if (check_is_recipe_valid(cur_available_crafts[hover_over], a, w))
                        {
                            a.items.click_consumed = true;
                            take_item_requirements(cur_available_crafts[hover_over], a, w);
                            a.stats.get_experience_crafting(cur_available_crafts[hover_over].complexity, a);
                            for (int i = 0; i < cur_available_crafts[hover_over].output.Count; i++)
                            {
                                switch (cur_available_crafts[hover_over].output[i].type)
                                {
                                case ItemType.Block:
                                    a.items.pickup_block((sbyte)cur_available_crafts[hover_over].output[i].item_id, (ushort)cur_available_crafts[hover_over].output[i].item_quantity);
                                    Exilania.display.fading_text.Add(new FadeText("@00+" + cur_available_crafts[hover_over].output[i].item_quantity + " " +
                                                                                  Exilania.block_types.blocks[cur_available_crafts[hover_over].output[i].item_id].name,
                                                                                  Display.default_msec_show_fade_text / 2, (int)a.world_loc.X + 18, (int)a.world_loc.Y - 40, true, true));
                                    break;

                                case ItemType.Furniture:
                                    a.items.pickup_furniture(cur_available_crafts[hover_over].output[i].item_id, (ushort)cur_available_crafts[hover_over].output[i].item_quantity);
                                    Exilania.display.fading_text.Add(new FadeText("@00+" + cur_available_crafts[hover_over].output[i].item_quantity + " " +
                                                                                  Exilania.furniture_manager.furniture[cur_available_crafts[hover_over].output[i].item_id].name,
                                                                                  Display.default_msec_show_fade_text / 2, (int)a.world_loc.X + 18, (int)a.world_loc.Y - 40, true, true));
                                    break;

                                case ItemType.ItemPiece:
                                    Item temp = new Item();
                                    temp.add_piece(Exilania.item_manager.item_pieces[cur_available_crafts[hover_over].output[i].item_id], cur_available_crafts[hover_over].output[i].item_id, -1, 0, 0, 0);
                                    temp.construct_item(Exilania.item_manager.item_pieces[cur_available_crafts[hover_over].output[i].item_id].name);
                                    a.items.pickup_item(temp);
                                    Exilania.display.fading_text.Add(new FadeText("@00Received " +
                                                                                  temp.item_name,
                                                                                  Display.default_msec_show_fade_text / 2, (int)a.world_loc.X + 18, (int)a.world_loc.Y - 40, true, true));
                                    break;

                                case ItemType.Material:
                                    a.items.pickup_material(cur_available_crafts[hover_over].output[i].item_id, (ushort)cur_available_crafts[hover_over].output[i].item_quantity);
                                    Exilania.display.fading_text.Add(new FadeText("@00+" + cur_available_crafts[hover_over].output[i].item_quantity + " " +
                                                                                  Exilania.material_manager.materials[cur_available_crafts[hover_over].output[i].item_id].name,
                                                                                  Display.default_msec_show_fade_text / 2, (int)a.world_loc.X + 18, (int)a.world_loc.Y - 40, true, true));
                                    break;
                                }
                            }
                            last_time_bought = ticks_now;
                        }
                        a.items.click_consumed  = true;
                        a.items.last_left_state = true;
                    }
                    else if (last_time_bought + buy_delay <= ticks_now && cur_mouse_state.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
                    {
                        cur_click      = -1;
                        cur_click_name = "";
                        buys_in_a_row  = 0;
                        buy_delay      = 200;
                    }
                }
                if (first_show < 0)
                {
                    first_show = 0;
                }
                if (first_show + num_show > cur_available_crafts.Count)
                {
                    if (cur_available_crafts.Count > num_show)
                    {
                        first_show = cur_available_crafts.Count - num_show;
                    }
                    else
                    {
                        first_show = 0;
                    }
                }
                last_mouse_state = cur_mouse_state;
            }
        }
Example #22
0
 protected override void MouseExit(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     return;
 }
Example #23
0
 public Mouse()
 {
     _mouse = Microsoft.Xna.Framework.Input.Mouse.GetState();
 }
Example #24
0
 protected override void MouseExit(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     leftButtonDown = false;
     dragging       = false;
 }
Example #25
0
 internal bool isIn(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     return(mouse.X > Position.X + Vp.X && mouse.Y > Position.Y + Vp.Y &&
            mouse.X < Position.X + Texture.Width + Vp.X && mouse.Y < Position.Y + Texture.Height + Vp.Y);
 }
Example #26
0
        public override void Update(Microsoft.Xna.Framework.GameTime gameTime, Microsoft.Xna.Framework.Input.KeyboardState keyboard, Microsoft.Xna.Framework.Input.MouseState mouse)
        {
            Viewport viewport       = MobileFortressClient.Game.GraphicsDevice.Viewport;
            ShipObj  Ship           = (ShipObj)Camera.Target;
            Vector3  Crosshair      = Ship.Entity.WorldTransform.Forward * 70;
            Vector3  ScreenLocation = viewport.Project(Crosshair, Camera.Projection, Camera.View, Matrix.CreateTranslation(Ship.Entity.WorldTransform.Translation));

            RCrosshairs.Location = new Point((int)ScreenLocation.X - Crosshairs.Width / 2, (int)ScreenLocation.Y - Crosshairs.Height / 2);

            Crosshair             = Ship.Entity.WorldTransform.Forward * 35;
            ScreenLocation        = viewport.Project(Crosshair, Camera.Projection, Camera.View, Matrix.CreateTranslation(Ship.Entity.WorldTransform.Translation));
            RCrosshairs2.Location = new Point((int)ScreenLocation.X - Crosshairs.Width / 4, (int)ScreenLocation.Y - Crosshairs.Height / 4);

            float dt = (float)gameTime.ElapsedGameTime.TotalSeconds;

            if (LockStatus == LockonStatus.Locking)
            {
                lockTime += dt;
                if (lockTime >= 0.2f)
                {
                    lockTime = 0f;
                    Resources.Sounds.LockingOn.Play();
                }
            }
            if (enemyLock)
            {
                enemyLockTime += dt;
                if (enemyLockTime >= Resources.Sounds.EnemyLockon.Duration.TotalSeconds * 1.2f)
                {
                    enemyLockTime = 0f;
                    Resources.Sounds.EnemyLockon.Play();
                }
            }

            FrameCounter.Update(gameTime);
            Manager.Update(gameTime, mouse);
        }
Example #27
0
 protected override void MouseExit(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     leftButtonDown = false;
     currentState   = ButtonState.Default;
 }
Example #28
0
 public static void Update()
 {
     oldMouseState     = currentMouseState;
     currentMouseState = Microsoft.Xna.Framework.Input.Mouse.GetState();
 }
Example #29
0
        /// <summary>
        /// check for new updates
        /// </summary>
        public void Update()
        {
            // get the mousestate
            Microsoft.Xna.Framework.Input.MouseState ms = Microsoft.Xna.Framework.Input.Mouse.GetState();
            this.lastKeyboardState    = this.currentKeyboardState;
            this.currentKeyboardState = Microsoft.Xna.Framework.Input.Keyboard.GetState();

            // get the movement and position

            this.mouseMovement         = new Microsoft.Xna.Framework.Vector2((FenrirGame.Instance.Properties.ScreenWidth / 2 - ms.X), (FenrirGame.Instance.Properties.ScreenHeight / 2 - ms.Y));
            this.currentMousePosition -= mouseMovement * 1.05f;
            Microsoft.Xna.Framework.Input.Mouse.SetPosition(FenrirGame.Instance.Properties.ScreenWidth / 2, FenrirGame.Instance.Properties.ScreenHeight / 2);

            if (this.currentMousePosition.X < 0)
            {
                this.currentMousePosition.X = 0;
            }
            else if (this.currentMousePosition.X > FenrirGame.Instance.Properties.ScreenWidth)
            {
                this.currentMousePosition.X = FenrirGame.Instance.Properties.ScreenWidth;
            }

            if (this.currentMousePosition.Y < 0)
            {
                this.currentMousePosition.Y = 0;
            }
            else if (this.currentMousePosition.Y > FenrirGame.Instance.Properties.ScreenHeight)
            {
                this.currentMousePosition.Y = FenrirGame.Instance.Properties.ScreenHeight;
            }

            // get the scrollwheel
            this.scrollValue    = scrollValueOld - ms.ScrollWheelValue;
            this.scrollValueOld = ms.ScrollWheelValue;

            // calculate boundingbox
            this.boundingBox.X = (int)FenrirGame.Instance.Properties.Input.CurrentMousePosition.X;
            this.boundingBox.Y = (int)FenrirGame.Instance.Properties.Input.CurrentMousePosition.Y;

            // buttonstates
            Boolean leftPressed  = ms.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            Boolean rightPressed = ms.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;

            // reset click events
            this.releaseLeft  = false;
            this.releaseRight = false;
            this.leftClick    = false;
            this.rightClick   = false;

            // check if dragging or clicked
            if (leftPressed)
            {
                if (!this.dragLeftStart.HasValue)
                {
                    this.dragLeftStart = this.currentMousePosition;
                }
                else if (!this.leftDrag && (Math.Abs(this.currentMousePosition.X - this.dragLeftStart.Value.X) > 5) || (Math.Abs(this.currentMousePosition.Y - this.dragLeftStart.Value.Y) > 5))
                {
                    this.leftDrag = true;
                }
            }
            else
            {
                if (this.dragLeftStart.HasValue)
                {
                    this.dragLeftStart = null;
                    this.leftDrag      = false;
                    this.releaseLeft   = true;

                    if (!this.leftDrag)
                    {
                        this.leftClick = true;
                    }
                }
            }

            if (rightPressed)
            {
                if (!this.dragRightStart.HasValue)
                {
                    this.dragRightStart = this.currentMousePosition;
                }
                else if (!this.rightDrag && (Math.Abs(this.currentMousePosition.X - this.dragRightStart.Value.X) > 5) || (Math.Abs(this.currentMousePosition.Y - this.dragRightStart.Value.Y) > 5))
                {
                    this.rightDrag = true;
                }
            }
            else
            {
                if (this.dragRightStart.HasValue)
                {
                    this.dragRightStart = null;
                    this.rightDrag      = false;
                    this.releaseRight   = true;

                    if (!this.rightDrag)
                    {
                        this.rightClick = true;
                    }
                }
            }

            // keaboard stuff
            this.moveCamLeft  = currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.A);
            this.moveCamRight = currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D);
            this.moveCamUp    = currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.W);
            this.moveCamDown  = currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.S);
            this.resetCamRot  = currentKeyboardState.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.D0);

            if (currentKeyboardState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Escape) && !lastKeyboardState.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                this.endCurrentAction = true;
            }
            else
            {
                this.endCurrentAction = false;
            }

            if (FenrirGame.Instance.Properties.CurrentGameState == GameState.InGame)
            {
                Microsoft.Xna.Framework.Vector3 nearsource = new Microsoft.Xna.Framework.Vector3(this.currentMousePosition.X, this.currentMousePosition.Y, 0f);
                Microsoft.Xna.Framework.Vector3 farsource  = new Microsoft.Xna.Framework.Vector3(this.currentMousePosition.X, this.currentMousePosition.Y, 1f);

                Microsoft.Xna.Framework.Vector3 nearPoint = FenrirGame.Instance.Properties.GraphicDeviceManager.GraphicsDevice.Viewport.Unproject(
                    nearsource,
                    FenrirGame.Instance.InGame.Camera.Projection,
                    FenrirGame.Instance.InGame.Camera.View,
                    FenrirGame.Instance.InGame.Camera.World);
                Microsoft.Xna.Framework.Vector3 farPoint = FenrirGame.Instance.Properties.GraphicDeviceManager.GraphicsDevice.Viewport.Unproject(
                    farsource,
                    FenrirGame.Instance.InGame.Camera.Projection,
                    FenrirGame.Instance.InGame.Camera.View,
                    FenrirGame.Instance.InGame.Camera.World);

                Microsoft.Xna.Framework.Vector3 direction = farPoint - nearPoint;
                direction.Normalize();
                this.mouseRay = new Microsoft.Xna.Framework.Ray(nearPoint, direction);

                this.currentMousePositionInWorld = FenrirGame.Instance.Properties.GraphicDeviceManager.GraphicsDevice.Viewport.Unproject(
                    nearsource,
                    FenrirGame.Instance.InGame.Camera.Projection,
                    FenrirGame.Instance.InGame.Camera.View,
                    Microsoft.Xna.Framework.Matrix.Identity
                    );
            }
        }
Example #30
0
 protected override void MouseEnter(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     leftButtonDown = false;
     currentState   = ButtonState.MouseOver;
 }
Example #31
0
 /// <summary>
 /// Реагируем на изменение мыши
 /// </summary>
 /// <param name="state">Состояние мыши</param>
 public override void ChangeState(Microsoft.Xna.Framework.Input.MouseState state)
 {
 }
Example #32
0
 public MouseEventArgs(Microsoft.Xna.Framework.Input.MouseState mouseState)
 {
     this.MouseState = mouseState;
 }
Example #33
0
 public override bool MouseLeftClick(Microsoft.Xna.Framework.Input.MouseState mouse)
 {
     return(base.MouseLeftClick(mouse));
 }
Example #34
0
 public override void HandleInput(Microsoft.Xna.Framework.Input.GamePadState gamePadState, Microsoft.Xna.Framework.Input.KeyboardState keyState, Microsoft.Xna.Framework.Input.MouseState mouseState)
 {
     //none?
 }
Example #35
0
 private void Button_OnMouseUp(GameObject sender, Microsoft.Xna.Framework.Input.MouseState state)
 {
     PlayAnimation("default");
 }