3D-Arena (Duell, Hub, Freiheit, Erstellung, Bestenliste), Retiarius beidhändig, Waffen je Klasse, Einführung, Willkommen, weniger Reiter, Wirtschaft ohne Taberna, Kantenglättung, Leuchten, weiche Schatten, Gamepad, Absturz-Protokoll

Stand von main 20cd8ba2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 13:24:20 +01:00
parent a08764c505
commit e29db47b20
44 changed files with 2089 additions and 991 deletions

View File

@@ -15,7 +15,10 @@ namespace GladiatorIdle.Arena
/// </summary>
internal sealed partial class HubScene
{
enum Drawer { None, Gladiator, Ludus, Forum, Skills, Hall, Expedition }
enum Drawer { None, Gladiator, Ludus, Expedition, Hall }
/// Seite im Gladiator-Reiter: Werte & Ausrüstung oder Fähigkeiten.
enum Page { Gear, Skills }
Page _page;
readonly GameState _game;
readonly Ui _ui = new();
@@ -23,9 +26,14 @@ namespace GladiatorIdle.Arena
readonly Crowd _crowd = new(11);
readonly FighterView _hero;
readonly DuelFighter _dummy = new() { IsPlayer = true, X = 0, Facing = 1, MaxHp = 1, Hp = 1 };
Texture2D? _backdrop;
string? _loopName;
int _arenaShown = -1;
readonly Stage3D _stage; // dieselbe 3D-Arena wie im Duell
const float HERO_X = 560;
// Gegnerkarten: echte 3D-Figur je Gegner (wie im Duell), in eigene Bildflächen gerendert
readonly Dictionary<string, FighterView> _foeViews = new();
readonly DuelFighter _foeDummy = new() { IsPlayer = false, X = 0, Facing = -1, MaxHp = 1, Hp = 1 };
readonly List<RenderTarget2D> _cardRt = new();
const int CARD_W = 300, CARD_H = 360;
int _cardFrame;
double _t;
Drawer _drawer;
float _drawerK; // 0 zu, 1 offen (gleitet)
@@ -45,6 +53,7 @@ namespace GladiatorIdle.Arena
string hero = Art.Hero(game.Class, game.Look.Preset);
_hero = Assets.Has(hero) ? new FighterView(hero, 0.5f, game.Look.Color) : new FighterView(Art.Fighter(game.Class), 0.5f);
_hero.Preload();
_stage = new Stage3D(game.Arena, AppSettings.ReduceMotion);
_fx.Calm = AppSettings.ReduceMotion;
SoundManager.StartAmbient("music_ludus");
SoundManager.PlayAmbience("amb_crowd");
@@ -56,13 +65,40 @@ namespace GladiatorIdle.Arena
_crowd.Excite(color == D.Gold ? 0.8f : 0.1f);
}
void EnsureArena()
void EnsureArena() => _stage.SetArena(_game.Arena);
FighterView FoeView(Enemy e)
{
if (_arenaShown == _game.Arena) return;
_arenaShown = _game.Arena;
string art = Art.Arena(ArenaDef.All[_game.Arena]);
_backdrop = Assets.Sprite(art, "jpg");
_loopName = AppSettings.ReduceMotion ? null : art;
string art = e.Art ?? Art.Enemy(e.NameKey);
if (!_foeViews.TryGetValue(art, out var v))
_foeViews[art] = v = new FighterView(art, 1.7f, -1, _game.Look.Color == 0 ? 6 : 0);
return v;
}
/// Gegner der Karten in ihre Bildflächen zeichnen (vor allem anderen: Zielwechsel leert das Bild).
void RenderCards(GraphicsDevice gd, BasicEffect fx, float dt)
{
if (_drawerK > 0.98f || Modal || _game.Away != null) return;
// 15 Bilder/s reichen für die ruhige Bereit-Haltung (die Bildflächen behalten ihren Inhalt)
_cardFrame++;
var offers = _game.Offers();
if (_cardFrame % 4 != 0 && _cardRt.Count >= offers.Count) { foreach (var o in offers) FoeView(o.Enemy).Update(dt, dt, _foeDummy, 0, AppSettings.ReduceMotion); return; }
var previous = gd.GetRenderTargets();
for (int i = 0; i < offers.Count; i++)
{
var v = FoeView(offers[i].Enemy);
v.Update(dt, dt, _foeDummy, 0, AppSettings.ReduceMotion);
if (!v.Is3D) continue;
while (_cardRt.Count <= i) _cardRt.Add(new RenderTarget2D(gd, CARD_W, CARD_H, false, SurfaceFormat.Color, DepthFormat.Depth24, 0, RenderTargetUsage.PreserveContents));
gd.SetRenderTarget(_cardRt[i]);
gd.Clear(Color.Transparent);
fx.View = Matrix.CreateTranslation(0, -Stage.FloorY, 0) * Matrix.CreateScale(0.9f) * Matrix.CreateTranslation(CARD_W / 2f, CARD_H - 10, 0);
fx.Projection = Matrix.CreateOrthographicOffCenter(0, CARD_W, CARD_H, 0, 0, 1);
gd.BlendState = BlendState.AlphaBlend; gd.DepthStencilState = DepthStencilState.None; gd.RasterizerState = RasterizerState.CullNone;
v.DrawBody(gd, fx, _foeDummy, true);
}
gd.SetRenderTargets(previous);
gd.Clear(Color.Black);
}
// ── Takt ────────────────────────────────────────────────────
@@ -73,7 +109,9 @@ namespace GladiatorIdle.Arena
_toastAge += dt;
_ui.Begin(input, ui);
_game.Tick(dt); // Training, Einnahmen, Erholung
_hero.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion);
_hero.Update(dt, dt, _dummy, HERO_X, AppSettings.ReduceMotion);
_stage.Cam.Update(dt, Camera.W / 2 - 1800, Camera.W / 2 + 1800, AppSettings.ReduceMotion); // weiter weg, ruhige Drift
_lastDt = dt;
UpdateAdventure();
_crowd.Update(dt);
_fx.Motes(AppSettings.ReduceMotion ? 0 : 50, Camera.W, Camera.H);
@@ -85,12 +123,15 @@ namespace GladiatorIdle.Arena
}
public bool DrawerOpen => _drawer != Drawer.None;
float _lastDt = 1 / 60f;
/// Testlauf: Schublade öffnen (0 zu, 1 Gladiator, 2 Ludus), sofort ganz offen.
public void DevOpen(int d)
/// Testlauf: Schublade öffnen ("none", "gladiator", "skills", "ludus", "expedition", "hall"), sofort ganz offen.
public void DevOpen(string d)
{
_drawer = (Drawer)d; _drawerK = d == 0 ? 0 : 1;
if (d == 1 && _game.Inventory.Count > 0) _sel = _game.Inventory[0].Id;
_drawer = d switch { "gladiator" or "skills" => Drawer.Gladiator, "ludus" => Drawer.Ludus, "expedition" => Drawer.Expedition, "hall" => Drawer.Hall, _ => Drawer.None };
_page = d == "skills" ? Page.Skills : Page.Gear;
_drawerK = _drawer == Drawer.None ? 0 : 1;
if (d == "gladiator" && _game.Inventory.Count > 0) _sel = _game.Inventory[0].Id;
}
// ── Zeichnen ────────────────────────────────────────────────
@@ -101,35 +142,23 @@ namespace GladiatorIdle.Arena
D.UiScale = scale;
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
// Arena im Hintergrund
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
var loop = _loopName != null ? ClipCache.Video(_loopName) : null; // Standbild, bis der Film geladen ist
var bg = loop != null ? loop[PingPong(_t * 8, loop.Length)] : _backdrop;
if (bg != null)
{
float k = 1.12f * MathF.Max(Camera.W / bg.Width, Camera.H / bg.Height);
sb.Draw(bg, new Vector2(Camera.W / 2, Camera.H / 2), null, new Color(0.55f, 0.51f, 0.47f), 0,
new Vector2(bg.Width / 2f, bg.Height / 2f), k, SpriteEffects.None, 0);
}
D.Glow(sb, new Vector2(-200, Camera.H / 2), new Vector2(900, 2000), Color.Black * 0.7f);
D.Glow(sb, new Vector2(Camera.W + 200, Camera.H / 2), new Vector2(900, 2000), Color.Black * 0.6f);
D.Rect(sb, new RectangleF(0, 0, Camera.W, 120), Color.Black * 0.45f);
sb.End();
// Gladiator (links, in der Arena), Licht, Schatten
var view = Matrix.CreateTranslation(0, -Stage.FloorY, 0) * Matrix.CreateScale(1.1f) * Matrix.CreateTranslation(520, 930, 0) * ui;
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, view);
D.Glow(sb, new Vector2(0, Stage.FloorY - 300), new Vector2(1000, 1100), new Color(255, 190, 120) * 0.14f);
D.Glow(sb, new Vector2(0, Stage.FloorY + 6), new Vector2(760, 130), new Color(255, 180, 110) * 0.22f);
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, view);
_hero.DrawShadow(sb);
sb.End();
fx.View = view;
fx.Projection = Matrix.CreateOrthographicOffCenter(0, gd.Viewport.Width, gd.Viewport.Height, 0, 0, 1);
gd.BlendState = BlendState.AlphaBlend; gd.SamplerStates[0] = SamplerState.LinearClamp;
gd.RasterizerState = RasterizerState.CullNone; gd.DepthStencilState = DepthStencilState.None;
var sw = System.Diagnostics.Stopwatch.StartNew();
RenderCards(gd, fx, _lastDt);
double tCards = sw.Elapsed.TotalMilliseconds;
// Arena in 3D wie im Duell: Sand, Mauer, Ränge, Licht; der Gladiator steht mit Schatten darin
_stage.Prepare(gd, scale, offset);
_stage.DrawSet(gd, sb, _t, _crowd.Excitement);
_stage.Shadows(gd, sb, 0, _hero);
_stage.FloorLight(sb, HERO_X, 900, 0.18f);
Stage3D.BeginFigures(gd);
_stage.Use(_hero);
_hero.DrawBody(gd, fx, _dummy, AppSettings.ReduceMotion);
double tStage = sw.Elapsed.TotalMilliseconds;
// oben dunkler Verlauf hinter der Kopfleiste
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
D.Glow(sb, new Vector2(-200, Camera.H / 2), new Vector2(900, 2000), Color.Black * 0.55f);
D.Glow(sb, new Vector2(Camera.W + 200, Camera.H / 2), new Vector2(900, 2000), Color.Black * 0.45f);
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui * Matrix.Identity);
_crowd.Draw(sb, AppSettings.ReduceMotion);
@@ -150,7 +179,11 @@ namespace GladiatorIdle.Arena
if (_drawerK > 0.01f) DrawDrawer(sb);
}
sb.End();
// Profil (nur Testlauf --perf): Anteile der Hub-Zeichenzeit
if (DevShot.Active && ++_profN % 120 == 0)
DevShot.Log($"hub profile: cards {tCards:0.00} ms, stage {tStage - tCards:0.00} ms, ui {sw.Elapsed.TotalMilliseconds - tStage:0.00} ms, drawer {_drawerK:0.0}");
}
int _profN;
static int PingPong(double t, int n)
{
@@ -177,8 +210,6 @@ namespace GladiatorIdle.Arena
if (Assets.Sprite("icon_denarius") is Texture2D coin)
sb.Draw(coin, new Vector2(gx, 60), null, Color.White, 0, new Vector2(coin.Width / 2f, coin.Height / 2f), 52f / coin.Width, SpriteEffects.None, 0);
D.Text(sb, Assets.SansBold, 30, NumberFormat.Format(_game.Gold), new Vector2(gx + 36, 52), Color.White);
if (_game.GoldPerSec > 0)
D.Text(sb, Assets.Sans, 17, string.Format(L.t("res.persec"), NumberFormat.Small(_game.GoldPerSec)), new Vector2(gx + 36, 86), D.Sand);
// Arena, Rang, Ruhm bis zum Champion
float rx = Camera.W - 40;
@@ -207,9 +238,16 @@ namespace GladiatorIdle.Arena
if (champ) D.Glow(sb, r.Center, new Vector2(w * 1.6f, h * 1.2f), D.Gold * (0.08f + 0.04f * MathF.Sin((float)_t * 3)));
D.Text(sb, Assets.SansBold, 18, L.t(o.Key).ToUpperInvariant(), new Vector2(r.Center.X, r.Y + 24), accent, Align.Center);
// Gegner
// Gegner: 3D-Figur wie im Duell (sonst das Bild)
string art = o.Enemy.Art ?? Art.Enemy(o.Enemy.NameKey);
if (Assets.Sprite(art) is Texture2D t)
if (i < _cardRt.Count && FoeView(o.Enemy).Is3D)
{
var rt = _cardRt[i];
float k = 330f / CARD_H;
D.Glow(sb, new Vector2(r.Center.X, r.Y + 352), new Vector2(w * 0.9f, 40), Color.Black * 0.5f);
sb.Draw(rt, new Vector2(r.Center.X, r.Y + 352), null, Color.White, 0, new Vector2(CARD_W / 2f, CARD_H - 10), k, SpriteEffects.None, 0);
}
else if (Assets.Sprite(art) is Texture2D t)
{
float k = 300f / t.Height;
sb.Draw(t, new Vector2(r.Center.X, r.Y + 350), null, Color.White, 0, new Vector2(t.Width / 2f, Stage.Feet), k * 1.0f, SpriteEffects.FlipHorizontally, 0);
@@ -228,18 +266,10 @@ namespace GladiatorIdle.Arena
Line(sb, r, ly + 26, L.t("res.fame"), "+" + NumberFormat.Format(fame));
Line(sb, r, ly + 52, "XP", "+" + NumberFormat.Format(xp)); // i18n-ok
// Knöpfe
bool auto = _game.CanAutoWin(o);
var fb = new RectangleF(r.X + 16, r.Bottom - (auto ? 112 : 62), r.Width - 32, 48);
// Knopf
var fb = new RectangleF(r.X + 16, r.Bottom - 62, r.Width - 32, 48);
if (_ui.Button(sb, fb, L.t(champ ? "arena.challenge" : "hub.fight"), canFight, selected: champ, size: champ ? 18 : 22, accent: accent))
Chosen = o;
if (auto && _ui.Button(sb, new RectangleF(r.X + 16, r.Bottom - 58, r.Width - 32, 42), L.t("hub.auto"), canFight, size: 17))
{
var before = Snapshot();
_game.AutoWin(o);
ShowResult(ResultLines(before, true), D.Gold);
SoundManager.PlayCoins();
}
}
if (!canFight && _game.Recovery > 0)
{
@@ -289,29 +319,40 @@ namespace GladiatorIdle.Arena
// ── Schubladen ──────────────────────────────────────────────
/// Ehrenhalle erst, wenn es dort etwas gibt (nach der ersten Freiheit).
bool HallOpen => _game.Freedoms > 0 || _game.Legends.Count > 0;
void DrawDrawerButtons(SpriteBatch sb)
{
float y = Camera.H - 92;
string gl = _game.AttrPoints > 0 ? $"{L.t("ludus.gladiator")} ({_game.AttrPoints})" : L.t("ludus.gladiator");
if (_ui.Button(sb, new RectangleF(40, y, 230, 60), gl, selected: _drawer == Drawer.Gladiator, size: 22,
accent: _game.AttrPoints > 0 ? D.Gold : null))
_drawer = _drawer == Drawer.Gladiator ? Drawer.None : Drawer.Gladiator;
if (_ui.Button(sb, new RectangleF(286, y, 230, 60), L.t("main.ludus"), selected: _drawer == Drawer.Ludus, size: 22))
_drawer = _drawer == Drawer.Ludus ? Drawer.None : Drawer.Ludus;
if (_ui.Button(sb, new RectangleF(532, y, 230, 60), L.t("main.shop"), selected: _drawer == Drawer.Forum, size: 22))
_drawer = _drawer == Drawer.Forum ? Drawer.None : Drawer.Forum;
int sp = _game.LearnablePoints;
string sk = sp > 0 ? $"{L.t("char.skills")} ({sp})" : L.t("char.skills");
if (_ui.Button(sb, new RectangleF(778, y, 230, 60), sk, selected: _drawer == Drawer.Skills, size: 22, accent: sp > 0 ? D.Gold : null))
_drawer = _drawer == Drawer.Skills ? Drawer.None : Drawer.Skills;
int open = _game.Legends.Count(l => !_game.LegendsBeaten.Contains(l.Number));
if (_ui.Button(sb, new RectangleF(1024, y, 230, 60), string.Format(L.t("hall.button"), _game.Legends.Count), selected: _drawer == Drawer.Hall,
size: 22, accent: open > 0 || _game.GodFavor > 0 ? D.Purple : null))
_drawer = _drawer == Drawer.Hall ? Drawer.None : Drawer.Hall;
float y = Camera.H - 92, x = 40;
bool Tab(string text, Drawer d, float w, Color? accent = null)
{
bool hit = _ui.Button(sb, new RectangleF(x, y, w, 60), text, selected: _drawer == d, size: 22, accent: accent);
x += w + 16;
return hit;
}
// Gladiator: freie Attribut- und Fähigkeitspunkte zusammen
int pts = _game.AttrPoints + _game.LearnablePoints;
if (Tab(pts > 0 ? $"{L.t("ludus.gladiator")} ({pts})" : L.t("ludus.gladiator"), Drawer.Gladiator, 260, pts > 0 ? D.Gold : null)) // i18n-ok
{
if (_drawer == Drawer.Gladiator) _drawer = Drawer.None;
else
{
_drawer = Drawer.Gladiator;
// offene Punkte: gleich die passende Seite
if (_game.AttrPoints == 0 && _game.LearnablePoints > 0) _page = Page.Skills;
else if (_game.AttrPoints > 0) _page = Page.Gear;
}
}
if (Tab(L.t("main.ludus"), Drawer.Ludus, 260)) _drawer = _drawer == Drawer.Ludus ? Drawer.None : Drawer.Ludus;
string ex = _game.Away != null ? $"{L.t("exp.button")} · {NumberFormat.Duration(_game.Away.Left)}" : L.t("exp.button"); // i18n-ok
if (_ui.Button(sb, new RectangleF(1270, y, 300, 60), ex, selected: _drawer == Drawer.Expedition, size: 22,
accent: _game.Away != null ? D.Gold : null))
_drawer = _drawer == Drawer.Expedition ? Drawer.None : Drawer.Expedition;
if (Tab(ex, Drawer.Expedition, 300, _game.Away != null ? D.Gold : null)) _drawer = _drawer == Drawer.Expedition ? Drawer.None : Drawer.Expedition;
if (HallOpen)
{
int open = _game.Legends.Count(l => !_game.LegendsBeaten.Contains(l.Number));
if (Tab(string.Format(L.t("hall.button"), _game.Legends.Count), Drawer.Hall, 300, open > 0 || _game.GodFavor > 0 ? D.Purple : null))
_drawer = _drawer == Drawer.Hall ? Drawer.None : Drawer.Hall;
}
}
void DrawDrawer(SpriteBatch sb)
@@ -322,10 +363,17 @@ namespace GladiatorIdle.Arena
var r = new RectangleF(x, 140, W, Camera.H - 260);
Ui.Panel(sb, r, D.Gold, 0.94f);
DrawGuide(sb, new RectangleF(r.Right + 20, r.Y, GUIDE, r.Height));
if (_drawer == Drawer.Gladiator) DrawGladiator(sb, r);
if (_drawer == Drawer.Gladiator)
{
// zwei Seiten: Werte & Ausrüstung | Fähigkeiten
int sp = _game.LearnablePoints;
if (_ui.Button(sb, new RectangleF(r.X + 30, r.Y + 20, 300, 50), L.t("char.page.gear"), selected: _page == Page.Gear, size: 21,
accent: _game.AttrPoints > 0 ? D.Gold : null)) _page = Page.Gear;
if (_ui.Button(sb, new RectangleF(r.X + 342, r.Y + 20, 300, 50), sp > 0 ? $"{L.t("char.skills")} ({sp})" : L.t("char.skills"), // i18n-ok
selected: _page == Page.Skills, size: 21, accent: sp > 0 ? D.Gold : null)) _page = Page.Skills;
if (_page == Page.Skills) DrawSkills(sb, r); else DrawGladiator(sb, r);
}
else if (_drawer == Drawer.Ludus) DrawLudus(sb, r);
else if (_drawer == Drawer.Forum) DrawForum(sb, r);
else if (_drawer == Drawer.Skills) DrawSkills(sb, r);
else if (_drawer == Drawer.Hall) DrawHall(sb, r);
else if (_drawer == Drawer.Expedition) DrawExpeditions(sb, r);
}
@@ -334,13 +382,11 @@ namespace GladiatorIdle.Arena
void DrawGladiator(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, y = r.Y + 40;
D.Text(sb, Assets.Serif, 30, $"{_game.Name} · {L.t(_game.ClassDef.Key)}", new Vector2(x, y), D.Gold);
D.Text(sb, Assets.SansBold, 20, string.Format(L.t("char.power"), NumberFormat.Format(_game.Power())), new Vector2(x + 700, y), D.Sand, Align.Right);
float x = r.X + 30, y = r.Y + 100;
// Werte mit Attributpunkten
y += 50;
// Werte mit Attributpunkten, Kampfkraft rechts in derselben Zeile
D.Text(sb, Assets.SansBold, 20, string.Format(L.t("char.points"), _game.AttrPoints), new Vector2(x, y), _game.AttrPoints > 0 ? D.Gold : D.Dim);
D.Text(sb, Assets.SansBold, 20, string.Format(L.t("char.power"), NumberFormat.Format(_game.Power())), new Vector2(x + 700, y), D.Sand, Align.Right);
for (int i = 0; i < 4; i++)
{
var s = (Stat)i;
@@ -373,10 +419,19 @@ namespace GladiatorIdle.Arena
D.Frame(sb, row, it == null ? D.Border : RarityColor(it.Rarity), 2);
if (it != null && Assets.Sprite(it.Def.Icon) is Texture2D icon)
sb.Draw(icon, new Vector2(row.X + 36, row.Center.Y), null, Color.White, 0, new Vector2(icon.Width / 2f, icon.Height / 2f), 56f / icon.Width, SpriteEffects.None, 0);
D.Text(sb, Assets.Sans, 16, L.t("slot." + slot.ToString().ToLowerInvariant()), new Vector2(row.X + 76, row.Y + 18), D.Dim);
string slotText = L.t("slot." + slot.ToString().ToLowerInvariant());
if (_game.SlotLevels[i] > 0) slotText += " · " + string.Format(L.t("forge.level"), _game.SlotLevels[i]); // i18n-ok
D.Text(sb, Assets.Sans, 16, slotText, new Vector2(row.X + 76, row.Y + 18), D.Dim);
D.Text(sb, Assets.SansBold, 20, it == null ? "–" : ItemName(it), new Vector2(row.X + 76, row.Y + 44), it == null ? D.Dim : RarityColor(it.Rarity)); // i18n-ok
if (it != null && _sel == it.Id) D.Frame(sb, row, Color.White, 3);
if (it != null && _ui.Hit(row)) _sel = it.Id;
// Schmied: diesen Platz verstärken (gilt für jedes Stück, das hier liegt)
double cost = _game.UpgradeSlotCost(slot);
var fr = new RectangleF(row.Right - 214, row.Y + 11, 200, 44);
if (_ui.Button(sb, fr, string.Format(L.t("btn.forge"), NumberFormat.Format(cost)), _game.Gold >= cost, size: 17))
{
if (_game.UpgradeSlot(slot)) SoundManager.PlayLevelUp();
}
else if (it != null && !fr.Contains(_ui.Mouse) && _ui.Hit(row)) _sel = it.Id;
}
DrawInventory(sb, new RectangleF(r.X + 790, r.Y + 30, 430, r.Height - 60));
}