Exemplo n.º 1
0
        public ArenaUI(Game game)
            : base(game)
        {
            _components = new Dictionary<string, Component>();

            _input = new InputState();
            _prevScreenArea = new Rectangle();

            game.Components.Add(this);
        }
Exemplo n.º 2
0
        public override void Update(ArenaUI hud, GameTime dt, InputState input)
        {
            if (Parent == null || Text == null || Text.Equals(String.Empty))
                return;

            if (Parent.IsMouseOver)
            {
                _durationOfMouseOver += dt.ElapsedGameTime.Milliseconds;

                if(FlavorText != null && !FlavorText.Equals(String.Empty))
                    _durationOfFlavor += dt.ElapsedGameTime.Milliseconds;

                if (_durationOfMouseOver >= _mouseOverDelay)
                    Visible = true;

                if (_durationOfFlavor >= _mouseOverFlavorDelay)
                    _showFlavorText = true;
            }
            else
            {
                Visible = false;
                _durationOfMouseOver = 0;

                _showFlavorText = false;
                _durationOfFlavor = 0;
            }

            _mousePosition.X = input.CurrentMouseState.X;
            _mousePosition.Y = input.CurrentMouseState.Y;

            int width;
            int height;

            if (_showFlavorText)
            {
                width = Math.Max((int)Font.MeasureString(Text).X, (int)FlavorFont.MeasureString(FlavorText).X);
                width = Math.Max(100, width + FrameLeft + FrameRight + PaddingLeft + PaddingRight);

                height = Math.Max(15, (int)Font.MeasureString(Text).Y + (int)FlavorFont.MeasureString(FlavorText).Y + 4 + PaddingTop + PaddingBottom + FrameTop + FrameBottom);
            }
            else
            {
                width = Math.Max(100, (int)Font.MeasureString(Text).X + 20);
                height = Math.Max(15, (int)Font.MeasureString(Text).Y + PaddingTop + PaddingBottom + FrameTop + FrameBottom);
            }

            Position = new Rectangle((int)_mousePosition.X + 10, (int)_mousePosition.Y, width, height);
        }
Exemplo n.º 3
0
        public override void Update(ArenaUI hud, GameTime dt, InputState input)
        {
            if (!Visible)
                return;

            base.Update(hud, dt, input);

            // If the entities go out of range of one another close the conversation
            if (Vector2.Distance(Speaker.Pos, Audience.Pos) > 40)
                Visible = false;
        }
Exemplo n.º 4
0
        public virtual void Update(ArenaUI hud, GameTime dt, InputState input)
        {
            foreach (Component child in Children)
                child.Update(hud, dt, input);

            if (ToolTip != null && Enabled)
                ToolTip.Update(hud, dt, input);
        }