NativeUI.Sprite.Draw C# (CSharp) Method

Draw() public method

Draws the sprite on a 1080-pixels height base.
public Draw ( ) : void
return void
        public void Draw()
        {
            if (!Visible) return;
            if (!Function.Call<bool>(Hash.HAS_STREAMED_TEXTURE_DICT_LOADED, TextureDict))
                Function.Call(Hash.REQUEST_STREAMED_TEXTURE_DICT, TextureDict, true);

                int screenw = Game.ScreenResolution.Width;
            int screenh = Game.ScreenResolution.Height;
            const float height = 1080f;
            float ratio = (float)screenw/screenh;
            var width = height*ratio;

            float w = (Size.Width / width);
            float h = (Size.Height / height);
            float x = (Position.X / width) + w * 0.5f;
            float y = (Position.Y / height) + h * 0.5f;

            Function.Call(Hash.DRAW_SPRITE, TextureDict, TextureName, x, y, w, h, Heading, Color.R, Color.G, Color.B, Color.A);
        }

Usage Example

Example #1
0
File: GUI.cs Project: Guad/NOOSE
        public static void DrawHUD(Teammate[] mates, int seconds = -1)
        {
            string[] photos = new[]
            {
                "hc_n_gus",
                "hc_n_kar",
                "hc_n_edd",
                "hc_n_pac",
            };

            SizeF res = UIMenu.GetScreenResolutionMantainRatio();
            Point safe = UIMenu.GetSafezoneBounds();
            new Sprite("heisthud", "main_gradient", new Point(Convert.ToInt32(res.Width) - safe.X - 300, Convert.ToInt32(res.Height) - safe.Y - (seconds == -1 ? 370 : 470)), new Size(400, (seconds == -1 ? 300 : 400)), 90f, Color.White).Draw();
            for (int i = 0; i < mates.Length; i++)
            {
                new UIResRectangle(new Point(Convert.ToInt32(res.Width) - 100 - safe.X, Convert.ToInt32(res.Height) - 110 - safe.Y - 100 * i), new Size(100, 20), Color.FromArgb(200, 57, 98, 116)).Draw();
                if (mates[i].Character.IsAlive)
                    new UIResRectangle(new Point(Convert.ToInt32(res.Width) - 100 - safe.X, Convert.ToInt32(res.Height) - 110 - safe.Y - 100 * i), new Size(Convert.ToInt32((mates[i].Character.Armor / 200f) * 100), 20), Color.FromArgb(200, 75, 140, 172)).Draw();

                new UIResRectangle(new Point(Convert.ToInt32(res.Width) - 100 - safe.X, Convert.ToInt32(res.Height) - 140 - safe.Y - 100*i), new Size(100, 20), Color.FromArgb(200, 60, 103, 52)).Draw();
                if(mates[i].Character.IsAlive)
                    new UIResRectangle(new Point(Convert.ToInt32(res.Width) - 100 - safe.X, Convert.ToInt32(res.Height) - 140 - safe.Y - 100 * i), new Size(Convert.ToInt32((mates[i].Character.Health/200f)*100), 20), Color.FromArgb(200, 90, 155, 85)).Draw();

                var photoSprite = new Sprite("heisthud", photos[i], new Point(Convert.ToInt32(res.Width) - 180 - safe.X, Convert.ToInt32(res.Height) - 150 - safe.Y - 100*i), new Size(70, 70));
                photoSprite.Draw();
                if (mates[i].Character.IsDead)
                {
                    new Sprite("heisthud", "kiaoverlay", new Point(Convert.ToInt32(res.Width) - 180 - safe.X, Convert.ToInt32(res.Height) - 130 - safe.Y - 100*i),
                        new Size(70, 50)).Draw();
                }
            }
            if(seconds != -1)
                DrawBombTimer(seconds);
        }
All Usage Examples Of NativeUI.Sprite::Draw