コード例 #1
0
        /// <summary>
        /// Makes the object draw itself.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> the object can use to draw itself with.</param>
        public void Draw(ISpriteBatch sb)
        {
            if (BeforeDraw != null)
            {
                BeforeDraw.Raise(this, EventArgsHelper.Create(sb));
            }

            var drawPos = DrawPosition;

            _lastScreenPosition = drawPos - Parent.Camera.Min;

            if (IsVisible)
            {
                // Draw the character body
                _characterSprite.Draw(sb, drawPos, Heading, Color);

                // Draw the HP/MP
                DrawSPBar(sb, HPPercent, 0, new Color(255, 0, 0, 175));
                DrawSPBar(sb, MPPercent, 1, new Color(0, 0, 255, 175));

                // Draw the name
                DrawName(sb, NameFont);
            }

            if (AfterDraw != null)
            {
                AfterDraw.Raise(this, EventArgsHelper.Create(sb));
            }
        }
コード例 #2
0
ファイル: MirControl.cs プロジェクト: coolzoom/mir2-master
 protected virtual void BeforeDrawControl()
 {
     if (BeforeDraw != null)
     {
         BeforeDraw.Invoke(this, EventArgs.Empty);
     }
 }
コード例 #3
0
        /// <summary>
        /// Makes the object draw itself.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> the object can use to draw itself with.</param>
        public void Draw(ISpriteBatch sb)
        {
            // Ensure the sprite is set
            if (!IsSpriteSet())
            {
                return;
            }

            // Pre-drawing
            if (BeforeDraw != null)
            {
                BeforeDraw.Raise(this, EventArgsHelper.Create(sb));
            }

            // Draw
            if (IsVisible)
            {
                HandleDraw(sb);
            }

            // Post-drawing
            if (AfterDraw != null)
            {
                AfterDraw.Raise(this, EventArgsHelper.Create(sb));
            }
        }
コード例 #4
0
ファイル: ItemEntity.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Draws the ItemEntity.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> to draw to.</param>
        /// <param name="pos">Position to draw at.</param>
        /// <param name="color">The color to draw the item.</param>
        /// <exception cref="ArgumentNullException"><paramref name="sb" /> is <c>null</c>.</exception>
        public void Draw(ISpriteBatch sb, Vector2 pos, Color color)
        {
            if (sb == null)
            {
                throw new ArgumentNullException("sb");
            }

            if (BeforeDraw != null)
            {
                BeforeDraw.Raise(this, EventArgsHelper.Create(sb));
            }

            if (IsVisible)
            {
                if (_grh != null)
                {
                    _grh.Draw(sb, pos, color);
                }
            }

            if (AfterDraw != null)
            {
                AfterDraw.Raise(this, EventArgsHelper.Create(sb));
            }
        }
コード例 #5
0
        /// <summary>
        /// Performs the drawning of current entities and components
        /// </summary>
        /// <param name="gameTime"></param>
        public void Draw(GameTime gameTime)
        {
            IsDrawing = true;

            BeforeDraw?.Invoke();

            foreach (EntityNode entityNode in Tree.ChildNodes)
            {
                DrawNode(entityNode, gameTime);
            }

            AfterDraw?.Invoke();

            IsDrawing = false;
        }
コード例 #6
0
ファイル: MapGrh.cs プロジェクト: thepirateclub/netgore
        /// <summary>
        /// Makes the object draw itself.
        /// </summary>
        /// <param name="sb"><see cref="ISpriteBatch"/> the object can use to draw itself with.</param>
        public void Draw(ISpriteBatch sb)
        {
            if (BeforeDraw != null)
            {
                BeforeDraw.Raise(this, EventArgsHelper.Create(sb));
            }

            if (IsVisible)
            {
                HandleDrawing(sb);
            }

            if (AfterDraw != null)
            {
                AfterDraw.Raise(this, EventArgsHelper.Create(sb));
            }
        }
コード例 #7
0
 /// <summary>
 /// Called to notify listeners that drawing is about to start.
 /// </summary>
 /// <param name="time"></param>
 protected virtual void OnBeforeDraw(GameTime time)
 {
     BeforeDraw?.Invoke(this, time);
 }
コード例 #8
0
 private void OnBeforeDraw()
 {
     BeforeDraw?.Invoke(this, EventArgs.Empty);
 }
