Journey encounters and 360 camera, Ludus training ground, offline gold fix, new music, settings layout, grounded KO, thraex shield, arena name chant

Stand von main 9c35eff2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-10 10:47:49 +01:00
parent 0454683fc3
commit c516679674
26 changed files with 856 additions and 151 deletions

1
.gitignore vendored
View File

@@ -17,3 +17,4 @@ _Archiv/3D-Erstversuch/
# Stimmen fuer Ansager/Sprechchor (tools/get_voices.py, ca. 240 MB)
Assets/Voices/
_Archiv/Musik-Vorlagen/

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -60,7 +60,7 @@ namespace GladiatorIdle
string lang = LangCode;
if (name.Length == 0) return;
lock (_lock) { if (_name == name && _lang == lang) return; _name = name; _lang = lang; }
string enter = string.Format(L.t("announce.enter"), name), win = string.Format(L.t("announce.win"), name);
string win = string.Format(L.t("announce.win"), name);
var oathLines = string.Format(L.t("oath.text"), name).Split('|', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries);
lock (_lock) { OathLines = oathLines; OathTimes = Array.Empty<float>(); }
// eigener Faden mit niedriger Priorität: das Spiel läuft flüssig weiter
@@ -73,13 +73,13 @@ namespace GladiatorIdle
var (oath, times) = LoadOath(lang, name, oathLines);
if (oath == null) (oath, times) = MakeOath(lang, oathLines);
if (oath != null) lock (_lock) { _ready[(name, lang, Kind.Oath)] = oath; OathTimes = times; }
foreach (var (kind, text) in new[] { (Kind.Name, name + "!"), (Kind.Enter, enter), (Kind.Win, win) })
foreach (var (kind, text) in new[] { (Kind.Name, name + "!"), (Kind.Win, win) })
{
var pcm = Cached(lang, kind, text) ?? Make(lang, kind, text);
if (pcm == null) return;
lock (_lock) _ready[(name, lang, kind)] = pcm;
}
var chant = Cached(lang, Kind.Chant, name) ?? MakeChant(lang, name);
var chant = Cached(lang, Kind.Chant, name + "|v3") ?? MakeChant(lang, name);
if (chant != null) lock (_lock) _ready[(name, lang, Kind.Chant)] = chant;
if (DevShot.Active) DevShot.Log($"namevoice: '{name}' ({lang}) ready in {sw.ElapsedMilliseconds} ms");
}
@@ -269,61 +269,96 @@ namespace GladiatorIdle
return null;
}
/// Sprechchor: viele Stimmen rufen den Namen dreimal im Takt, dazu Klatschen und Hall.
/// Sprechchor wie in einer vollen Arena: Dutzende Stimmen (tief und hoch, nah und fern) rufen den
/// Namen viermal im Takt, jeder Ruf auf Trommel und Stampfen, der letzte am lautesten; dazu ein
/// Grundrauschen der Menge, das anschwillt, Jubel am Ende und weiter Hall.
static float[]? MakeChant(string lang, string name)
{
var shout = Speak(lang, name + "!", 0.9f);
if (shout == null) return null;
shout = Trim(shout);
// drei Rufe in verschiedenem Tempo, einer davon rau – damit die Menge nicht wie ein Echo klingt
var takes = new List<float[]>();
foreach (float sp in new[] { 0.82f, 0.92f, 1.04f })
if (Speak(lang, name + "!", sp) is float[] t) takes.Add(Trim(t));
if (takes.Count == 0) return null;
takes.Add(Grit(takes[0]));
var rng = new Random(name.GetHashCode());
int beat = shout.Length + (int)(0.45 * RATE);
int total = beat * 3 + (int)(1.4 * RATE);
int callLen = 0; foreach (var t in takes) callLen = Math.Max(callLen, t.Length);
int beat = Math.Max(callLen + (int)(0.32 * RATE), (int)(0.95 * RATE));
const int CALLS = 4;
int lead = (int)(0.5 * RATE);
int total = lead + beat * CALLS + (int)(3.2 * RATE);
var l = new float[total]; var r = new float[total];
const int VOICES = 14;
void Add(float[] src, int start, float g, float pan)
{
for (int i = 0; i < src.Length && start + i < total; i++)
if (start + i >= 0) { l[start + i] += src[i] * g * (1 - pan); r[start + i] += src[i] * g * pan; }
}
// Stimmen: 56, Tonhöhe −6 … +5 Halbtöne, fern = dumpfer, leiser, später
const int VOICES = 56;
for (int v = 0; v < VOICES; v++)
{
double semi = v == 0 ? 0 : -2 + 5 * rng.NextDouble(); // Stimme 0: klare Vorsängerin
var voice = Resample(shout, RATE, (int)(RATE * Math.Pow(2, -semi / 12))); // Tonhöhe
if (v > 0) voice = LowPass(voice, 0.35f + 0.4f * (float)rng.NextDouble());
float g = v == 0 ? 3.2f : 0.4f + 0.4f * (float)rng.NextDouble(), pan = v == 0 ? 0.5f : (float)rng.NextDouble();
for (int rep = 0; rep < 3; rep++)
var src = takes[rng.Next(takes.Count)];
double semi = -6 + 11 * rng.NextDouble();
if (v < 10) semi = -6 + 3 * rng.NextDouble(); // ein Kern tiefer Männerstimmen trägt den Ruf
var voice = Resample(src, RATE, (int)(RATE * Math.Pow(2, -semi / 12)));
float far = (float)rng.NextDouble();
voice = LowPass(voice, 0.55f - 0.4f * far);
float g = (0.55f - 0.3f * far) * (v < 10 ? 1.4f : 1f), pan = 0.1f + 0.8f * (float)rng.NextDouble();
for (int c = 0; c < CALLS; c++)
{
int start = rep * beat + (v == 0 ? 0 : (int)(rng.NextDouble() * 0.05 * RATE));
float lg = g * (rep == 2 ? 1.15f : 1f); // der dritte Ruf am lautesten
for (int i = 0; i < voice.Length && start + i < total; i++)
int start = lead + c * beat + (int)((0.01 + 0.07 * far + 0.03 * rng.NextDouble()) * RATE);
Add(voice, start, g * (0.8f + 0.12f * c) * (0.85f + 0.3f * (float)rng.NextDouble()), pan);
}
}
// Trommel (tiefer Schlag) auf jeden Ruf, Stampfen der Ränge dazwischen
float[] Drum(float freq, float decay, float noise)
{
l[start + i] += voice[i] * lg * (1 - pan);
r[start + i] += voice[i] * lg * pan;
}
}
}
// Klatschen: kurze Rauschstöße auf die Silben des Namens (Anfang und Mitte) und am Ende
for (int rep = 0; rep < 3; rep++)
foreach (double at in new[] { 0.0, 0.5, 1.0 })
var d = new float[(int)(0.5 * RATE)];
for (int i = 0; i < d.Length; i++)
{
int c0 = rep * beat + (int)(at * shout.Length);
for (int k = 0; k < 14; k++)
float t = i / (float)RATE, env = MathF.Exp(-t / decay);
float f = freq * (1 + 1.5f * MathF.Exp(-t / 0.02f)); // Anschlag fällt in der Tonhöhe
d[i] = (MathF.Sin(MathF.Tau * f * t) + ((float)rng.NextDouble() * 2 - 1) * noise * MathF.Exp(-t / 0.015f)) * env;
}
return d;
}
var drum = Drum(52, 0.22f, 0.5f);
var stomp = LowPass(Drum(80, 0.09f, 1f), 0.3f);
for (int c = 0; c < CALLS; c++)
{
int s0 = c0 + (int)(rng.NextDouble() * 0.06 * RATE);
float cg = 0.12f + 0.12f * (float)rng.NextDouble(), cp = (float)rng.NextDouble();
for (int i = 0; i < 0.03 * RATE && s0 + i < total; i++)
{
float env = MathF.Exp(-i / (0.006f * RATE));
float n = ((float)rng.NextDouble() * 2 - 1) * env * cg;
l[s0 + i] += n * (1 - cp); r[s0 + i] += n * cp;
int at = lead + c * beat;
Add(drum, at - (int)(0.02 * RATE), 1.6f + 0.3f * c, 0.5f);
for (int k = 0; k < 24; k++) // viele Füße, leicht verstreut
Add(stomp, at + beat / 2 + (int)(rng.NextDouble() * 0.05 * RATE), 0.12f, (float)rng.NextDouble());
}
}
}
l = Reverb(l, 0.3f, 0.55f); r = Reverb(r, 0.3f, 0.57f);
var st = new float[total * 2];
float peak = 1e-4f;
for (int i = 0; i < total; i++) peak = MathF.Max(peak, MathF.Max(MathF.Abs(l[i]), MathF.Abs(r[i])));
// Menge: Rauschen, dumpf, schwillt mit jedem Ruf an und bricht am Ende in Jubel aus
float s1 = 0, s2 = 0;
int roarAt = lead + beat * CALLS - beat / 3;
for (int i = 0; i < total; i++)
{
float fade = i > total - RATE ? (total - i) / (float)RATE : 1;
st[i * 2] = l[i] / peak * 0.85f * fade; st[i * 2 + 1] = r[i] / peak * 0.85f * fade;
float t = i / (float)RATE;
float n = (float)rng.NextDouble() * 2 - 1;
s1 += (n - s1) * 0.08f; s2 += (s1 - s2) * 0.3f;
float swell = 0.10f + 0.05f * Math.Min(i, roarAt) / (float)roarAt;
if (i > roarAt) swell += 0.55f * (1 - MathF.Exp(-(i - roarAt) / (0.25f * RATE))) * MathF.Exp(-(i - roarAt) / (2.2f * RATE));
float fade = i < lead ? i / (float)lead : i > total - RATE ? (total - i) / (float)RATE : 1;
float wob = 1 + 0.25f * MathF.Sin(t * 7.3f + (i & 1)) ;
l[i] += s2 * swell * fade * wob * 2.2f;
r[i] += s2 * swell * fade * (2 - wob) * 2.2f;
}
Save(lang, Kind.Chant, name, st);
// weite Arena: zwei Hallstufen
l = Reverb(Reverb(l, 0.35f, 0.62f), 0.25f, 0.7f); r = Reverb(Reverb(r, 0.35f, 0.64f), 0.25f, 0.72f);
int len = Math.Min(l.Length, r.Length);
var st = new float[len * 2];
float peak = 1e-4f;
for (int i = 0; i < len; i++) peak = MathF.Max(peak, MathF.Max(MathF.Abs(l[i]), MathF.Abs(r[i])));
for (int i = 0; i < len; i++)
{
float fade = i > len - RATE ? (len - i) / (float)RATE : 1;
// weich begrenzen: laut, aber ohne Knacksen
st[i * 2] = MathF.Tanh(l[i] / peak * 1.6f) * 0.9f * fade;
st[i * 2 + 1] = MathF.Tanh(r[i] / peak * 1.6f) * 0.9f * fade;
}
Save(lang, Kind.Chant, name + "|v3", st);
return st;
}

View File

@@ -15,6 +15,14 @@ namespace GladiatorIdle
/// Tägliches Training: Grund-XP/s plus dieser Anteil der gesamten Ausbilder-Leistung,
/// fest verteilt (Stärke, Ausdauer, Geschick, Showtalent) – wächst mit den Ausbildern mit.
// ── Training im Ludus (aktiv): Energie, XP je gelungener Aktion ──
public const int TRAIN_ENERGY_MAX = 5;
public const double TRAIN_ENERGY_SECONDS = 12 * 60; // eine neue Einheit
public const double TRAIN_TIME = 30; // Sekunden je Übung
/// Anteil einer Stufe je gelungener Aktion (ohne Ausbilder); ~20 Aktionen je Übung.
public const double TRAIN_LEVEL_PER_ACTION = 0.06;
public const double TRAIN_TRAINER_BONUS = 0.12; // +12 % je Ausbilder-Stufe
public const double EXPEDITION_GOLD = 0.45; // Denare der Expedition (Anteil der Siege)
public const double DRILL_BASE = 1.0;
public const double DRILL_TRAINER_SHARE = 0.6;
public static readonly double[] DRILL_SPLIT = { 0.3, 0.3, 0.2, 0.2 };

View File

