private void AddRandomLaser() { var laser = new RadialAnimatedLaser( Center, 360 * (float)Random.NextDouble(), 1, SecondaryLaserColour, SecondaryLaserScale); laser.SetRadiusAnimator(SecondaryLaserRadiusFunction, false); Lasers.Add(laser); }
/// <summary> /// Add lasers according to the parameters specified by a spawn point. /// </summary> /// <param name="spawnPoint"></param> private void AddLasers(RadialLaserSpawnPoint spawnPoint) { var n = spawnPoint.Lasers; var angleMultiplier = spawnPoint.AngleMul; var angleDampener = spawnPoint.AngleDamp; var pulseRadius = spawnPoint.PulseRadius; var pulseTension = spawnPoint.PulseTension; var pulseRepeat = spawnPoint.SecondaryPulseTime; var pulseRecoil = spawnPoint.SecondaryPulseRecoil; var thickness = spawnPoint.Thickness; var colour = spawnPoint.Colour; var angleIncrement = 360f / n; for (int i = 0; i < n; i++) { var laser = new RadialAnimatedLaser(Center, angleIncrement * i, 1, colour, thickness); Func<int, float> animator = new LaserRadiusAnimationFunction( y1: pulseRadius, x2: LaserRadiusAnimationFunction.DEFAULT_X1 + pulseTension, x3: pulseRepeat, x4: pulseRepeat + pulseRecoil).Func; laser.SetRadiusAnimator(animator, false); laser.SetAngleAnimator(m => angleMultiplier * (float)SpecialFunctions.J0(m / angleDampener)); Lasers.Add(laser); } var count = Random.Next(80, 100); for (int i = 0; i < count; i++) { var velocity = (5f * (float)Random.NextDouble() + 1f) * VectorUtils.Polar(360 * Random.NextDouble()); var lifetime = Random.Next(40, 100); Particles.Add(new ClickParticle(Center, velocity, lifetime, colour)); } }