Пример #1
0
        public override void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            if (Finished)
            {
                return;
            }

            DirSheet sheet = GraphicsManager.GetBackground(Anim.AnimIndex);

            int   frame = Time.ToFrames();
            Loc   diff  = Movement * frame / 60 - offset;
            float fade  = 1f;// (float)Math.Min(Math.Min(FadeTime, frame), (TotalTime > 0) ? Math.Min(FadeTime, TotalTime - frame) : FadeTime) / FadeTime;

            if (sheet.Width == 1 && sheet.Height == 1)
            {
                sheet.DrawTile(spriteBatch, new Rectangle(0, 0, GraphicsManager.ScreenWidth, GraphicsManager.ScreenHeight), 0, 0, Color * ((float)Anim.Alpha * fade / 255f));
            }
            else
            {
                for (int x = diff.X % sheet.TileWidth - sheet.TileWidth; x < GraphicsManager.ScreenWidth; x += sheet.TileWidth)
                {
                    for (int y = diff.Y % sheet.TileHeight - sheet.TileHeight; y < GraphicsManager.ScreenHeight; y += sheet.TileHeight)
                    {
                        sheet.DrawDir(spriteBatch, new Vector2(x, y), Anim.GetCurrentFrame(Time, sheet.TotalFrames), Anim.AnimDir, Color * ((float)Anim.Alpha * fade / 255f));
                    }
                }
            }
        }
Пример #2
0
        public override void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            if (Finished)
            {
                return;
            }

            DirSheet sheet = GraphicsManager.GetBackground(Anim.AnimIndex);

            int   frame = Time.ToFrames();
            Color color = StartColor;

            if (frame < FadeInTime)
            {
                color = interpolateColor(StartColor, EndColor, frame, FadeInTime);
            }
            else if (frame < FadeInTime + HoldTime)
            {
                color = EndColor;
            }
            else if (frame < FadeInTime + HoldTime + FadeOutTime)
            {
                int endTime = FadeInTime + HoldTime + FadeOutTime;
                color = interpolateColor(StartColor, EndColor, endTime - frame, FadeOutTime);
            }

            Loc diff = -offset;

            if (sheet.Width == 1 && sheet.Height == 1)
            {
                sheet.DrawTile(spriteBatch, new Rectangle(0, 0, GraphicsManager.ScreenWidth, GraphicsManager.ScreenHeight), 0, 0, color);
            }
            else
            {
                for (int x = diff.X % sheet.TileWidth - sheet.TileWidth; x < GraphicsManager.ScreenWidth; x += sheet.TileWidth)
                {
                    for (int y = diff.Y % sheet.TileHeight - sheet.TileHeight; y < GraphicsManager.ScreenHeight; y += sheet.TileHeight)
                    {
                        sheet.DrawDir(spriteBatch, new Vector2(x, y), Anim.GetCurrentFrame(Time, sheet.TotalFrames), Anim.GetDrawDir(Dir8.None), color);
                    }
                }
            }
        }