@@ -341,9 +341,30 @@ namespace GladiatorIdle
return (Balance.DRILL_BASE * XpMult(s) + Balance.DRILL_TRAINER_SHARE * trainers) * Balance.DRILL_SPLIT[(int)s];
}
/// Gesamt-XP/s eines Werts (Ausbilder + Training).
/// Gesamt-XP/s eines Werts (früheres passives Training; nur noch Anzeige/Bot-Vergleich).
public double XpPerSec(Stat s) => TrainerXpPerSec(s) + DrillXpPerSec(s);
// ── Training im Ludus (aktiv) ───────────────────────────────
/// Trainingsenergie (0 … 5), eine Einheit je Übung, füllt sich mit der Zeit (auch offline).
public double TrainEnergy { get; private set; } = Balance.TRAIN_ENERGY_MAX;
public bool CanTrain => TrainEnergy >= 1 && Away == null;
/// Sekunden bis zur nächsten vollen Einheit (0 = voll).
public double TrainEnergyNextIn => TrainEnergy >= Balance.TRAIN_ENERGY_MAX ? 0 : (1 - TrainEnergy % 1) * Balance.TRAIN_ENERGY_SECONDS;
public double TrainFactor(Stat s) => (1 + Balance.TRAIN_TRAINER_BONUS * UpgradeLevel(UpgradeDef.TrainerFor(s).Id)) * XpMult(s);
/// XP je gelungener Aktion für diesen Wert (wächst mit der Stufe, den Ausbildern und Boni).
public double TrainXpPerAction(Stat s) => Balance.XpToNext(Level(s)) * Balance.TRAIN_LEVEL_PER_ACTION * TrainFactor(s);
/// Übung abgeschlossen: Energie verbrauchen, XP gutschreiben. Liefert die XP.
public double Train(Stat s, int actions)
{
if (TrainEnergy < 1) return 0;
TrainEnergy -= 1;
double xp = 0;
for (int i = 0; i < actions; i++) { double x = TrainXpPerAction(s); AddXp(s, x); xp += x; }
return xp;
}
public double XpToNext(Stat s) => Balance.XpToNext(Level(s));
public Combatant PlayerCombat()
@@ -377,11 +398,7 @@ namespace GladiatorIdle
{
RunSeconds += dt;
Crowd = Math.Max(0, Crowd - Balance.CROWD_DECAY * Gods.CrowdDecayMult(GodLevel(God.Bacchus)) * dt);
for (int i = 0; i < 4; i++)
{
double r = XpPerSec((Stat)i);
if (r > 0) AddXp((Stat)i, r * dt);
}
TrainEnergy = Math.Min(Balance.TRAIN_ENERGY_MAX, TrainEnergy + dt / Balance.TRAIN_ENERGY_SECONDS);
Recovery = Math.Max(0, Recovery - dt);
for (int i = Buffs.Count - 1; i >= 0; i--)
if ((Buffs[i].Left -= dt) <= 0) Buffs.RemoveAt(i);
@@ -486,7 +503,7 @@ namespace GladiatorIdle
var rep = new ExpeditionReport
{
Region = a.Region, Success = ok,
Gold = Balance.GoldPerWin(r.Tier) * GoldMult * fights * 0.9 * share,
Gold = Balance.GoldPerWin(r.Tier) * GoldMult * fights * Balance.EXPEDITION_GOLD * share,
Fame = Balance.FamePerWin(r.Tier) * FameMult * fights * 0.5 * share,
Xp = Balance.CharXpPerWin(r.Tier) * fights * 0.8 * share,
};
@@ -710,11 +727,12 @@ namespace GladiatorIdle
seconds = Math.Clamp(seconds, 0, OfflineCapSeconds);
double gold = GoldEarnedRun, fame = FameRun;
int wins = Wins, losses = Losses, levels = StatLevels.Sum();
bool collect = CollectEvents;
CollectEvents = false;
for (double t = 0; t < seconds; t += Balance.OFFLINE_STEP)
Tick(Math.Min(Balance.OFFLINE_STEP, seconds - t));
CollectEvents = collect;
// nur Zeit läuft weiter: Reise, Erholung, Trainingsenergie – kein Training, keine Kämpfe
TrainEnergy = Math.Min(Balance.TRAIN_ENERGY_MAX, TrainEnergy + seconds / Balance.TRAIN_ENERGY_SECONDS);
Recovery = Math.Max(0, Recovery - seconds);
for (int i = Buffs.Count - 1; i >= 0; i--)
if ((Buffs[i].Left -= seconds) <= 0) Buffs.RemoveAt(i);
if (Away != null && (Away.Left -= seconds) <= 0) FinishExpedition();
return new OfflineReport(seconds, GoldEarnedRun - gold, FameRun - fame, Wins - wins, Losses - losses,
StatLevels.Sum() - levels);
}
@@ -768,6 +786,8 @@ namespace GladiatorIdle
public List<Item> Inventory { get; set; } = new();
public long NextItemId { get; set; } = 1;
public Expedition? Away { get; set; }
public double TrainEnergy { get; set; } = Balance.TRAIN_ENERGY_MAX;
public Dictionary<string, double>? GoldBySource { get; set; }
public ExpeditionReport? ExpeditionResult { get; set; }
public string? PendingEvent { get; set; }
public double EventIn { get; set; } = Adventures.EVENT_MIN;
@@ -788,7 +808,7 @@ namespace GladiatorIdle
Equipped = Equipped, SlotLevels = SlotLevels, Inventory = Inventory,
NextItemId = _nextItemId,
Away = Away, ExpeditionResult = ExpeditionResult, PendingEvent = PendingEvent, EventIn = EventIn, Buffs = Buffs,
SkillRanks = SkillRanks
SkillRanks = SkillRanks, TrainEnergy = TrainEnergy, GoldBySource = GoldBySource
};
public static GameState FromSave(SaveData d, int? seed = null)
@@ -806,6 +826,8 @@ namespace GladiatorIdle
FreedomEarned = d.FreedomEarned, Wins = d.Wins, Losses = d.Losses, RunSeconds = d.RunSeconds
};
g._pendingInherit = d.PendingInherit;
g.TrainEnergy = Math.Clamp(d.TrainEnergy, 0, Balance.TRAIN_ENERGY_MAX);
if (d.GoldBySource != null) foreach (var kv in d.GoldBySource) g.GoldBySource[kv.Key] = kv.Value;
g.CharLevel = d.CharLevel; g.CharXp = d.CharXp; g.AttrPoints = d.AttrPoints; g.StatBonus = Fit(d.StatBonus, 4);
g.Equipped = Fit(d.Equipped, 5);
g.SlotLevels = Fit(d.SlotLevels, 5);

View File

