DrawSprite() публичный Метод

public DrawSprite ( Sprite s, Vertex sourceVertices, int offset ) : void
s Sprite
sourceVertices Vertex
offset int
Результат void
Пример #1
0
        public void DrawSprite(Sprite s, float3 location, float3 size)
        {
            if (s.Channel != TextureChannel.RGBA)
            {
                throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
            }

            parent.DrawSprite(s, location, 0, size);
        }
Пример #2
0
        public void DrawText(SpriteRenderer r, string text, float2 location, Color c)
        {
            location.Y += size;	// baseline vs top

            var p = location;
            foreach (var s in text)
            {
                if (s == '\n')
                {
                    location.Y += size;
                    p = location;
                    continue;
                }

                var g = glyphs[s];
                r.DrawSprite(g.Sprite,
                    new float2(
                        (int)Math.Round(p.X + g.Offset.X, 0),
                        p.Y + g.Offset.Y),
                    "chrome");
                p.X += g.Advance;
            }

            r.Flush();
        }
Пример #3
0
        public void DrawSprite(Sprite s, float3 a, float3 b, float3 c, float3 d)
        {
            if (s.Channel != TextureChannel.RGBA)
            {
                throw new InvalidOperationException("DrawRGBASprite requires a RGBA sprite.");
            }

            parent.DrawSprite(s, a, b, c, d);
        }
Пример #4
0
        internal void Draw(SpriteRenderer r)
        {
            if (dirty)
            {
                dirty = false;
                for (int j = map.YOffset; j < map.YOffset + map.Height; j++)
                    for (int i = map.XOffset; i < map.XOffset + map.Width; i++)
                        sprites[i, j] = ChooseShroud(i, j);
                for (int j = map.YOffset; j < map.YOffset + map.Height; j++)
                    for (int i = map.XOffset; i < map.XOffset + map.Width; i++)
                        fogSprites[i, j] = ChooseFog(i, j);
            }

            var miny = bounds.HasValue ? Math.Max(map.YOffset, bounds.Value.Top) : map.YOffset;
            var maxy = bounds.HasValue ? Math.Min(map.YOffset + map.Height, bounds.Value.Bottom) : map.YOffset + map.Height;

            var minx = bounds.HasValue ? Math.Max(map.XOffset, bounds.Value.Left) : map.XOffset;
            var maxx = bounds.HasValue ? Math.Min(map.XOffset + map.Width, bounds.Value.Right) : map.XOffset + map.Width;

            var shroudPalette = "fog";

            for (var j = miny; j < maxy; j++)
            {
                var starti = minx;
                for (var i = minx; i < maxx; i++)
                {
                    if (fogSprites[i, j] == shadowBits[0x0f])
                        continue;

                    if (starti != i)
                    {
                        r.DrawSprite(fogSprites[starti, j],
                            Game.CellSize * new float2(starti, j),
                            shroudPalette,
                            new float2(Game.CellSize * (i - starti), Game.CellSize));
                        starti = i+1;
                    }

                    r.DrawSprite(fogSprites[i, j],
                        Game.CellSize * new float2(i, j),
                        shroudPalette);
                    starti = i+1;
                }

                if (starti < maxx)
                    r.DrawSprite(fogSprites[starti, j],
                        Game.CellSize * new float2(starti, j),
                        shroudPalette,
                        new float2(Game.CellSize * (maxx - starti), Game.CellSize));
            }

            shroudPalette = "shroud";

            for (var j = miny; j < maxy; j++)
            {
                var starti = minx;
                for (var i = minx; i < maxx; i++)
                {
                    if (sprites[i, j] == shadowBits[0x0f])
                        continue;

                    if (starti != i)
                    {
                        r.DrawSprite(sprites[starti, j],
                            Game.CellSize * new float2(starti, j),
                            shroudPalette,
                            new float2(Game.CellSize * (i - starti), Game.CellSize));
                        starti = i + 1;
                    }

                    r.DrawSprite(sprites[i, j],
                        Game.CellSize * new float2(i, j),
                        shroudPalette);
                    starti = i + 1;
                }

                if (starti < maxx)
                    r.DrawSprite(sprites[starti, j],
                        Game.CellSize * new float2(starti, j),
                        shroudPalette,
                        new float2(Game.CellSize * (maxx - starti), Game.CellSize));
            }
        }