Exemplo n.º 1
0
        private void DrawStars(Stars stars, KeyboardCustom keyboard)
        {
            var t = (DateTimeOffset.UtcNow - Game.FsdJumpChange).TotalSeconds;

            stars.Clean();

            foreach (var star in stars)
            {
                var r = Math.Pow((DateTimeOffset.UtcNow - star.Birth).TotalMilliseconds / star.Lifespan.TotalMilliseconds, 2);

                var x = (int)Math.Round(_x0 + (star.VX * r * _xScale));
                var y = (int)Math.Round(_y0 + (star.Y * _yScale));

                if (x < 0 || x >= KeyboardConstants.MaxColumns)
                {
                    continue;
                }

                if (y < 0 || y >= KeyboardConstants.MaxRows)
                {
                    continue;
                }

                var c = keyboard[y, x].Combine(star.Color.Transform(r * 1, 1.5));

                if (Game.FsdJumpType == FsdJumpType.Hyperspace && t >= 4 && t <= 5)
                {
                    c = c.Combine(Color.White, t - 4);
                }

                keyboard[y, x] = c;
            }
        }