AddDrawable() public method

Add the drawable to be displayed on the screen bounding the given rectangle.
public AddDrawable ( string target, Drawable visual, Rectangle rectangle ) : void
target string The target GUIElement for the action
visual Drawable The drawable to display
rectangle Microsoft.Xna.Framework.Rectangle The drawable should be stretched to be drawn at the rectangle
return void
コード例 #1
0
ファイル: GUIElementFactory.cs プロジェクト: nezbo/Descent
        /// <summary>
        /// Draws a visualization of a SurgeAbility on a target GUIElement. By using this method
        /// to draw the SurgeAbility, you're sure it's drawn the same way every time.
        /// </summary>
        /// <param name="target">The GUIElement to draw the SurgeAbility on.</param>
        /// <param name="ability">The SurgeAbility to display.</param>
        /// <param name="xPosition">The top-left x-coordinate to start drawing from.</param>
        /// <param name="yPosition">The top-left y-coordinate to start drawing from.</param>
        /// <param name="small">True if the surge ability should be drawn as compact as possible, else false.</param>
        public static void DrawSurgeAbility(GUIElement target, SurgeAbility ability, int xPosition, int yPosition, bool small)
        {
            Contract.Requires(target != null);
            Contract.Requires(ability != null);
            Contract.Requires(target.HasPoint(target.Bound.X + xPosition, target.Bound.Y + yPosition));

            // icons
            int cost = ability.Cost;
            int costX = target.Bound.X + xPosition;
            while (cost > 0)
            {
                Image img = new Image(target.Game.Content.Load<Texture2D>("Images/Other/surge"));
                target.AddDrawable(target.Name, img, new Vector2(costX, target.Bound.Y + yPosition));
                cost--;
                costX += img.Texture.Width + (small ? -5 : +2);
            }

            // text
            costX += 10;
            string s = ability.Ability.ToString();
            if (small) s = s.Replace("Damage", "Dmg");
            target.AddText(target.Name, ":" + s, new Vector2(costX - target.Bound.X, yPosition));
        }
コード例 #2
0
ファイル: GUIElementFactory.cs プロジェクト: nezbo/Descent
        /// <summary>
        /// Draws a given dice-type to the target GUIElement. By using this method
        /// to draw the EDice, you're sure it's drawn the same way every time.
        /// </summary>
        /// <param name="target">The GUIElement to display the dice in.</param>
        /// <param name="dice">The dice to display.</param>
        /// <param name="x">The top-left x-coordinate to start drawing from.</param>
        /// <param name="y">The top-left y-coordinate to start drawing from.</param>
        /// <param name="size">The width and height in pixels.</param>
        public static void DrawDice(GUIElement target, EDice dice, int x, int y, int size)
        {
            Contract.Requires(target != null);
            Contract.Requires(target.HasPoint(x, y));
            Contract.Requires(size > 0);
            Contract.Requires(x + size < target.Bound.X + target.Bound.Width);

            if (dicetinary == null) LoadDiceTextures(target.Game);

            target.AddDrawable(target.Name, new Image(dicetinary[dice]), new Rectangle(x, y, size, size));
        }