Пример #1
0
        private void UserControlls()
        {
            // Reset the color of the object that was being hovered over
            if (_mouseIsOver != null)
            {
                _mouseIsOver.Sprite.Color = Color.White;
            }

            // Get the object the mouse is hovering.
            _mouseIsOver = _hotel.GetObject(_camera.ScreenToWorld(Input.Instance.GetMousePos()));

            if (_wasSelected != null)
            {
                _closeUpCamera.CamPosition = new Vector2(-_wasSelected.Position.X - _wasSelected.Sprite.DrawDestination.Width / 2, _wasSelected.Position.Y - _wasSelected.Sprite.DrawDestination.Height / 2);
            }

            // If a mouseover object is found
            if (_mouseIsOver != null)
            {
                // Highlight the sprite.
                _mouseIsOver.Sprite.Color = Color.LightGreen;

                // When the left mouse is clicked
                if (Input.Instance.OnLeftMouseButtonRelease())
                {
                    if (_mouseIsOver is Lobby)
                    {
                        Paused = !Paused;
                        HotelEventManager.Pauze();
                    }

                    // Check if the information window is already showing some data.
                    if (!_informationWindow.IsShowingInfo)
                    {
                        // Set the object as selected and show its information
                        _wasSelected = _mouseIsOver;
                        _informationWindow.ShowInformation(_mouseIsOver);
                    }
                    else
                    {
                        // Hide the information window
                        if (_wasSelected.Equals(_mouseIsOver))
                        {
                            _informationWindow.HideInformation();
                        }
                        else
                        {
                            // Update the information window
                            _wasSelected = _mouseIsOver;
                            _informationWindow.HideInformation();
                            _informationWindow.ShowInformation(_mouseIsOver);
                        }
                    }
                }
            }
            else
            {
                // Hide the information window
                if (Input.Instance.OnLeftMouseButtonRelease())
                {
                    _informationWindow.HideInformation();
                }
            }
        }