using System;
using System.Collections.Generic;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace GladiatorIdle.Arena
{
internal enum PKind { Spark, Dust, Mote, Ring, Chip }
///
_list = new(2048);
readonly Random _rng = new();
public bool Calm;
float R(float a, float b) => a + (float)_rng.NextDouble() * (b - a);
public void Sparks(Vector2 at, int n, Color c, float dir = 0, float spread = MathF.PI, float speed = 900)
{
if (Calm) n /= 3;
for (int i = 0; i < n; i++)
{
float a = dir + R(-spread, spread), v = R(0.3f, 1f) * speed;
_list.Add(new P { Kind = PKind.Spark, Pos = at, Vel = new Vector2(MathF.Cos(a), MathF.Sin(a)) * v - new Vector2(0, R(100, 300)),
Life = R(0.18f, 0.45f), Size = R(2.5f, 5f), Gravity = 1600, Drag = 2.5f, Color = c });
}
}
public void Dust(Vector2 at, int n, float spread = 60, float rise = 60, float size = 60)
{
if (Calm) n /= 2;
for (int i = 0; i < n; i++)
_list.Add(new P { Kind = PKind.Dust, Pos = at + new Vector2(R(-spread, spread), R(-8, 4)),
Vel = new Vector2(R(-120, 120), -R(10, rise)), Life = R(0.5f, 1.1f), Size = R(0.6f, 1f) * size,
Grow = size * 1.2f, Drag = 2.2f, Color = new Color(150, 120, 85) * 0.55f });
}
public void Chips(Vector2 at, int n, Color c, int facing)
{
if (Calm) n /= 2;
for (int i = 0; i < n; i++)
_list.Add(new P { Kind = PKind.Chip, Pos = at, Vel = new Vector2(facing * R(150, 650), -R(250, 750)), Life = R(0.5f, 0.9f),
Size = R(4, 9), Gravity = 2000, Drag = 0.6f, Rot = R(0, 6), Spin = R(-20, 20), Color = c });
}
public void Ring(Vector2 at, Color c, float size = 420, float life = 0.35f) =>
_list.Add(new P { Kind = PKind.Ring, Pos = at, Life = life, Size = 40, Grow = size / life, Color = c });
/// Schwebstaub im Licht: langsam, flackernd; hält die Anzahl um