Example #1
0
        public void Update(GameTime gameTime, Rectangle playerRect)
        {
            Text intersecting = GetIntersecting(playerRect);

            if (intersecting == null || (_activeText != null && !_activeText.Intersects(playerRect)))
                foreach (var text in _texts.Where(t => t.Active))
                    text.Disable();
            else
                foreach (var text in _texts.Where(t => t.Active && !t.Intersects(playerRect)))
                    text.Disable();

            intersecting = null;

            foreach (var text in GetAllIntersecting(playerRect))
            {
                // We want to get the first intersecting text object that the player has not already been inside
                if (!text.Active)
                {
                    text.Enable();
                    intersecting = text;
                }
            }

            var active = GetActive();
            if (intersecting != null)
            {
                _activeText = intersecting;
                if (active == null || !active.EqualText(intersecting))
                {
                    _activeText.Hide();
                    _activeText.FadeIn();
                }
                else
                {
                    _activeText.Show();
                }
            }

            active = GetActive();

            if (active != null)
                active.Update(gameTime);
        }