public ScreenManager(Game game, GraphicsDeviceManager graphicsDeviceManager, ContentManager content, Viewport viewport)
        {
            Game = game;
            GraphicsDeviceManager = graphicsDeviceManager;
            Content = content;
            Viewport = viewport;
            ScreenCentre = new Vector2(Viewport.Width * 0.5f, Viewport.Height * 0.5f);

            ActiveScreens = new List<Screen>();
            ScreensToAdd = new List<Screen>();
            ScreensToRemove = new List<Screen>();
            Camera = new Camera2D(this);
            Mouse = new InGameMouse(this);
            Input = new InputManager();
            Music = new MusicManager("Music");
            SoundEffects = new SoundEffectManager("Sounds");
        }
        public override void CheckMouseInteraction(InGameMouse mouse)
        {
            Point clickPoint = new Point((int)InGameMouse.InGamePosition.X, (int)InGameMouse.InGamePosition.Y);

            if (Texture != null)
            {
                if (AnimationBounds.Contains(clickPoint))
                {
                    Selected = true;
                }
                else
                {
                    Selected = false;
                }
            }
        }
        public override void CheckClicked(InGameMouse mouse)
        {
            base.CheckClicked(mouse);

            foreach (UIElement uielement in ActiveUIElements)
            {
                uielement.CheckClicked(mouse);

                /*if (uielement as Button != null)
                {
                    uielement.CheckClicked(mouse);
                }
                else if (uielement as Image != null)
                {
                    uielement.CheckClicked(mouse);
                }
                else
                {
                    uielement.CheckForInteraction(InGameMouse.ScreenPosition);
                }*/
            }
        }
        public override void CheckClicked(InGameMouse mouse)
        {
            // Mouse is over button
            if (Bounds.Contains((int)InGameMouse.ScreenPosition.X, (int)InGameMouse.ScreenPosition.Y))
            {
                if (HighlightedTexture != null)
                {
                    Texture = HighlightedTexture;
                }

                if (CanPlayHighlightedSound)
                {
                    ScreenManager.SoundEffects.Play(ButtonData.HighlightedSoundAsset);
                    CanPlayHighlightedSound = false;
                }

                CurrentColour = HighlightedColour;
                timeSinceHighlighted = 0;
            }
            else if (timeSinceHighlighted < ColourResetTime)
            {
                CanPlayHighlightedSound = true;
                CurrentColour = Color.Lerp(HighlightedColour, DefaultColour, timeSinceHighlighted / ColourResetTime);
            }
            else
            {
                CanPlayHighlightedSound = true;
            }

            base.CheckClicked(mouse);
        }
示例#5
0
        public override void CheckClicked(InGameMouse mouse)
        {
            Rectangle bounds = new Rectangle((int)(Position.X - TextOrigin.X), (int)(Position.Y - TextOrigin.Y), (int)(2 * TextOrigin.X), (int)(2 * TextOrigin.Y));

            if (HoverInfo != null)
            {
                if (IsActive())
                {
                    if (bounds.Contains(new Point((int)InGameMouse.ScreenPosition.X, (int)InGameMouse.ScreenPosition.Y)))
                    {
                        HoverInfo.Activate();
                    }
                    else
                    {
                        HoverInfo.DisableAndHide();
                    }
                }
            }

            if (mouse.IsLeftClicked && mouse.PreviousMouseState.LeftButton == ButtonState.Released && clickDelay > 0.3f)
            {
                CheckForInteraction(mouse.LastLeftClickedPosition);
            }
        }
        // Use for those that will be interacted with by the mouse
        public virtual void CheckClicked(InGameMouse mouse)
        {
            if (HoverInfo != null)
            {
                if (IsActive())
                {
                    if (Bounds.Contains(new Point((int)InGameMouse.ScreenPosition.X, (int)InGameMouse.ScreenPosition.Y)))
                    {
                        HoverInfo.Activate();
                    }
                    else
                    {
                        HoverInfo.DisableAndHide();
                    }
                }
            }

            if (mouse.IsLeftClicked && mouse.PreviousMouseState.LeftButton == ButtonState.Released && clickDelay > 0.3f)
            {
                CheckForInteraction(mouse.LastLeftClickedPosition);
            }
        }
        public virtual void CheckMouseInteraction(InGameMouse mouse)
        {
            if (IsAlive())
            {
                if (mouse.IsLeftClicked)
                {
                    Point clickPoint = new Point((int)mouse.LastLeftClickedPosition.X, (int)mouse.LastLeftClickedPosition.Y);

                    if (Bounds.Contains(clickPoint))
                    {
                        Select();
                    }
                    else
                    {
                        DeSelect();
                    }
                }
            }
        }