@@ -55,6 +55,14 @@ namespace GladiatorIdle
{
ManageGear(gs);
BuyCheapest(gs);
// Ludus-Training: schwächsten Wert üben (Aktionen je nach Geschick)
if (gs.CanTrain)
{
var weakest = (Stat)Enumerable.Range(0, 4).OrderBy(i => gs.StatLevels[i]).First();
gs.Train(weakest, (int)(12 + 16 * skill));
Pass(Balance.TRAIN_TIME + 10);
continue;
}
if (gs.PendingEvent != null) gs.Choose(0);
if (!gs.CanFight) { Pass(5); continue; } // Erholung abwarten

View File

@@ -93,6 +93,18 @@
"ludus.damage": "Schaden",
"ludus.crit": "Chance auf kritischen Treffer",
"ludus.level": "Stufe {0}",
"ludus.train.hint.showmanship": "Zeig dich: kritische Treffer, Sprünge und Spezialangriffe zählen doppelt.",
"ludus.train.hint.agility": "Der Doctore greift an – weiche seinen Hieben aus.",
"ludus.train.hint.endurance": "Der Doctore greift an – blocke erst kurz vor seinem Hieb. Dauerblocken zählt nicht, eine Parade doppelt.",
"ludus.train.hint.strength": "Triff den Doctore so oft du kannst – er hält still.",
"ludus.train.per": "{0} XP je Aktion",
"ludus.train.intro": "Selbst trainieren: 30 Sekunden gegen den Doctore. Jede gelungene Aktion bringt XP. Jede Übung kostet eine Einheit Kraft.",
"ludus.train.full": "ausgeruht",
"ludus.train.next": "nächste in {0}",
"ludus.train.result": "{0} Aktionen · +{1} XP {2}",
"ludus.train.done": "Training beendet",
"ludus.train.count": "{0} gelungen",
"ludus.train.title": "{0}-Training",
"ludus.levelup": "Stufe {0}!",
"arena.rank": "Gegner {0} von {1}",
"arena.championfight": "Champion-Kampf!",
@@ -141,7 +153,7 @@
"hall.reward": "Du hast die Legende {0} besiegt! +{1} Gunst der Götter",
"hall.away": "Dein Gladiator ist auf Expedition.",
"duel.legend": "Duell der Legenden",
"upgrade.trainer.desc": "Trainiert {0} nach und nach – auch wenn du nicht spielst.",
"upgrade.trainer.desc": "+12 % Trainings-XP für {0} je Stufe.",
"upgrade.building.baths.desc": "Schnellere Erholung nach einer Niederlage (−12 % je Stufe).",
"upgrade.building.kitchen.desc": "Besseres Essen: +15 % XP je Stufe.",
"upgrade.building.medicus.desc": "Ein Heiler für den Ludus: +8 % Leben je Stufe.",
@@ -533,11 +545,11 @@
"guide.gladiator.2": "Stärke = Schaden, Ausdauer = Leben, Geschick = kritische Treffer, Showtalent = mehr Ruhm und Stimmung.",
"guide.gladiator.3": "Klicke einen Gegenstand im Inventar an: die Karte zeigt seine Werte und um wie viel du stärker wirst (grün).",
"guide.gladiator.4": "„Bestes anlegen“ wählt die stärkste Ausrüstung. „Verstärken“ (Schmied) macht einen Platz stärker – für jedes Stück, das du dort trägst. Den Rest verkaufst du.",
"guide.ludus.what": "Deine Gladiatorenschule: Ausbilder und Gebäude wirken die ganze Zeit, auch wenn du nicht spielst.",
"guide.ludus.1": "Ausbilder steigern einen Wert nach und nach, während die Zeit vergeht.",
"guide.ludus.2": "Gebäude geben Dauerboni: schnellere Erholung, mehr Erfahrung, mehr Leben.",
"guide.ludus.3": "Jede Stufe kostet etwas mehr als die vorige.",
"guide.ludus.4": "Gewinne Kämpfe für Denare und investiere früh hier – das zahlt sich mit der Zeit aus.",
"guide.ludus.what": "Dein Trainingsplatz: Hier trainierst du selbst – 30 Sekunden gegen den Doctore.",
"guide.ludus.1": "Wähle einen Wert. Jede gelungene Aktion (Treffer, Block, Ausweichen, Show) bringt XP.",
"guide.ludus.2": "Jede Übung kostet eine Einheit Kraft. Alle 12 Minuten kommt eine zurück, auch wenn du nicht spielst (höchstens 5).",
"guide.ludus.3": "Ausbilder geben mehr XP je Aktion, Gebäude Dauerboni: schnellere Erholung, mehr Erfahrung, mehr Leben.",
"guide.ludus.4": "Ist die Kraft voll, verschenkst du Zeit – trainiere zwischen den Kämpfen.",
"guide.skills.what": "Dein Fähigkeitenbaum: drei Zweige mit Dauerboni und neuen Angriffen fürs Duell.",
"guide.skills.1": "Alle zwei Stufen bekommst du einen Fähigkeitspunkt.",
"guide.skills.2": "Klicke eine Fähigkeit an, um sie zu lernen. Untere Reihen öffnen sich mit genug Punkten im Zweig.",

View File

@@ -93,6 +93,18 @@
"ludus.damage": "Damage",
"ludus.crit": "Critical hit chance",
"ludus.level": "Level {0}",
"ludus.train.hint.showmanship": "Show off: critical hits, leaps and specials count double.",
"ludus.train.hint.agility": "The doctore attacks – dodge his strikes.",
"ludus.train.hint.endurance": "The doctore attacks – raise your block just before his strike. Holding block does not count, a parry counts double.",
"ludus.train.hint.strength": "Hit the doctore as often as you can – he stands still.",
"ludus.train.per": "{0} XP per action",
"ludus.train.intro": "Train yourself: 30 seconds against the doctore. Every successful action gives XP. Each session uses one unit of stamina.",
"ludus.train.full": "rested",
"ludus.train.next": "next in {0}",
"ludus.train.result": "{0} actions · +{1} XP {2}",
"ludus.train.done": "Training done",
"ludus.train.count": "{0} successful",
"ludus.train.title": "{0} training",
"ludus.levelup": "Level {0}!",
"arena.rank": "Opponent {0} of {1}",
"arena.championfight": "Champion fight!",
@@ -141,7 +153,7 @@
"hall.reward": "You defeated the legend {0}! +{1} favor of the gods",
"hall.away": "Your gladiator is on an expedition.",
"duel.legend": "Duel of legends",
"upgrade.trainer.desc": "Trains {0} bit by bit over time – even while you are away.",
"upgrade.trainer.desc": "+12 % training XP for {0} per level.",
"upgrade.building.baths.desc": "Faster recovery after a defeat (−12% per level).",
"upgrade.building.kitchen.desc": "Better food: +15% XP per level.",
"upgrade.building.medicus.desc": "A healer for the ludus: +8% health per level.",
@@ -533,11 +545,11 @@
"guide.gladiator.2": "Strength = damage, Endurance = health, Agility = critical hits, Showmanship = more fame and a livelier crowd.",
"guide.gladiator.3": "Click an item in the inventory: the card shows its values and how much stronger you would get (green).",
"guide.gladiator.4": "“Equip best” picks the strongest set. “Reinforce” (smith) makes a slot stronger for every piece you wear there. Sell the rest for denarii.",
"guide.ludus.what": "Your gladiator school: trainers and buildings work all the time, even while you are away.",
"guide.ludus.1": "Trainers raise one value step by step while the days go by.",
"guide.ludus.2": "Buildings give lasting bonuses: faster recovery, more experience, more health.",
"guide.ludus.3": "Each level costs a little more than the last one.",
"guide.ludus.4": "Win fights for denarii and invest here early – it pays off over time.",
"guide.ludus.what": "Your training ground: train yourself here – 30 seconds against the doctore.",
"guide.ludus.1": "Pick a stat. Every successful action (hit, block, dodge, show) gives XP.",
"guide.ludus.2": "Each session uses one unit of stamina. One returns every 12 minutes, even while you are away (up to 5).",
"guide.ludus.3": "Trainers give more XP per action, buildings give lasting bonuses: faster recovery, more experience, more health.",
"guide.ludus.4": "Full stamina means wasted time – train between fights.",
"guide.skills.what": "Your skill tree: three branches with passive bonuses and new attacks for the duel.",
"guide.skills.1": "You get a skill point every two levels.",
"guide.skills.2": "Click a skill to learn it. Lower rows open after enough points in their branch.",

View File

@@ -93,6 +93,18 @@
"ludus.damage": "Daño",
"ludus.crit": "Probabilidad de crítico",
"ludus.level": "Nivel {0}",
"ludus.train.hint.showmanship": "Lúcete: críticos, saltos y ataques especiales cuentan doble.",
"ludus.train.hint.agility": "El doctore ataca: esquiva sus golpes.",
"ludus.train.hint.endurance": "El doctore ataca: bloquea justo antes de su golpe. Bloquear todo el rato no cuenta, la parada cuenta doble.",
"ludus.train.hint.strength": "Golpea al doctore tantas veces como puedas: se queda quieto.",
"ludus.train.per": "{0} XP por acción",
"ludus.train.intro": "Entrena tú mismo: 30 segundos contra el doctore. Cada acción lograda da XP. Cada sesión gasta una unidad de fuerza.",
"ludus.train.full": "descansado",
"ludus.train.next": "siguiente en {0}",
"ludus.train.result": "{0} acciones · +{1} XP {2}",
"ludus.train.done": "Entrenamiento terminado",
"ludus.train.count": "{0} logradas",
"ludus.train.title": "Entrenamiento de {0}",
"ludus.levelup": "¡Nivel {0}!",
"arena.rank": "Rival {0} de {1}",
"arena.championfight": "¡Combate de campeón!",
@@ -141,7 +153,7 @@
"hall.reward": "¡Has derrotado a la leyenda {0}! +{1} favor de los dioses",
"hall.away": "Tu gladiador está de expedición.",
"duel.legend": "Duelo de leyendas",
"upgrade.trainer.desc": "Entrena {0} poco a poco con el tiempo, incluso cuando no juegas.",
"upgrade.trainer.desc": "+12 % de XP de entrenamiento para {0} por nivel.",
"upgrade.building.baths.desc": "Recuperación más rápida tras una derrota (−12 % por nivel).",
"upgrade.building.kitchen.desc": "Mejor comida: +15 % de XP por nivel.",
"upgrade.building.medicus.desc": "Un sanador para el ludus: +8 % de vida por nivel.",
@@ -533,11 +545,11 @@
"guide.gladiator.2": "Fuerza = daño, Resistencia = vida, Agilidad = críticos, Espectáculo = más fama y público.",
"guide.gladiator.3": "Haz clic en un objeto del inventario: la tarjeta muestra sus valores y cuánto más fuerte serías (verde).",
"guide.gladiator.4": "«Equipar lo mejor» elige el equipo más fuerte. «Reforzar» (herrero) mejora una ranura para cada pieza que lleves en ella. Vende el resto.",
"guide.ludus.what": "Tu escuela de gladiadores: entrenadores y edificios trabajan siempre, incluso cuando no juegas.",
"guide.ludus.1": "Los entrenadores suben un atributo poco a poco con el paso del tiempo.",
"guide.ludus.2": "Los edificios dan bonos permanentes: recuperación más rápida, más experiencia, más vida.",
"guide.ludus.3": "Cada nivel cuesta algo más que el anterior.",
"guide.ludus.4": "Gana combates por denarios e invierte pronto aquí: compensa con el tiempo.",
"guide.ludus.what": "Tu campo de entrenamiento: entrena tú mismo, 30 segundos contra el doctore.",
"guide.ludus.1": "Elige un atributo. Cada acción lograda (golpe, bloqueo, esquiva, espectáculo) da XP.",
"guide.ludus.2": "Cada sesión gasta una unidad de fuerza. Recuperas una cada 12 minutos, incluso sin jugar (máximo 5).",
"guide.ludus.3": "Los instructores dan más XP por acción; los edificios, bonificaciones fijas: recuperación más rápida, más experiencia, más vida.",
"guide.ludus.4": "Con la fuerza llena pierdes tiempo: entrena entre combates.",
"guide.skills.what": "Tu árbol de habilidades: tres ramas con bonos y nuevos ataques para el duelo.",
"guide.skills.1": "Cada dos niveles recibes un punto de habilidad.",
"guide.skills.2": "Haz clic en una habilidad para aprenderla. Las filas inferiores se abren con suficientes puntos en su rama.",

View File

@@ -120,6 +120,8 @@ namespace GladiatorIdle.Arena
public bool? Spared => _spared;
public float MissioTime => _missio ? _missioT : -1;
public bool Over => _phase == Phase.End;
/// Testläufe: Zeit seit dem Ende des Kampfs.
public float EndTime => _phase == Phase.End ? _phaseTime : -1;
sealed class Floater { public string Text = ""; public Vector2 Pos; public Color Color; public float Size, Age, Life = 1.1f; public bool Big; }
readonly List<Floater> _floaters = new();
@@ -136,6 +138,36 @@ namespace GladiatorIdle.Arena
public TutStep Tutorial => _tut;
public bool TutorialRan { get; private set; }
// ── Training im Ludus: 30 s Übung, jede gelungene Aktion zählt ──
public Stat? Training { get; private set; }
public int TrainActions { get; private set; }
float _trainPop;
public void StartTraining(Stat s)
{
Training = s;
Duel.GuardHp = true;
Duel.EnemyDamageMult = 0.25;
if (s is Stat.Strength or Stat.Showmanship) Duel.EnemyPassive = true; // der Doctore hält still
else Duel.EnemyAttacksOnly = true; // der Doctore greift an: blocken bzw. ausweichen
}
void TrainEvent(DuelEvent e)
{
if (Training is not Stat s || _phase != Phase.Fight) return;
int n = s switch
{
Stat.Strength => e.Type == DuelEventType.Hit && e.ByPlayer ? 1 : 0,
// Ausdauer: nur rechtzeitiges Blocken zählt (Block kurz vor dem Hieb gesetzt), Dauerblock bringt nichts
Stat.Endurance => !e.ByPlayer ? 0 : e.Type == DuelEventType.Parry ? 2
: e.Type == DuelEventType.Blocked && Duel.Time - Duel.Player.BlockSince < 0.5 ? 1 : 0,
Stat.Agility => e.Type == DuelEventType.Dodged && e.ByPlayer ? 1 : 0,
_ => e.ByPlayer && e.Type is DuelEventType.Leap or DuelEventType.Special or DuelEventType.Super ? 2
: e.Type == DuelEventType.Hit && e.ByPlayer ? (e.Crit ? 2 : 1) : 0,
};
if (n > 0) { TrainActions += n; _trainPop = 1; _crowd.Excite(0.08f); }
}
public void StartTutorial()
{
TutorialRan = true;
@@ -284,7 +316,6 @@ namespace GladiatorIdle.Arena
if (!_announced)
{
_announced = true;
NameVoice.Play(NameVoice.Kind.Enter, 1f, 8); // „Gladiator Spartacus!“
if (_enemy.IsChampion) // Champion: von unten nah heran, dann hoch und zurück
Cine(Pivot.Enemy, new(0.01f, -35, -24, 1700), new(1.7f, -55, -16, 1550), new(COUNTDOWN, 0, 0, 0));
else if (_tut == TutStep.Off) // volle Umrundung beider Kämpfer
@@ -305,18 +336,27 @@ namespace GladiatorIdle.Arena
TutUpdate(realDt, input);
Duel.Step(dt);
HandleEvents();
_trainPop = MathF.Max(0, _trainPop - realDt * 3);
if (Training != null && Duel.Time >= Balance.TRAIN_TIME)
{
// Übung vorbei: kein Sieger, kein Gnadenstoß
_phase = Phase.End; _phaseTime = 0; Won = true; _missio = false;
Duel.EnemyPassive = true; Duel.EnemyAttacksOnly = false;
SoundManager.PlayVictory(); SoundManager.PlayCheer();
break;
}
if (Duel.Over)
{
_phase = Phase.End; _phaseTime = 0; Won = Duel.PlayerWon;
// Gnadenstoß: nicht in der Einführung und nicht gegen Legenden
_missio = !TutorialRan && _enemy.Display == null;
if (Won && !_missio) NameVoice.Play(NameVoice.Kind.Chant, 1f, 0);
if (Won) NameVoice.Play(NameVoice.Kind.Chant, 1f, 0); // jeder Sieg: die Menge ruft den Namen
_crowdMercy = Duel.DamageToPlayer >= Duel.Player.MaxHp * 0.3 || Duel.Time >= 25; // tapferer Gegner
if (!Won) _spared = Duel.PlayerParries >= 2 || Duel.Enemy.Hp <= Duel.Enemy.MaxHp * 0.5 || Duel.Time >= 30;
_cam.FocusX = Won ? _pv.X : _ev.X;
// Kinomoment: Kamera kippt nach unten, Nahansicht auf den Sieger über dem Gefallenen
Cine(Pivot.Winner, new(0.6f, Won ? 35 : -35, -20, 1500), new(2.8f, Won ? 70 : -70, -17, 1450));
if (Won) SoundManager.PlayVictory(); else SoundManager.PlayDefeat();
if (Won) { SoundManager.PlayVictory(); SoundManager.PlayCheer(); } else SoundManager.PlayDefeat();
}
break;
case Phase.End:
@@ -458,6 +498,7 @@ namespace GladiatorIdle.Arena
foreach (var e in Duel.Events)
{
TutEvent(e);
TrainEvent(e);
var targetView = e.ByPlayer ? _ev : _pv;
var actorView = e.ByPlayer ? _pv : _ev;
var target = e.ByPlayer ? Duel.Enemy : Duel.Player;
@@ -845,16 +886,25 @@ namespace GladiatorIdle.Arena
if (n >= 1)
D.Text(sb, Assets.Serif, 200, n.ToString(NumberFormat.Culture), new Vector2(Camera.W / 2, 420),
D.Gold * (1 - k * 0.7f), Align.Center, 1.5f - 0.5f * k);
D.Text(sb, Assets.SansBold, 28, L.t(_enemy.Display != null ? "duel.legend" : _enemy.IsChampion ? "duel.champion" : "duel.practice").ToUpperInvariant(),
D.Text(sb, Assets.SansBold, 28, (Training is Stat tt ? string.Format(L.t("ludus.train.title"), L.t(TextKeys.Of(tt))) : L.t(_enemy.Display != null ? "duel.legend" : _enemy.IsChampion ? "duel.champion" : "duel.practice")).ToUpperInvariant(),
new Vector2(Camera.W / 2, 600), D.Sand, Align.Center);
}
if (Training is Stat ts && _phase == Phase.Fight)
{
// Übung: Zeit, Zähler, Hinweis
double left = Math.Max(0, Balance.TRAIN_TIME - Duel.Time);
D.Text(sb, Assets.Serif, 34, string.Format(L.t("ludus.train.title"), L.t(TextKeys.Of(ts))), new Vector2(Camera.W / 2, 150), D.Gold, Align.Center);
D.Text(sb, Assets.SansBold, 26, $"{left:0}s · " + string.Format(L.t("ludus.train.count"), TrainActions), new Vector2(Camera.W / 2, 196), // i18n-ok
Color.Lerp(Color.White, D.Gold, _trainPop), Align.Center, 1 + 0.15f * _trainPop);
D.Text(sb, Assets.Sans, 20, L.t("ludus.train.hint." + ts.ToString().ToLowerInvariant()), new Vector2(Camera.W / 2, 236), D.Sand, Align.Center);
}
if (_phase == Phase.End && _missio && _decidedAt < 0) DrawMissio(sb);
else if (_phase == Phase.End)
{
float since = _missio ? _missioT - _decidedAt : _phaseTime;
float k = MathHelper.Clamp(since / 0.6f, 0, 1);
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * (0.35f * k));
D.Text(sb, Assets.Serif, 170, L.t(Won ? "duel.win" : "duel.lose"), new Vector2(Camera.W / 2, 400),
D.Text(sb, Assets.Serif, 170, Training != null ? L.t("ludus.train.done") : L.t(Won ? "duel.win" : "duel.lose"), new Vector2(Camera.W / 2, 400),
(Won ? D.Gold : D.Red) * k, Align.Center, 1 + 0.4f * (1 - k));
if (_missio)
{
@@ -929,7 +979,7 @@ namespace GladiatorIdle.Arena
if (!Won) { if (mercy) SoundManager.PlayCheer(); else SoundManager.PlayBoo(); return; }
_mercy = mercy;
bool match = mercy == _crowdMercy;
if (match) { _crowd.Wave(); SoundManager.PlayCheer(); NameVoice.Play(_enemy.IsChampion ? NameVoice.Kind.Win : NameVoice.Kind.Chant, 1f, 0); }
if (match) { _crowd.Wave(); SoundManager.PlayCheer(); if (_enemy.IsChampion) NameVoice.Play(NameVoice.Kind.Win, 1f, 0); }
else SoundManager.PlayBoo();
if (!mercy) { _pv.HoldClip = "powerup"; _cam.Shake(0.35f); SoundManager.PlayFury(); } // Kampfschrei, keine Tötung
Big(L.t(mercy ? "missio.mitte" : "missio.iugula"), mercy ? D.Gold : new Color(255, 120, 70));

View File

@@ -20,6 +20,7 @@ namespace GladiatorIdle.Arena
float _mTime, _mBlend = 1;
bool _mFree;
float _lift; // Höhe über dem Boden (Sprungangriff)
float _ground, _restLow; // Absenken liegender Figuren (Modell-Einheiten), tiefster Punkt der Grundhaltung
public bool Is3D => _model != null;
@@ -44,6 +45,7 @@ namespace GladiatorIdle.Arena
_model.SetColor(color);
var idle = Clip3("idle");
_model.Pose(idle, 0, true);
_restLow = _model.LowestY();
double tColor = sw.Elapsed.TotalMilliseconds;
// Einpassen hängt nur von der Figur ab (sortiert alle Punkte): einmal je Bild-Name rechnen
if (!_fitCache.TryGetValue(_art, out _fit)) _fitCache[_art] = _fit = _model.FitNow();
@@ -172,6 +174,9 @@ namespace GladiatorIdle.Arena
_mBlend = MathF.Min(1, _mBlend + realDt / 0.12f);
_mTime = t;
m.Pose(Clip3(name), t, loop, _mBlend, rootY: f.State == DuelState.Leap ? 0.15f : 1);
// am Boden liegend: tiefster Punkt auf den Boden (die Todesbewegung passt nicht genau zur Figur)
float ground = f.State == DuelState.Down ? m.LowestY() - _restLow : 0;
_ground += (ground - _ground) * MathF.Min(1, realDt * 12);
// Sprungangriff: eigene Flugkurve (der Clip springt kaum und passt nicht zur kurzen Sprungzeit)
float air = (float)Duel.LEAP_HIT + 0.08f, leapT = (float)f.StateTime;
float lift = f.State == DuelState.Leap && leapT < air ? MathF.Sin(MathF.PI * leapT / air) * 0.55f * Stage.FigH : 0;
@@ -186,7 +191,7 @@ namespace GladiatorIdle.Arena
{
float s = Stage.FigH / 180f * (1 + grow);
float yaw = Facing * MathHelper.ToRadians(72); // zum Gegner, leicht zum Betrachter gedreht
return _fit * Matrix.CreateRotationY(yaw)
return Matrix.CreateTranslation(0, -_ground, 0) * _fit * Matrix.CreateRotationY(yaw)
* Matrix.CreateScale(s * (1 - _sq * 0.04f), -s * (1 + _sq * 0.06f), s) // y nach unten
* Matrix.CreateRotationZ(_lean * Facing)
* Matrix.CreateTranslation(X + _off * Facing * 0.35f * Stage.Scale, Stage.FloorY - _lift, 0);

View File

@@ -0,0 +1,302 @@
using System;
using System.Collections.Generic;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// <summary>
/// Begegnungen auf der Reise: Zu jeder Tagebuchzeile spielt eine kurze Szene am Weg – Kampf
/// gegen Räuber, Lager am Feuer, Fund in einer Ruine, Fest im Dorf. Dazu wechselnde Kamerafahrten
/// (360°-Umrundung, Untersicht, weit von oben, seitlich), die Figuren bleiben immer im Bild.
/// </summary>
internal sealed partial class HubScene
{
enum EncKind { None, Fight, Camp, Find, Village }
sealed class EncFig
{
public FighterView View = null!;
public DuelFighter F = new() { X = 0, Facing = -1, MaxHp = 1, Hp = 1 };
public float X, HomeX;
}
EncKind _enc;
float _encT, _encX, _encDelay = -1;
int _encLog, _encBeat;
bool _encStopped;
readonly List<EncFig> _encFigs = new();
Mesh3D? _encMesh;
float _jShotT, _encIdle; int _jShotKind = -1;
/// Tagebuchzeile der laufenden Szene (0 = keine) – das Tagebuch zeigt sie an.
int EncLogShown => _enc != EncKind.None || _encDelay >= 0 ? _encLog : 0;
float _jScale = 1; Vector2 _jOff; int _jVw = 1, _jVh = 1;
const float ENC_STOP = 360; // so weit vor der Szenenmitte bleibt der Held stehen
static EncKind KindOf(int log) => log switch
{
1 or 2 or 6 or 8 or 9 => EncKind.Fight,
12 => EncKind.Camp,
4 or 10 or 11 => EncKind.Find,
_ => EncKind.Village,
};
/// Neue Tagebuchzeile: nach kurzer Zeit taucht die passende Szene vor dem Helden auf.
void QueueEncounter(int log) { _encLog = log; _encDelay = 2.5f; }
/// Testläufe: diese Begegnung sofort (die laufende endet).
public void DevEncounter(int log)
{
_enc = EncKind.None; _encFigs.Clear(); _encMesh = null; _encStopped = false; _jCam.StopCine();
_encLog = log; _encDelay = 0.2f; _encIdle = 0;
}
void StartEncounter(int log)
{
_enc = KindOf(log);
_encT = 0; _encBeat = 0; _encStopped = false;
_encX = _jX + 1100;
_encFigs.Clear();
var rng = new Random(log * 31 + (int)_jX);
string[] arts = _enc switch
{
EncKind.Fight => log switch
{
2 => new[] { "champ_doctore" },
9 => new[] { "foe_brawler" },
_ => rng.Next(2) == 0 ? new[] { "foe_recruit", "foe_slave" } : new[] { "foe_hoplomachus", "foe_recruit" },
},
EncKind.Village => new[] { "foe_slave", "foe_recruit", "foe_slave" },
_ => Array.Empty<string>(),
};
for (int i = 0; i < arts.Length; i++)
{
var f = new EncFig { View = new FighterView(arts[i], 0.3f * i, -1, 0) };
// Kampf: Gegner kommen von vorn auf den Weg; Dorf: Bewohner warten am Weg
f.HomeX = _enc == EncKind.Fight ? _encX - ENC_STOP + 300 + 260 * i : _encX + 120 + 230 * i;
f.X = _enc == EncKind.Fight ? f.HomeX + 900 : f.HomeX;
f.F.Facing = -1;
_encFigs.Add(f);
}
BuildEncounterMesh(rng);
}
/// Kulisse der Szene: Lagerfeuer, Ruine oder Hütten (einfache Körper, Steine und Holz).
void BuildEncounterMesh(Random rng)
{
float floor = Stage.FloorY, x = _encX;
var m = new Mesh3D { Tex = Assets.Pixel };
switch (_enc)
{
case EncKind.Camp:
for (int i = 0; i < 6; i++)
{
float a = i * MathF.PI / 3;
m.Box(new Vector3(x + 46 * MathF.Cos(a), floor - 8, 40 + 46 * MathF.Sin(a)), new Vector3(70, 14, 16), new Color(92, 64, 40));
}
for (int i = 0; i < 8; i++) // Steinkreis
{
float a = i * MathF.PI / 4;
m.Box(new Vector3(x + 88 * MathF.Cos(a), floor - 10, 40 + 88 * MathF.Sin(a)), new Vector3(26, 20, 24), new Color(120, 116, 108));
}
break;
case EncKind.Find:
for (int i = 0; i < 5; i++)
{
float h = i == 3 ? 160 : 430 - 30 * rng.Next(3);
float cx = x - 260 + 150 * i;
m.Box(new Vector3(cx, floor - h / 2, -330), new Vector3(52, h, 52), new Color(196, 188, 170));
m.Box(new Vector3(cx, floor - 10, -330), new Vector3(78, 20, 78), new Color(176, 168, 150));
}
m.Box(new Vector3(x - 110, floor - 450, -330), new Vector3(360, 34, 70), new Color(186, 178, 160)); // Rest des Gebälks
m.Box(new Vector3(x + 260, floor - 18, -200), new Vector3(150, 36, 60), new Color(170, 162, 146)); // umgestürzte Trommel
break;
case EncKind.Village:
for (int i = 0; i < 3; i++)
{
float cx = x - 300 + 360 * i, cz = -520 - 120 * (i % 2);
m.Box(new Vector3(cx, floor - 110, cz), new Vector3(230, 220, 190), new Color(150, 120, 88));
m.Box(new Vector3(cx, floor - 250, cz), new Vector3(270, 60, 230), new Color(150, 128, 70)); // Strohdach
m.Box(new Vector3(cx, floor - 300, cz), new Vector3(180, 40, 160), new Color(140, 118, 64));
m.Box(new Vector3(cx, floor - 60, cz + 96), new Vector3(60, 120, 4), new Color(70, 50, 34)); // Tür
}
break;
}
m.Freeze();
_encMesh = m.VA is { Length: > 0 } ? m : null;
}
/// Szene fortschreiben; true, solange der Held stehen bleibt.
bool UpdateEncounter(float dt, bool calm)
{
if (_encDelay >= 0) { _encDelay -= dt; if (_encDelay < 0) StartEncounter(_encLog); }
// beim Zuschauen nicht lange nur laufen: alle ~20 s die nächste Begegnung
if (_enc == EncKind.None && _encDelay < 0 && (_encIdle += dt) > 18)
{
_encIdle = 0;
int next; do next = 1 + Random.Shared.Next(Adventures.LOG_LINES); while (next == _encLog);
QueueEncounter(next);
}
if (_enc == EncKind.None) return false;
bool hold = _jX >= _encX - ENC_STOP;
if (hold && !_encStopped)
{
_encStopped = true;
_jShotT = 0;
// Fahrt passend zur Szene
var pivotX = _encX - ENC_STOP / 2;
_jCam.CinePivot = new Vector3(pivotX, Stage.FloorY - Stage.FigH * 0.55f, 0);
if (_enc == EncKind.Fight) _jCam.Orbit(-26, -9, 500);
else if (_enc == EncKind.Find) _jCam.Shot(new Camera.Key(0.01f, -40, -20, 900), new Camera.Key(6, 30, -12, 700), new Camera.Key(11, 60, -6, 500));
else _jCam.Orbit(16, -4, 450);
}
if (_encStopped) _encT += dt;
float t = _encT;
foreach (var f in _encFigs)
{
// auf den Platz gehen, dann dort bleiben
if (_encStopped && MathF.Abs(f.X - f.HomeX) > 1) f.X += MathF.Sign(f.HomeX - f.X) * MathF.Min(MathF.Abs(f.HomeX - f.X), 320 * dt);
f.F.StateTime += dt;
}
switch (_enc)
{
case EncKind.Fight when _encStopped && t > 2.4f:
{
// Schlagabtausch im Takt: gerade Takte schlägt der Held, ungerade der Gegner
int beat = (int)((t - 2.4f) / 0.95f);
var foe = FirstStanding();
if (beat != _encBeat && foe != null)
{
_encBeat = beat;
if (beat >= 6)
{
foreach (var f in _encFigs) if (f.F.State != DuelState.Down) { f.F.Set(DuelState.Down); }
SoundManager.PlayKo();
_jDummy.Set(DuelState.Victory);
}
else if (beat % 2 == 0)
{
_jDummy.Set(DuelState.Strike); SoundManager.PlaySwing();
foe.F.Set(beat == 4 ? DuelState.Down : DuelState.Hit);
if (beat == 4) SoundManager.PlayKo(); else SoundManager.PlayHit();
if (!calm) _jfx.Sparks(new Vector2(foe.X - 60, Stage.FloorY - Stage.FigH * 0.55f), 10, new Color(255, 220, 140), MathF.PI, 1.2f, 260);
}
else
{
foe.F.Set(DuelState.Strike); SoundManager.PlaySwing();
_jDummy.Set(DuelState.Block); SoundManager.PlayBlock();
}
}
if (_jDummy.State is DuelState.Strike or DuelState.Block && _jDummy.StateTime > 0.45f) _jDummy.Set(DuelState.Ready);
foreach (var f in _encFigs)
if (f.F.State is DuelState.Strike or DuelState.Hit && f.F.StateTime > 0.5f) f.F.Set(DuelState.Ready);
break;
}
case EncKind.Find when _encStopped && t > 2.6f && _jDummy.State != DuelState.Victory:
_jDummy.Set(DuelState.Victory); SoundManager.PlayUnlock();
break;
case EncKind.Village when _encStopped && t > 0.8f:
foreach (var f in _encFigs) if (f.F.State != DuelState.Victory) f.F.Set(DuelState.Victory);
if (t > 1.5f && _jDummy.State != DuelState.Victory) { _jDummy.Set(DuelState.Victory); SoundManager.PlayCheer(); }
break;
}
foreach (var f in _encFigs) f.View.Update(dt, dt, f.F, f.X, calm);
float len = _enc == EncKind.Fight ? 10.5f : 9f;
if (_encStopped && t > len)
{
// weiter: Szene bleibt am Weg zurück, bis sie aus dem Bild ist
_jDummy.Set(DuelState.Ready);
_encStopped = false; _encT = -999;
_jCam.StopCine();
}
if (!_encStopped && _encT < -1 && _jX > _encX + 2600) { _enc = EncKind.None; _encFigs.Clear(); _encMesh = null; }
return _encStopped;
}
EncFig? FirstStanding()
{
foreach (var f in _encFigs) if (f.F.State != DuelState.Down) return f;
return null;
}
/// Kamera beim Wandern: alle ~11 s eine andere Einstellung (nie zweimal dieselbe).
void UpdateJourneyCamera(float dt, bool calm)
{
if (calm || _encStopped) return;
_jShotT -= dt;
if (_jShotT > 0) return;
int kind;
do kind = Random.Shared.Next(4); while (kind == _jShotKind);
_jShotKind = kind;
_jShotT = 10 + 4 * (float)Random.Shared.NextDouble();
switch (kind)
{
case 0: _jCam.Orbit(Random.Shared.Next(2) == 0 ? 30 : -30, -6, 600); break; // Umrundung 360°
case 1: _jCam.Shot(new Camera.Key(0.01f, -70, -22, 1500), new Camera.Key(_jShotT, -40, -16, 1300)); break; // von vorn unten
case 2: _jCam.Shot(new Camera.Key(0.01f, 25, 15, 150), new Camera.Key(_jShotT, -25, 11, 300)); break; // weit von oben
default: _jCam.StopCine(); break; // seitlich
}
}
/// Figuren der Szene im Bild halten (Kopf und Füße aller Beteiligten).
void KeepJourneyInView(float dt)
{
Span<Vector3> pts = stackalloc Vector3[2 + 2 * Math.Min(_encFigs.Count, 3)];
pts[0] = new(_jX - 90, Stage.FloorY - Stage.FigH * 1.1f, 0); pts[1] = new(_jX + 90, Stage.FloorY + 12, 0);
int n = 2;
if (_encStopped)
for (int i = 0; i < _encFigs.Count && n + 1 < pts.Length; i++)
{
pts[n++] = new(_encFigs[i].X, Stage.FloorY - Stage.FigH * 1.1f, 0);
pts[n++] = new(_encFigs[i].X, Stage.FloorY + 12, 0);
}
_jCam.KeepInView(pts[..n], _jScale, _jOff, _jVw, _jVh, dt);
}
/// Kulisse und Figuren der Szene zeichnen (im 3D-Durchgang der Reise, nach dem Bewuchs).
void DrawEncounterSet(GraphicsDevice gd)
{
if (_enc == EncKind.None || _encMesh == null || _jFx == null) return;
_jFx.Texture = Assets.Pixel; _jFx.DiffuseColor = Vector3.One; _jFx.World = Matrix.Identity;
foreach (var pass in _jFx.CurrentTechnique.Passes)
{
pass.Apply();
gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _encMesh.VA, 0, _encMesh.VA!.Length, _encMesh.IA, 0, _encMesh.IA!.Length / 3);
}
}
void DrawEncounterFigures(GraphicsDevice gd, BasicEffect fx, Matrix v3, Matrix p3, ArenaLook look, bool calm)
{
foreach (var f in _encFigs)
{
f.View.UseCamera3D(v3, p3);
f.View.SetLighting(look);
f.View.DrawBody(gd, fx, f.F, calm);
}
}
FighterView[] EncShadowFigs()
{
var a = new FighterView[1 + _encFigs.Count];
a[0] = _jHero!;
for (int i = 0; i < _encFigs.Count; i++) a[i + 1] = _encFigs[i].View;
return a;
}
/// Lagerfeuer: Glut und Flammen (additiv), Funken.
void DrawCampFire(SpriteBatch sb, bool calm)
{
if (_enc != EncKind.Camp || _jPlane == null) return;
var at = new Vector2(_encX, Stage.FloorY - 30);
float fl = 0.8f + 0.2f * MathF.Sin((float)_t * 21) * MathF.Sin((float)_t * 6.3f);
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, _jPlane);
D.Glow(sb, new Vector2(_encX, Stage.FloorY), new Vector2(1500 * fl, 360), new Color(255, 130, 40) * 0.45f);
D.Glow(sb, at, new Vector2(150 * fl, 210 * fl), new Color(255, 150, 50));
D.Glow(sb, at + new Vector2(0, 20), new Vector2(80, 110 * fl), new Color(255, 236, 170));
sb.End();
if (!calm && Random.Shared.NextDouble() < 0.6) _jfx.Sparks(at, 1, new Color(255, 180, 80), -MathF.PI / 2, 0.6f, 160);
}
}
}

View File

@@ -38,7 +38,7 @@ namespace GladiatorIdle.Arena
Mesh3D? _jGround, _jPath, _jStone;
string? _jRegion;
float _jX;
int _jLine = -1; float _jLineT;
int _jLine = -1, _jLogShown; float _jLineT;
/// Testlauf: Tageszeit (0 Morgen, 0,25 Mittag, 0,5 Abend, 0,75 Nacht) statt aus der Reisezeit.
public float? DevDayPhase;
// feste Puffer (keine neuen Objekte je Bild)
@@ -54,6 +54,10 @@ namespace GladiatorIdle.Arena
_jHero ??= Assets.Has(hero) ? new FighterView(hero, 0.5f, _game.Look.Color) : new FighterView(Art.Fighter(_game.Class), 0.5f);
_jCam.FollowX = 300; _jCam.FollowZoom = 1.0f;
_jCam.Center = new Vector2(300, Camera.H / 2 + 40);
_jCam.StopCine(); _jCam.Ring = null;
_enc = EncKind.None; _encDelay = -1; _encFigs.Clear(); _encMesh = null; _encStopped = false;
_jShotT = 5; _jShotKind = 3;
_jDummy.Set(DuelState.Ready);
SoundManager.PlayDrawer();
}
@@ -61,10 +65,15 @@ namespace GladiatorIdle.Arena
{
if (_game.Away is not { } away) { _overlay = Overlay.Map; return; }
bool calm = AppSettings.ReduceMotion;
_jX += WALK_SPEED * dt;
bool hold = UpdateEncounter(dt, calm);
if (!hold) _jX += WALK_SPEED * dt;
_jDummy.StateTime += dt;
_jHero!.Update(dt, dt, _jDummy, _jX, calm);
_jCam.FollowX = _jX + 260;
if (!hold) _jCam.CinePivot = new Vector3(_jX, Stage.FloorY - Stage.FigH * 0.6f, 0);
UpdateJourneyCamera(dt, calm);
_jCam.Update(dt, _jX, _jX, calm);
KeepJourneyInView(dt);
_jfx.Calm = calm;
_jfx.Update(dt);
if (_jRegion != away.Region) BuildJourney(away.Region);
@@ -80,8 +89,8 @@ namespace GladiatorIdle.Arena
Mesh3D Grid(string tex, Vector3 tint, float z0, float z1, float y, int nz)
{
var m = new Mesh3D { Tex = Assets.Sprite(tex, "jpg"), Wrap = true, Tint = tint };
const int NX = 30;
float x0 = -4200, x1 = 4200;
const int NX = 44;
float x0 = -6600, x1 = 6600;
for (int i = 0; i < NX; i++)
for (int k = 0; k < nz; k++)
{
@@ -94,7 +103,7 @@ namespace GladiatorIdle.Arena
m.Freeze();
return m;
}
_jGround = Grid(land.Ground, land.GroundTint, -3000, 900, floor, 10);
_jGround = Grid(land.Ground, land.GroundTint, -5000, 5000, floor, 24); // auch hinter der Kamera (360°-Fahrten)
_jPath = Grid(land.Path, land.PathTint, -230, 150, floor - 0.6f, 2);
// Meilenstein
_jStone = new Mesh3D { Tex = Assets.Pixel };
@@ -140,6 +149,7 @@ namespace GladiatorIdle.Arena
bool calm = AppSettings.ReduceMotion;
int vw = gd.Viewport.Width, vh = gd.Viewport.Height;
_jScale = scale; _jOff = offset; _jVw = vw; _jVh = vh;
var v3 = _jCam.View3(); var p3 = _jCam.Proj3(scale, offset, vw, vh);
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
_jFx ??= new BasicEffect(gd) { TextureEnabled = true, VertexColorEnabled = true, PreferPerPixelLighting = true };
@@ -150,12 +160,13 @@ namespace GladiatorIdle.Arena
float camX = _jCam.Center.X;
// fernes Regionsbild (gespiegelt wiederholt, langsamer als der Weg: Parallaxe)
if (Picture(reg.Art) is Texture2D pic)
float picA = _jCam.PlaneAlpha; // Bild nur im Blick nach vorn, beim Drehen in den Nebel ausblenden
if (picA > 0.01f && Picture(reg.Art) is Texture2D pic)
{
const float Z = -5200, W = 7000;
float h = W * pic.Height / pic.Width, bottom = Stage.FloorY + 900, top = bottom - h * 1.15f;
float xl = camX - 9000, xr = camX + 9000, shift = camX * 0.8f;
var c = new Color(sky * (0.92f - 0.55f * night));
var c = new Color(Vector3.Lerp(fog, sky * (0.92f - 0.55f * night), picA));
float u0 = (xl - shift) / W, u1 = (xr - shift) / W;
_jBack[0] = new(new Vector3(xl, top, Z), c, new Vector2(u0, 0)); _jBack[1] = new(new Vector3(xr, top, Z), c, new Vector2(u1, 0));
_jBack[2] = new(new Vector3(xr, bottom, Z), c, new Vector2(u1, 1)); _jBack[3] = _jBack[0]; _jBack[4] = _jBack[2];
@@ -192,7 +203,7 @@ namespace GladiatorIdle.Arena
}
// Meilensteine alle 4 Felder
_jFx.Texture = Assets.Pixel; _jFx.DiffuseColor = Vector3.One;
int c0 = (int)MathF.Floor((camX - 4200) / CELL), c1 = (int)MathF.Ceiling((camX + 4200) / CELL);
int c0 = (int)MathF.Floor((camX - 5600) / CELL), c1 = (int)MathF.Ceiling((camX + 5600) / CELL);
for (int cell = c0; cell <= c1; cell++)
if (cell % 4 == 0)
{
@@ -205,7 +216,7 @@ namespace GladiatorIdle.Arena
}
// Bäume, Büsche, Felsen: je Feld fest ausgewürfelt
foreach (var key in land.Props) if (!_jProps.ContainsKey(key)) _jProps[key] = (new VertexPositionColorTexture[6 * 400], 0);
foreach (var key in land.Props) if (!_jProps.ContainsKey(key)) _jProps[key] = (new VertexPositionColorTexture[6 * 600], 0);
var counts = new Dictionary<string, int>(_jProps.Count);
foreach (var k in _jProps.Keys) counts[k] = 0;
var light = new Color(Vector3.Clamp(amb + sun * 0.55f, Vector3.Zero, Vector3.One));
@@ -222,6 +233,7 @@ namespace GladiatorIdle.Arena
float zr = (float)rng.NextDouble();
// nah am Weg nur Kleines, weiter hinten auch Bäume; selten etwas ganz vorn
float z = zr < 0.45f ? -240 - 520 * (float)rng.NextDouble() : -800 - 2000 * (float)rng.NextDouble();
if (zr > 0.8f) z = 2900 + 1600 * (float)rng.NextDouble(); // hinter der Kamera: sichtbar beim Umrunden
if (!small && z > -380) continue; // Bäume nicht direkt am Weg
float size = (small ? 170 : 720) * (0.75f + 0.55f * (float)rng.NextDouble());
int k = counts[kind];
@@ -250,11 +262,13 @@ namespace GladiatorIdle.Arena
}
}
DrawEncounterSet(gd);
// Gladiator mit Schatten; nachts mit Fackel
var look = new ArenaLook("wood", sunDir, sun, amb, fog, 1600, 6200, Vector3.One, Color.White, 0, false, 0, 1);
_jHero.UseCamera3D(v3, p3);
_jHero.SetLighting(look);
Stage3D.SoftShadows(gd, sb, sunDir, 0.42f * (1 - 0.6f * night), _jHero);
Stage3D.SoftShadows(gd, sb, sunDir, 0.42f * (1 - 0.6f * night), EncShadowFigs());
var torch = _jHero.Chest + new Vector2(70, -40);
if (night > 0.01f)
{
@@ -267,6 +281,8 @@ namespace GladiatorIdle.Arena
}
Stage3D.BeginFigures(gd);
_jHero.DrawBody(gd, fx, _jDummy, calm);
DrawEncounterFigures(gd, fx, v3, p3, look, calm);
DrawCampFire(sb, calm);
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, _jPlane);
if (night > 0.01f)
{
@@ -291,13 +307,15 @@ namespace GladiatorIdle.Arena
// Tagebuch: Zeilen nach Fortschritt, fest ausgewählt je Reise
int lines = 2 + 2 * away.Duration;
int idx = Math.Min(lines - 1, (int)(k2 * lines));
if (idx != _jLine) { _jLine = idx; _jLineT = 0; }
var order = new int[Adventures.LOG_LINES];
for (int i = 0; i < order.Length; i++) order[i] = i + 1;
new Random(away.Region.GetHashCode() ^ (away.Duration * 7919) ^ (int)(away.Chance * 1000)).Shuffle(order);
if (idx != _jLine) { _jLine = idx; _jLineT = 0; QueueEncounter(order[idx % order.Length]); }
int lineDay = day;
float la = MathHelper.Clamp(_jLineT / 1.2f, 0, 1);
string diary = $"{string.Format(L.t("exp.day"), lineDay)}: {L.t("expedition.log." + order[idx % order.Length])}"; // i18n-ok
int logNo = EncLogShown > 0 ? EncLogShown : order[idx % order.Length];
if (logNo != _jLogShown) { _jLogShown = logNo; _jLineT = 0; }
string diary = $"{string.Format(L.t("exp.day"), lineDay)}: {L.t("expedition.log." + logNo)}"; // i18n-ok
D.Text(sb, Assets.Serif, 28, diary, new Vector2(Camera.W / 2 + 2, 172), Color.Black * (0.7f * la), Align.Center);
D.Text(sb, Assets.Serif, 28, diary, new Vector2(Camera.W / 2, 170), new Color(250, 236, 205) * la, Align.Center);

View File

@@ -472,27 +472,51 @@ namespace GladiatorIdle.Arena
D.Text(sb, Assets.SansBold, 21, value, new Vector2(x + 320, y), Color.White, Align.Right);
}
/// Ludus: Wert zum Üben gewählt (das Spiel startet die Übung).
public Stat? ChosenTraining;
void DrawLudus(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, y = r.Y + 40;
D.Text(sb, Assets.Serif, 30, L.t("main.ludus"), new Vector2(x, y), D.Gold);
y += 40;
// Trainingsplatz: Kraft (Energie) und vier Übungen
int full = (int)_game.TrainEnergy;
for (int i = 0; i < Balance.TRAIN_ENERGY_MAX; i++)
{
var pip = new RectangleF(r.Right - 60 - (Balance.TRAIN_ENERGY_MAX - i) * 34, y + 6, 26, 26);
D.Rect(sb, pip, i < full ? D.Gold : new Color(60, 46, 30));
D.Frame(sb, pip, D.Border, 2);
}
string energy = _game.TrainEnergyNextIn > 0 ? string.Format(L.t("ludus.train.next"), NumberFormat.Duration(_game.TrainEnergyNextIn)) : L.t("ludus.train.full");
D.Text(sb, Assets.Sans, 17, energy, new Vector2(r.Right - 60 - Balance.TRAIN_ENERGY_MAX * 34 - 16, y + 10), D.Sand, Align.Right);
y += 46;
D.TextWrap(sb, Assets.Sans, 18, L.t("ludus.train.intro"), new RectangleF(x, y, r.Width - 60, 50), D.Dim);
y += 50;
float bw = (r.Width - 60 - 3 * 12) / 4;
for (int i = 0; i < 4; i++)
{
var st = (Stat)i;
var b = new RectangleF(x + i * (bw + 12), y, bw, 74);
if (_ui.Button(sb, b, L.t(TextKeys.Of(st)), _game.CanTrain, size: 20, accent: D.Gold) && _game.CanTrain) { ChosenTraining = st; SoundManager.PlayClick(); }
D.Text(sb, Assets.Sans, 15, string.Format(L.t("ludus.train.per"), NumberFormat.Format(_game.TrainXpPerAction(st))), new Vector2(b.Center.X, b.Bottom + 14), D.Dim, Align.Center);
}
y += 112;
foreach (var u in UpgradeDef.All)
{
var row = new RectangleF(x, y, r.Width - 60, 84);
var row = new RectangleF(x, y, r.Width - 60, 72);
D.Rect(sb, row, new Color(30, 22, 15) * 0.9f);
D.Frame(sb, row, D.Border, 2);
if (Assets.Sprite(Art.Upgrade(u)) is Texture2D icon)
sb.Draw(icon, new Vector2(row.X + 42, row.Center.Y), null, Color.White, 0, new Vector2(icon.Width / 2f, icon.Height / 2f), 64f / icon.Width, SpriteEffects.None, 0);
int level = _game.UpgradeLevel(u.Id);
D.Text(sb, Assets.SansBold, 21, L.t(u.Key), new Vector2(row.X + 86, row.Y + 24), Color.White);
D.Text(sb, Assets.Sans, 17, string.Format(L.t("ludus.level"), level), new Vector2(row.X + 86, row.Y + 56), D.Sand);
D.Text(sb, Assets.SansBold, 21, L.t(u.Key), new Vector2(row.X + 86, row.Y + 20), Color.White);
D.Text(sb, Assets.Sans, 17, string.Format(L.t("ludus.level"), level), new Vector2(row.X + 86, row.Y + 50), D.Sand);
string desc = u.Stat is Stat s ? string.Format(L.t("upgrade.trainer.desc"), L.t(TextKeys.Of(s))) : L.t(u.Key + ".desc");
D.TextWrap(sb, Assets.Sans, 17, desc, new RectangleF(row.X + 330, row.Y + 14, row.Width - 330 - 260, 64), D.Dim);
D.TextWrap(sb, Assets.Sans, 17, desc, new RectangleF(row.X + 330, row.Y + 8, row.Width - 330 - 260, 60), D.Dim);
double cost = _game.UpgradeCost(u.Id);
if (_ui.Button(sb, new RectangleF(row.Right - 240, row.Y + 16, 224, 52), string.Format(L.t("btn.buy"), NumberFormat.Format(cost)), _game.Gold >= cost, size: 19))
if (_ui.Button(sb, new RectangleF(row.Right - 240, row.Y + 12, 224, 48), string.Format(L.t("btn.buy"), NumberFormat.Format(cost)), _game.Gold >= cost, size: 19))
if (_game.Buy(u.Id)) SoundManager.PlayPurchase();
y += 92;
y += 78;
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Linq;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
@@ -43,69 +43,88 @@ namespace GladiatorIdle.Arena
public void Draw(SpriteBatch sb, float scale, Vector2 offset)
{
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
// weich einblenden: Hintergrund dunkelt ab, Tafel wächst leicht aus der Mitte
if (!_wasOpen) { _openedAt = Environment.TickCount64; _wasOpen = true; }
float k = MathHelper.Clamp((Environment.TickCount64 - _openedAt) / 220f, 0, 1);
k = 1 - (1 - k) * (1 - k);
var ui = Matrix.CreateTranslation(-Camera.W / 2f, -Camera.H / 2f, 0) * Matrix.CreateScale(0.94f + 0.06f * k)
* Matrix.CreateTranslation(Camera.W / 2f, Camera.H / 2f, 0) * Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
var flat = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, flat);
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * (0.65f * k));
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.6f);
var r = new RectangleF(Camera.W / 2 - 420, 24, 840, 1032);
Ui.Panel(sb, r, D.Gold, 0.97f);
float x = r.X + 50, y = r.Y + 60, w = r.Width - 100;
D.Text(sb, Assets.Serif, 40, L.t("main.settings").ToUpperInvariant(), new Vector2(r.Center.X, y), D.Gold, Align.Center);
// Audio
y += 70;
D.Text(sb, Assets.SansBold, 18, L.t("settings.sec.audio"), new Vector2(x, y), D.Dim);
y += 40;
Volume(sb, x, y, w, L.t("settings.row.music"), () => AppSettings.MusicVolume, v => AppSettings.MusicVolume = v); y += 56;
Volume(sb, x, y, w, L.t("settings.row.sfx"), () => AppSettings.SfxVolume, v => AppSettings.SfxVolume = v); y += 56;
Volume(sb, x, y, w, L.t("settings.vol.voice"), () => AppSettings.VoiceVolume, v => AppSettings.VoiceVolume = v); y += 56;
Toggle(sb, x, y, w, Plain(L.t(AppSettings.Muted ? "settings.muted" : "settings.sound.on")), !AppSettings.Muted,
// breite, flache Tafel in der Bildmitte: links Ton, rechts Anzeige, unten Sprache und Zurück
const float W = 1560, H = 650;
var r = new RectangleF((Camera.W - W) / 2, (Camera.H - H) / 2, W, H);
Ui.Panel(sb, r, D.Gold, 1f);
D.Text(sb, Assets.Serif, 38, L.t("main.settings").ToUpperInvariant(), new Vector2(r.Center.X, r.Y + 52), D.Gold, Align.Center);
D.Rect(sb, new RectangleF(r.Center.X - 160, r.Y + 84, 320, 2), D.Gold * 0.5f);
float colW = (W - 150) / 2, xl = r.X + 50, xr = r.X + 100 + colW, top = r.Y + 130;
D.Rect(sb, new RectangleF(r.Center.X - 1, top - 10, 2, 360), D.Border * 0.8f);
// links: Ton
float y = top;
D.Text(sb, Assets.SansBold, 18, L.t("settings.sec.audio").ToUpperInvariant(), new Vector2(xl, y), D.Dim);
y += 46;
Volume(sb, xl, y, colW, L.t("settings.row.music"), () => AppSettings.MusicVolume, v => AppSettings.MusicVolume = v); y += 54;
Volume(sb, xl, y, colW, L.t("settings.row.sfx"), () => AppSettings.SfxVolume, v => AppSettings.SfxVolume = v); y += 54;
Volume(sb, xl, y, colW, L.t("settings.vol.voice"), () => AppSettings.VoiceVolume, v => AppSettings.VoiceVolume = v); y += 54;
Toggle(sb, xl, y, colW, Plain(L.t(AppSettings.Muted ? "settings.muted" : "settings.sound.on")), !AppSettings.Muted,
() => { AppSettings.Muted = !AppSettings.Muted; if (!AppSettings.Muted) SoundManager.StartAmbient(); });
y += 56;
Toggle(sb, x, y, w, L.t("settings.narration"), AppSettings.Narration, () => AppSettings.Narration = !AppSettings.Narration);
y += 56;
Toggle(sb, x, y, w, L.t("settings.namecalls"), AppSettings.NameCalls, () => AppSettings.NameCalls = !AppSettings.NameCalls);
y += 54;
Toggle(sb, xl, y, colW, L.t("settings.narration"), AppSettings.Narration, () => AppSettings.Narration = !AppSettings.Narration);
y += 54;
Toggle(sb, xl, y, colW, L.t("settings.namecalls"), AppSettings.NameCalls, () => AppSettings.NameCalls = !AppSettings.NameCalls);
// Anzeige
y += 80;
D.Text(sb, Assets.SansBold, 18, L.t("settings.sec.display"), new Vector2(x, y), D.Dim);
y += 40;
Toggle(sb, x, y, w, L.t("settings.fullscreen"), AppSettings.Fullscreen, _toggleFullscreen);
y += 56;
Toggle(sb, x, y, w, L.t("settings.reducemotion"), AppSettings.ReduceMotion, () => AppSettings.ReduceMotion = !AppSettings.ReduceMotion);
y += 56;
Toggle(sb, x, y, w, L.t("settings.antialias"), AppSettings.AntiAlias, () => AppSettings.AntiAlias = !AppSettings.AntiAlias);
y += 56;
Toggle(sb, x, y, w, L.t("settings.bloom"), AppSettings.Bloom, () => AppSettings.Bloom = !AppSettings.Bloom);
y += 56;
D.Text(sb, Assets.Sans, 22, L.t("settings.framerate"), new Vector2(x, y), D.Sand);
// rechts: Anzeige
y = top;
D.Text(sb, Assets.SansBold, 18, L.t("settings.sec.display").ToUpperInvariant(), new Vector2(xr, y), D.Dim);
y += 46;
Toggle(sb, xr, y, colW, L.t("settings.fullscreen"), AppSettings.Fullscreen, _toggleFullscreen);
y += 54;
Toggle(sb, xr, y, colW, L.t("settings.reducemotion"), AppSettings.ReduceMotion, () => AppSettings.ReduceMotion = !AppSettings.ReduceMotion);
y += 54;
Toggle(sb, xr, y, colW, L.t("settings.antialias"), AppSettings.AntiAlias, () => AppSettings.AntiAlias = !AppSettings.AntiAlias);
y += 54;
Toggle(sb, xr, y, colW, L.t("settings.bloom"), AppSettings.Bloom, () => AppSettings.Bloom = !AppSettings.Bloom);
y += 54;
D.Text(sb, Assets.Sans, 22, L.t("settings.framerate"), new Vector2(xr, y), D.Sand);
var rates = new[] { "settings.fps.vsync", "settings.fps.120", "settings.fps.max" };
for (int i = 0; i < rates.Length; i++)
if (_ui.Button(sb, new RectangleF(x + w - 3 * 150 - 20 + i * 160, y - 22, 150, 44), L.t(rates[i]), selected: AppSettings.FrameLimit == i, size: 18)
if (_ui.Button(sb, new RectangleF(xr + colW - 3 * 132 + i * 132, y - 20, 124, 40), L.t(rates[i]), selected: AppSettings.FrameLimit == i, size: 17)
&& AppSettings.FrameLimit != i)
{ AppSettings.FrameLimit = i; Save(); ApplyGraphics(); }
y += 56;
D.Text(sb, Assets.Sans, 22, L.t("settings.row.language"), new Vector2(x, y), D.Sand);
y += 54;
D.Text(sb, Assets.Sans, 22, L.t("settings.row.language"), new Vector2(xr, y), D.Sand);
var langs = new[] { (L.Lang.De, "Deutsch"), (L.Lang.En, "English"), (L.Lang.Es, "Español") }; // i18n-ok
for (int i = 0; i < langs.Length; i++)
{
var (lang, name) = langs[i];
if (_ui.Button(sb, new RectangleF(x + w - 3 * 150 - 20 + i * 160, y - 22, 150, 44), name, selected: L.Current == lang, size: 18))
if (_ui.Button(sb, new RectangleF(xr + colW - 3 * 132 + i * 132, y - 20, 124, 40), name, selected: L.Current == lang, size: 17))
if (L.Current != lang && DevShot.Lang == null) L.Set(lang);
}
y += 70;
// unten: Einführung, Zurück, Hinweis
float by = r.Bottom - 110;
D.Rect(sb, new RectangleF(r.X + 50, by - 24, W - 100, 2), D.Border * 0.8f);
if (Tutorial() is bool seen)
{
D.Text(sb, Assets.Sans, 22, L.t("settings.tutorial"), new Vector2(x, y), D.Sand);
if (_ui.Button(sb, new RectangleF(x + w - 300, y - 22, 300, 44), L.t(seen ? "settings.tutorial.replay" : "settings.tutorial.next"), seen, size: 18))
D.Text(sb, Assets.Sans, 20, L.t("settings.tutorial"), new Vector2(xl, by + 32), D.Sand);
if (_ui.Button(sb, new RectangleF(xl + 260, by + 10, 280, 44), L.t(seen ? "settings.tutorial.replay" : "settings.tutorial.next"), seen, size: 17))
ReplayTutorial();
}
if (_ui.Button(sb, new RectangleF(r.Center.X - 160, r.Bottom - 100, 320, 64), L.t("select.back"), selected: true, size: 26))
if (_ui.Button(sb, new RectangleF(r.Right - 50 - 300, by + 2, 300, 60), L.t("select.back"), selected: true, size: 24))
Open = false;
D.Text(sb, Assets.Sans, 15, $"{Credits.COPYRIGHT} · {Credits.MAIL}", new Vector2(r.Center.X, r.Bottom - 20), D.Dim, Align.Center); // i18n-ok
D.Text(sb, Assets.Sans, 14, $"{Credits.COPYRIGHT} · {Credits.MAIL}", new Vector2(r.Center.X, r.Bottom - 22), D.Dim, Align.Center); // i18n-ok
sb.End();
if (!Open) _wasOpen = false;
}
long _openedAt;
bool _wasOpen;
void Volume(SpriteBatch sb, float x, float y, float w, string label, Func<int> get, Action<int> set)
{
D.Text(sb, Assets.Sans, 22, label, new Vector2(x, y), D.Sand);
@@ -113,7 +132,7 @@ namespace GladiatorIdle.Arena
for (int i = 0; i < steps.Length; i++)
{
int v = steps[i];
var r = new RectangleF(x + w - steps.Length * 86 + i * 86, y - 20, 78, 40);
var r = new RectangleF(x + w - steps.Length * 70 + i * 70, y - 20, 64, 40);
if (_ui.Button(sb, r, v.ToString(NumberFormat.Culture), selected: get() == v, size: 17)) { set(v); Save(); SoundManager.PlayClick(); }
}
}
@@ -121,7 +140,7 @@ namespace GladiatorIdle.Arena
void Toggle(SpriteBatch sb, float x, float y, float w, string label, bool on, Action flip)
{
D.Text(sb, Assets.Sans, 22, label, new Vector2(x, y), D.Sand);
if (_ui.Button(sb, new RectangleF(x + w - 170, y - 20, 170, 40), L.t(on ? "settings.on" : "settings.off"), selected: on, size: 18))
if (_ui.Button(sb, new RectangleF(x + w - 150, y - 20, 150, 40), L.t(on ? "settings.on" : "settings.off"), selected: on, size: 18))
{
flip();
Save();

View File

@@ -37,6 +37,8 @@ namespace GladiatorIdle
static readonly bool DevFreedomRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--freedom") >= 0;
static readonly bool DevChampionRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--champion") >= 0;
static readonly bool DevAdventureRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--adventure") >= 0;
static readonly bool DevJourneyRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--journey") >= 0;
static readonly bool DevTrainRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--train") >= 0;
static readonly bool DevBoardRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--leaderboard") >= 0;
static readonly bool DevTutorialRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--tutorial") >= 0;
static readonly bool DevOathRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--oath") >= 0;
@@ -240,6 +242,17 @@ namespace GladiatorIdle
DevShot.Log($"legend duel vs #{l.Number} {l.Name} ratio={_game.DuelRatio(_enemy):0.00}");
}
/// Ludus: 30-s-Übung für einen Wert gegen den Doctore.
void StartTraining(Stat s)
{
_offer = null; _legend = null;
_enemy = Enemy.Create(0, 0, true);
_before = _hub!.Snapshot();
_scene = new DuelScene(_game!, _enemy, _seed++);
_scene.StartTraining(s);
if (DevShot.Active) _scene.Bot = new DuelBot(0.8, new Random(3));
}
/// Gegner gewählt: Duell beginnt.
void StartDuel(Offer o)
{
@@ -260,7 +273,14 @@ namespace GladiatorIdle
{
bool won = _scene!.Won;
if (_scene.TutorialRan) _game!.TutorialDone = true;
if (_legend is Legend l)
if (_scene.Training is Stat ts)
{
double xp = _game!.Train(ts, _scene.TrainActions);
_hub!.ShowResult(new[] { L.t("ludus.train.done"),
string.Format(L.t("ludus.train.result"), _scene.TrainActions, NumberFormat.Format(xp), L.t(TextKeys.Of(ts))) }, Gfx.Draw.Gold);
SoundManager.PlayLevelUp();
}
else if (_legend is Legend l)
{
bool first = _game!.ResolveLegendDuel(l, won);
_hub!.ShowResult(new[] { L.t(won ? "duel.win" : "duel.lose"),
@@ -424,6 +444,7 @@ namespace GladiatorIdle
if (DevShot.Active) DevHub(dt);
if (_hub?.Chosen is Offer o) { _hub.Chosen = null; StartDuel(o); }
else if (_hub?.ChosenLegend is Legend lg) { _hub.ChosenLegend = null; StartLegendDuel(lg); }
else if (_hub?.ChosenTraining is Stat tr) { _hub.ChosenTraining = null; StartTraining(tr); }
else if (_hub != null && _game!.FreedomEarned && !_settings.Open) StartFreedom();
}
else if (_scene != null)
@@ -549,6 +570,27 @@ namespace GladiatorIdle
if (_devTime > 1.6 && _capture == null && _shots.Contains("w_welcome")) Exit();
return;
}
if (DevTrainRun)
{
// Ludus: Trainingsplatz, eine Übung (Ausdauer: der Doctore greift an), Ergebnis
if (_devTime > 0.6 && _shots.Add("tr_open")) _hub!.DevOpen("ludus");
if (_devTime > 1.4) Shot("tr_ludus");
if (_devTime > 1.8 && _shots.Add("tr_go")) { _hub!.DevOpen("none"); _hub.ChosenTraining = Stat.Endurance; }
if (_devTime > 6) Shot("tr_result");
if (_devTime > 7) Exit();
return;
}
if (DevJourneyRun)
{
// Reise: je eine Begegnung (Kampf, Lager, Fund, Dorf), Aufnahmen alle 1,2 s
if (_devTime > 0.8 && !_shots.Contains("j_go")) { _shots.Add("j_go"); _game!.StartExpedition("gallia", 1); _game.Tick(700); _hub!.DevOpen("journey"); }
int[] logs = { 1, 12, 4, 5 };
for (int i = 0; i < logs.Length; i++)
if (_devTime > 1.5 + i * 14 && _shots.Add($"j_enc{i}")) _hub!.DevEncounter(logs[i]);
for (int i = 0; i < 48; i++) if (_devTime > 2 + i * 1.2 && _shots.Add($"j_{i:00}")) { _capture = $"j_{i:00}"; break; }
if (_devTime > 60) Exit();
return;
}
if (DevAdventureRun)
{
// Expeditionen: Feldzugkarte, Aufbruch, Karte unterwegs, Reise in 3D zu vier Tageszeiten,
@@ -662,6 +704,10 @@ namespace GladiatorIdle
}
if (_scene.Tutorial != DuelScene.TutStep.Off) { Shot("t_" + _scene.Tutorial.ToString().ToLowerInvariant()); }
if (_devTime > 0.5) Shot("m_countdown");
if (_scene.Training != null) { for (int i = 0; i < 9; i++) if (d.Time > 2 + i * 3.5) Shot($"tr_f{i}"); if (_scene.Over) Shot("tr_end"); }
// --ko: Gegner fast besiegt (Aufnahmen vom Liegen am Boden)
if (Array.IndexOf(Environment.GetCommandLineArgs(), "--ko") >= 0 && d.Time > 1 && !d.Over) d.Enemy.Hp = Math.Min(d.Enemy.Hp, 0.01);
if (_scene.Over) for (int i = 0; i < 5; i++) if (_scene.EndTime > 0.6f + i * 0.6f) Shot($"m_down{i}");
if (d.Time > 0.6) Shot("m_fight");
if (d.Enemy.State == DuelState.Windup && d.Enemy.StateTime > d.Enemy.Windup * 0.6) Shot("m_telegraph");
if (d.Player.State == DuelState.Strike) Shot("m_strike");

View File

@@ -206,6 +206,14 @@ namespace GladiatorIdle.Gfx
public Clip? Find(string name) => Clips.Find(c => c.Name == name);
/// Tiefster Punkt der jetzigen Haltung (Modell-Raum, jeder 4. Punkt genügt): liegende Figuren auf den Boden setzen.
public float LowestY()
{
float lo = float.MaxValue;
for (int i = 0; i < Vertices.Length; i += 4) lo = MathF.Min(lo, Vertices[i].Position.Y);
return lo;
}
/// Bewegungen, die mit einer anderen Figur geladen wurden, haben die Hüfte (Wurzel-Knochen) in
/// anderer Höhe oder anderem Maßstab – die Figur schwebt oder versinkt. Je Clip die Wurzel-Bewegung
/// gemeinsam skalieren, sodass ihre Höhe zu den übrigen Clips der Figur passt.
@@ -797,7 +805,7 @@ namespace GladiatorIdle.Gfx
}
else
{
if (kind == "parmula") { W = 40; H = 48; BEND = 0.02f; } // kleiner Schild der Thraker
if (kind == "parmula") { W = 46; H = 56; BEND = 0.014f; } // kleiner Schild der Thraker
// x: Länge (entlang des Arms), y: Breite, z: nach außen (weg vom Arm), gewölbt um die Längsachse
b.Curved(W, H, BEND, face, 1.2f);
b.Rim(W, H, BEND, rim);
@@ -808,7 +816,7 @@ namespace GladiatorIdle.Gfx
var shield = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), across, Vector3.Cross(knuckles, across), centre));
shield.Shield = true; shield.Height = H; shield.Width = W; shield.Bend = BEND;
// Skelett ohne Finger: die Handdrehung passt nach der Übertragung der Bewegungen nicht zuverlässig
shield.Upright = Bone(side + "HandMiddle1") < 0;
shield.Upright = Bone(side + "HandMiddle1") < 0 || kind == "parmula"; // Parmula: aufrecht, die Handdrehung der Thraker-Figur passt nicht
Props.Add(shield);
}
@@ -987,7 +995,7 @@ namespace GladiatorIdle.Gfx
public void Curved(float w, float h, float bend, Color col, float thick)
{
const int NX = 8, NY = 10;
const int NX = 16, NY = 20;
for (int side = 0; side < 2; side++)
for (int i = 0; i < NX; i++)
for (int j = 0; j < NY; j++)
@@ -1002,7 +1010,7 @@ namespace GladiatorIdle.Gfx
public void Rim(float w, float h, float bend, Color col)
{
const int N = 10;
const int N = 24;
for (int j = 0; j < N; j++)
{
float y0 = -w / 2 + w * j / N, y1 = -w / 2 + w * (j + 1) / N;
@@ -1022,7 +1030,7 @@ namespace GladiatorIdle.Gfx
public void Dome(Vector3 c, float r, float hgt, Color col)
{
const int SEG = 12, RING = 4;
const int SEG = 24, RING = 8;
for (int k = 0; k < RING; k++)
for (int s = 0; s < SEG; s++)
{

57
tools/make_levelup.py Normal file
View File

@@ -0,0 +1,57 @@
"""Stufen-Ton (sfx_levelup) ohne Generator: gezupfte Leier (Karplus-Strong) spielt aufsteigend einen
Dur-Dreiklang, dazu ein leiser tiefer Gong und Raumhall. Warm und kurz statt greller Fanfare.
py -3.12 tools/make_levelup.py → Assets/Audio/sfx_levelup.mp3
"""
import os, subprocess, tempfile
import numpy as np
import soundfile as sf
SR = 44100
OUT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "Assets", "Audio", "sfx_levelup.mp3")
rng = np.random.default_rng(7)
def pluck(freq, dur, bright=0.5):
n = int(SR * dur); p = int(SR / freq)
buf = rng.uniform(-1, 1, p) * np.hanning(p)
out = np.zeros(n)
for i in range(n):
out[i] = buf[i % p]
buf[i % p] = 0.5 * (buf[i % p] + buf[(i + 1) % p]) * (0.996 + 0.003 * bright)
return out * np.exp(-np.arange(n) / (SR * dur * 0.45))
def gong(freq, dur):
t = np.arange(int(SR * dur)) / SR
parts = [(1, 1.0), (2.76, 0.4), (5.4, 0.18), (1.5, 0.25)]
s = sum(a * np.sin(2 * np.pi * freq * m * t + rng.uniform(0, 6)) for m, a in parts)
return s * np.exp(-t / 0.7) * (1 - np.exp(-t / 0.004))
def reverb(x, mix=0.25):
y = np.concatenate([x, np.zeros(int(0.9 * SR))]); wet = np.zeros_like(y)
for d, g in ((1557, 0.62), (1617, 0.6), (1491, 0.64), (1422, 0.66)):
buf = np.zeros_like(y)
for i in range(len(y)):
buf[i] = y[i] + (buf[i - d] * g if i >= d else 0)
wet += buf * 0.25
return y * (1 - mix) + wet * mix
notes = [293.66, 369.99, 440.0, 587.33] # D-Dur: D4 Fis4 A4 D5
x = np.zeros(int(SR * 1.6))
for k, f in enumerate(notes):
s = pluck(f, 1.2 - 0.15 * k, bright=0.3 + 0.2 * k) * (0.8 + 0.1 * k)
at = int(SR * 0.075 * k)
x[at:at + len(s)] += s[:len(x) - at]
g = gong(146.83, 1.6) * 0.35
x[:len(g)] += g[:len(x)]
x = reverb(x / np.abs(x).max())
x = x / np.abs(x).max() * 0.8
x[-int(0.3 * SR):] *= np.linspace(1, 0, int(0.3 * SR))
st = np.stack([x, np.concatenate([np.zeros(300), x[:-300]])], axis=1) # leicht breit
with tempfile.TemporaryDirectory() as t:
w = os.path.join(t, "l.wav"); sf.write(w, st.astype(np.float32), SR)
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", w, "-af", "loudnorm=I=-18:TP=-2", "-ar", "44100", "-b:a", "192k", OUT], check=True)
print("ok", OUT)

66
tools/prep_music.py Normal file
View File

@@ -0,0 +1,66 @@
"""Neue Musik (z. B. aus Gemini) fürs Spiel aufbereiten: Stille an den Rändern weg, Lautheit
angleichen, Schleifen-Stücke nahtlos machen (Ende blendet in den Anfang über).
py -3.12 tools/prep_music.py [ordner] Standard: Assets/Audio/music
Liest <ordner>/music_*.mp3, schreibt Assets/Audio/music_*.mp3, verschiebt die Vorlagen nach
_Archiv/Musik-Vorlagen/ (nicht ausgeliefert).
"""
import os, shutil, subprocess, sys, tempfile
import numpy as np
import soundfile as sf
ROOT = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")
SRC = sys.argv[1] if len(sys.argv) > 1 else os.path.join(ROOT, "Assets", "Audio", "music")
DST = os.path.join(ROOT, "Assets", "Audio")
ARCHIVE = os.path.join(ROOT, "_Archiv", "Musik-Vorlagen")
LOOPS = {"music_menu", "music_ludus", "music_arena", "music_champion"}
# Ziel-Lautheit (LUFS): ruhige Stücke leiser, Kampf etwas lauter – passend zu Stimmen und Effekten
TARGET = {"music_ludus": -19, "music_menu": -18, "music_oath": -20, "music_arena": -17, "music_champion": -16.5}
XFADE = 3.0
def decode(p):
with tempfile.TemporaryDirectory() as t:
w = os.path.join(t, "a.wav")
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", p, "-ar", "44100", "-ac", "2", w], check=True)
return sf.read(w, dtype="float32")
def trim(x, sr, thr=10 ** (-45 / 20)):
loud = np.where(np.abs(x).max(axis=1) > thr)[0]
return x[max(0, loud[0] - int(0.02 * sr)):loud[-1] + 1] if len(loud) else x
def loop(x, sr):
"""Ende weich in den Anfang blenden: das Stück endet genau dort, wo es wieder beginnt."""
n = int(XFADE * sr)
head, tail = x[:n], x[-n:]
k = np.linspace(0, 1, n, dtype=np.float32)[:, None]
fade = np.sqrt(1 - k) * tail + np.sqrt(k) * head # gleiche Leistung
return np.concatenate([fade, x[n:-n]])
def main():
os.makedirs(ARCHIVE, exist_ok=True)
for f in sorted(os.listdir(SRC)):
if not (f.startswith("music_") and f.endswith(".mp3")): continue
name = f[:-4]
x, sr = decode(os.path.join(SRC, f))
x = trim(x, sr)
if name in LOOPS: x = loop(x, sr)
else: # einmalige Stücke: kurz ein- und ausblenden
n = int(0.05 * sr); x[:n] *= np.linspace(0, 1, n)[:, None]
m = int(1.5 * sr); x[-m:] *= np.linspace(1, 0, m)[:, None]
with tempfile.TemporaryDirectory() as t:
w = os.path.join(t, "b.wav"); sf.write(w, x, sr)
tgt = TARGET.get(name, -17.5)
subprocess.run(["ffmpeg", "-y", "-loglevel", "error", "-i", w, "-af", f"loudnorm=I={tgt}:TP=-1.5:LRA=11",
"-ar", "44100", "-b:a", "192k", os.path.join(DST, f)], check=True)
shutil.move(os.path.join(SRC, f), os.path.join(ARCHIVE, f))
print(f"{name}: {len(x) / sr:.1f} s, {'Schleife' if name in LOOPS else 'einmal'}, {TARGET.get(name, -17.5)} LUFS")
if not os.listdir(SRC): os.rmdir(SRC)
if __name__ == "__main__":
main()