コード例 #1
0
 public virtual void Update()
 {
     if (Enabled)
     {
         if (Bounds.Contains(MouseReader.Position))
         {
             if (MouseReader.LeftClick())
             {
                 OnClick(new EventArgs());
             }
             else if (MouseReader.LeftPressed())
             {
                 _buttonState = ButtonState.Pressed;
             }
             else
             {
                 _buttonState = ButtonState.Hover;
             }
         }
         else
         {
             _buttonState = ButtonState.Normal;
         }
     }
 }
コード例 #2
0
        protected override void Update(GameTime gameTime)
        {
            if (nextWorld != null && World != nextWorld)
            {
                swapWorld();
            }

            IsInFocus = IsActive;

            InputManager.Update();
            RawKeyboardInput.Update();
            RawGamepadInput.Update();
            MouseReader.Update();

            Time.Set(gameTime);

            base.Update(gameTime);

            Console.Update();

            if (!Console.IsDisplaying && !PauseWorld)
            {
                UpdateGameplay();
            }

            Renderer.Update();
        }
コード例 #3
0
        public void Update()
        {
            if (MouseReader.LeftClick())
            {
                Point position = MouseReader.Position;

                if (Bounds.Contains(position))
                {
                    OnClick(new EventArgs());
                }
            }
        }
コード例 #4
0
        protected override void Initialize()
        {
            base.Initialize();

            MouseReader.Initialize();
            RawKeyboardInput.Initialize();
            RawGamepadInput.Initialize();
            GameSpeed.Reinitialize();
            GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp;
            DebugHelper.Initialize();

            MouseVisible = StartMouseVisible;

            InitializeGame();
        }
コード例 #5
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            if (IsActive)
            {
                KeyboardReader.Update();
                MouseReader.Update();
            }

            base.Update(gameTime);
        }
        public void Update(GameTime gameTime, GameStateManager gameStateManager)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape) || escToggle)
            {
                escToggle = true;
                if (Keyboard.GetState().IsKeyUp(Keys.Escape))
                {
                    gameStateManager.SetState(GameStateManager.States.Playing);
                    escToggle = false;
                }
            }

            MouseReader.Update(gameTime);
            menu.Update(gameTime);
        }
 public void Update(GameTime gameTime, GameStateManager gameStateManager)
 {
     if (Keyboard.GetState().IsKeyDown(Keys.Escape) || escToggle)
     {
         escToggle = true;
         if (Keyboard.GetState().IsKeyUp(Keys.Escape))
         {
             gameStateManager.SetState(GameStateManager.States.Paused);
             escToggle = false;
         }
     }
     hero.Update(gameTime);
     level.Update(gameTime);
     hud.Update(gameTime);
     camera.MoveTo(-hero.Position.X);
     viewMatrix = camera.GetTransform();
     MouseReader.Update(gameTime);
 }
コード例 #8
0
        public void Update(GameTime gameTime)
        {
            if (Enabled)
            {
                _snowyBackground.Update(gameTime);

                UpdateCamera();

                if (DndItem != null)
                {
                    Vector2 mousePosition = MouseReader.Position.ToVector2();

                    if (Bounds.Contains(mousePosition))
                    {
                        FindSnapPosition(mousePosition);
                        UpdateDndLayer();
                        UpdateRectangleDrawer(mousePosition);

                        if (MouseReader.LeftClick())
                        {
                            GameObject gameObject = (GameObject)DndItem.Clone();
                            gameObject.Position = Camera.ScreenToWorld(_snapPosition.GetValueOrDefault(mousePosition));
                            Items.Add(gameObject);
                        }

                        if (MouseReader.RightClick())
                        {
                            for (int i = Items.Count - 1; i >= 0; --i)
                            {
                                if (Items[i].Bounds.Contains(Camera.ScreenToWorld(mousePosition)))
                                {
                                    Items.RemoveAt(i);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }