public override void Update(GameTime gt)
            {
                base.Update(gt);
                MouseService.Cursor.Position = new Vector2(MouseService.Cursor.Position.X + (_moveCursor.Position.X * 5),
                                                           MouseService.Cursor.Position.Y - (_moveCursor.Position.Y * 5));

                if (MouseService.IsMouseButtonPressed(MouseButton.RightButton) || _emitButton.Pressed())
                {
                    EntityGame.Log.Write("Mouse button pressed, dispensing particles", this, Alert.Info);
                }
                if (MouseService.IsMouseButtonDown(MouseButton.RightButton) || _emitButton.Down())
                {
                    Spawner.Emit(30);
                }
                if (MouseService.IsMouseButtonReleased(MouseButton.RightButton) || _emitButton.Pressed())
                {
                    EntityGame.Log.Write("Mouse button released, stopping particles", this, Alert.Info);
                }
            }
Esempio n. 2
0
            public override void Update(GameTime gt)
            {
                base.Update(gt);

                if (!HasFocus && Body.BoundingRect.Contains((int)MouseService.Cursor.Position.X,
                                                            (int)MouseService.Cursor.Position.Y))
                {
                    _imageRender.Color = HoverColor;
                    if (MouseService.IsMouseButtonPressed(MouseButton.LeftButton))
                    {
                        _clickposition = MouseService.Cursor.Position;
                        HasFocus       = true;
                    }
                    if (MouseService.IsMouseButtonPressed(MouseButton.RightButton))
                    {
                        HasFocus       = true;
                        _lastImmovable = Collision.Immovable;
                    }
                }
                else if (!HasFocus)
                {
                    //_clickposition = Vector2.Zero;
                    //_releaseposition = Vector2.Zero;
                    _imageRender.Color = Color;
                }

                if (HasFocus && MouseService.IsMouseButtonReleased(MouseButton.LeftButton))
                {
                    HasFocus         = false;
                    _releaseposition = MouseService.Cursor.Position;

                    //Add delta to force.
                    _physics.AddForce((_clickposition - _releaseposition) / 2f);
                }
                else if (HasFocus && MouseService.IsMouseButtonDown(MouseButton.RightButton))
                {
                    Body.Position      -= new Vector2(MouseService.Delta.X, MouseService.Delta.Y);
                    Collision.Immovable = true;
                }
                else if (HasFocus && MouseService.IsMouseButtonUp(MouseButton.LeftButton) && MouseService.IsMouseButtonUp(MouseButton.RightButton))
                {
                    HasFocus            = false;
                    Collision.Immovable = _lastImmovable;
                }

                //ResetTimer our position if it goes off screen.
                if (Body.Right < 0)
                {
                    Body.X = EntityGame.Viewport.Width;
                }
                else if (Body.Left > EntityGame.Viewport.Width)
                {
                    Body.X = 0 - Body.Width;
                }

                if (Body.Bottom < 0)
                {
                    Body.Y = EntityGame.Viewport.Height;
                }
                else if (Body.Top > EntityGame.Viewport.Height)
                {
                    Body.Y = 0 - Body.Bounds.Y;
                }

                _textRender.Text = Name + Environment.NewLine +
                                   "X:" + Math.Round(Body.X, 2) + Environment.NewLine +
                                   "Y" + Math.Round(Body.Y, 2);
                _textBody.Position = Body.Position + Vector2.One * 3;
            }