コード例 #9
0
ファイル: Dropdown.cs プロジェクト: rockdj1983/GeonBit.UI
        /// <summary>
        /// Create the DropDown list.
        /// </summary>
        /// <param name="size">List size (refers to the whole size of the list + the header when dropdown list is opened).</param>
        /// <param name="anchor">Position anchor.</param>
        /// <param name="offset">Offset from anchor position.</param>
        /// <param name="skin">Panel skin to use for this DropDown list and header.</param>
        public DropDown(Vector2 size, Anchor anchor = Anchor.Auto, Vector2?offset = null, PanelSkin skin = PanelSkin.ListBackground) :
            base(size, anchor, offset)
        {
            // default padding of self is 0
            Padding = Vector2.Zero;

            // to get collision right when list is opened
            UseActualSizeForCollision = true;

            // create the panel and paragraph used to show currently selected value (what's shown when drop-down is closed)
            _selectedTextPanel     = new Panel(new Vector2(0, SelectedPanelHeight), skin, Anchor.TopLeft);
            _selectedTextParagraph = UserInterface.DefaultParagraph(string.Empty, Anchor.CenterLeft);
            _selectedTextParagraph.UseActualSizeForCollision = false;
            _selectedTextParagraph.UpdateStyle(SelectList.DefaultParagraphStyle);
            _selectedTextParagraph.UpdateStyle(DefaultParagraphStyle);
            _selectedTextParagraph.UpdateStyle(DefaultSelectedParagraphStyle);
            _selectedTextPanel.AddChild(_selectedTextParagraph, true);

            // create the arrow down icon
            _arrowDownImage = new Image(Resources.ArrowDown, new Vector2(ArrowSize, ArrowSize), ImageDrawMode.Stretch, Anchor.CenterRight, new Vector2(-10, 0));
            _selectedTextPanel.AddChild(_arrowDownImage, true);

            // create the list component
            _selectList = new SelectList(size, Anchor.TopCenter, Vector2.Zero, skin);

            // update list offset and space before
            _selectList.SetOffset(new Vector2(0, SelectedPanelHeight));
            _selectList.SpaceBefore = Vector2.Zero;

            // add the header and select list as children
            AddChild(_selectedTextPanel);
            AddChild(_selectList);

            // add callback on list value change
            _selectList.OnValueChange = (Entity entity) =>
            {
                // hide list
                ListVisible = false;

                // set selected text
                _selectedTextParagraph.Text = (SelectedValue ?? DefaultText);
            };

            // hide the list by default
            _selectList.Visible = false;

            // setup the callback to show / hide the list when clicking the dropbox
            _selectedTextPanel.OnClick = (Entity self) =>
            {
                // change visibility
                ListVisible = !ListVisible;
            };

            // set starting text
            _selectedTextParagraph.Text = (SelectedValue ?? DefaultText);

            // update styles
            _selectList.UpdateStyle(DefaultStyle);

            // make the list events trigger the dropdown events
            _selectList.OnListChange       += (Entity entity) => { OnListChange?.Invoke(this); };
            _selectList.OnMouseDown        += (Entity entity) => { OnMouseDown?.Invoke(this); };
            _selectList.OnMouseReleased    += (Entity entity) => { OnMouseReleased?.Invoke(this); };
            _selectList.WhileMouseDown     += (Entity entity) => { WhileMouseDown?.Invoke(this); };
            _selectList.WhileMouseHover    += (Entity entity) => { WhileMouseHover?.Invoke(this); };
            _selectList.OnClick            += (Entity entity) => { OnClick?.Invoke(this); };
            _selectList.OnValueChange      += (Entity entity) => { OnValueChange?.Invoke(this); };
            _selectList.OnMouseEnter       += (Entity entity) => { OnMouseEnter?.Invoke(this); };
            _selectList.OnMouseLeave       += (Entity entity) => { OnMouseLeave?.Invoke(this); };
            _selectList.OnMouseWheelScroll += (Entity entity) => { OnMouseWheelScroll?.Invoke(this); };
            _selectList.OnStartDrag        += (Entity entity) => { OnStartDrag?.Invoke(this); };
            _selectList.OnStopDrag         += (Entity entity) => { OnStopDrag?.Invoke(this); };
            _selectList.WhileDragging      += (Entity entity) => { WhileDragging?.Invoke(this); };
            _selectList.BeforeDraw         += (Entity entity) => { BeforeDraw?.Invoke(this); };
            _selectList.AfterDraw          += (Entity entity) => { AfterDraw?.Invoke(this); };
            _selectList.BeforeUpdate       += (Entity entity) => { BeforeUpdate?.Invoke(this); };
            _selectList.AfterUpdate        += (Entity entity) => { AfterUpdate?.Invoke(this); };

            // make the selected value panel trigger the dropdown events
            _selectedTextPanel.OnMouseDown        += (Entity entity) => { OnMouseDown?.Invoke(this); };
            _selectedTextPanel.OnMouseReleased    += (Entity entity) => { OnMouseReleased?.Invoke(this); };
            _selectedTextPanel.WhileMouseDown     += (Entity entity) => { WhileMouseDown?.Invoke(this); };
            _selectedTextPanel.WhileMouseHover    += (Entity entity) => { WhileMouseHover?.Invoke(this); };
            _selectedTextPanel.OnClick            += (Entity entity) => { OnClick?.Invoke(this); };
            _selectedTextPanel.OnValueChange      += (Entity entity) => { OnValueChange?.Invoke(this); };
            _selectedTextPanel.OnMouseEnter       += (Entity entity) => { OnMouseEnter?.Invoke(this); };
            _selectedTextPanel.OnMouseLeave       += (Entity entity) => { OnMouseLeave?.Invoke(this); };
            _selectedTextPanel.OnMouseWheelScroll += (Entity entity) => { OnMouseWheelScroll?.Invoke(this); };
            _selectedTextPanel.OnStartDrag        += (Entity entity) => { OnStartDrag?.Invoke(this); };
            _selectedTextPanel.OnStopDrag         += (Entity entity) => { OnStopDrag?.Invoke(this); };
            _selectedTextPanel.WhileDragging      += (Entity entity) => { WhileDragging?.Invoke(this); };
            _selectedTextPanel.BeforeDraw         += (Entity entity) => { BeforeDraw?.Invoke(this); };
            _selectedTextPanel.AfterDraw          += (Entity entity) => { AfterDraw?.Invoke(this); };
            _selectedTextPanel.BeforeUpdate       += (Entity entity) => { BeforeUpdate?.Invoke(this); };
            _selectedTextPanel.AfterUpdate        += (Entity entity) => { AfterUpdate?.Invoke(this); };
        }