Feldzugkarte, Reise in 3D, Kampfstile der Gegner, Missio, inszenierte Heimkehr

Stand von main 8c62f0dd.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 16:13:28 +01:00
parent 35a5ac5032
commit 9c433c61ba
33 changed files with 1265 additions and 131 deletions

View File

@@ -4,6 +4,7 @@ using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
using Part = GladiatorIdle.Gfx.Mesh3D;
namespace GladiatorIdle.Arena
{
@@ -56,56 +57,6 @@ namespace GladiatorIdle.Arena
const float ROW_H = 64, ROW_D = 118, COL_H = 330;
static float Floor => Stage.FloorY;
sealed class Part
{
public readonly List<VertexPNCT> V = new();
public readonly List<int> I = new();
public Texture2D? Tex;
public bool Lit = true, Wrap, Mirror, Fog = true;
public Vector3 Tint = Vector3.One;
public VertexPNCT[]? VA; public int[]? IA;
public void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 n, Color col,
Vector2 ta, Vector2 tb, Vector2 tc, Vector2 td)
{
int i = V.Count;
V.Add(new VertexPNCT { Position = a, Normal = n, Color = col, Uv = ta });
V.Add(new VertexPNCT { Position = b, Normal = n, Color = col, Uv = tb });
V.Add(new VertexPNCT { Position = c, Normal = n, Color = col, Uv = tc });
V.Add(new VertexPNCT { Position = d, Normal = n, Color = col, Uv = td });
I.AddRange(new[] { i, i + 1, i + 2, i, i + 2, i + 3 });
}
/// Quader (achsengerade), Mitte c, Größe s.
public void Box(Vector3 c, Vector3 s, Color col)
{
var h = s / 2;
Vector3 P(float x, float y, float z) => c + new Vector3(x * h.X, y * h.Y, z * h.Z);
var z0 = Vector2.Zero;
Quad(P(-1, -1, 1), P(1, -1, 1), P(1, 1, 1), P(-1, 1, 1), Vector3.UnitZ, col, z0, z0, z0, z0);
Quad(P(1, -1, -1), P(-1, -1, -1), P(-1, 1, -1), P(1, 1, -1), -Vector3.UnitZ, col, z0, z0, z0, z0);
Quad(P(-1, -1, -1), P(-1, -1, 1), P(-1, 1, 1), P(-1, 1, -1), -Vector3.UnitX, col, z0, z0, z0, z0);
Quad(P(1, -1, 1), P(1, -1, -1), P(1, 1, -1), P(1, 1, 1), Vector3.UnitX, col, z0, z0, z0, z0);
Quad(P(-1, -1, -1), P(1, -1, -1), P(1, -1, 1), P(-1, -1, 1), -Vector3.UnitY, col, z0, z0, z0, z0);
}
/// Senkrechter Zylinder (Becken, Pfosten): Mitte unten c, Radius r, Höhe h (nach oben = −y).
public void Cylinder(Vector3 c, float r, float h, Color col, int seg = 12, float rTop = -1)
{
if (rTop < 0) rTop = r;
var z0 = Vector2.Zero;
for (int i = 0; i < seg; i++)
{
float a0 = MathF.Tau * i / seg, a1 = MathF.Tau * (i + 1) / seg;
Vector3 Pt(float a, float rad, float y) => c + new Vector3(MathF.Cos(a) * rad, y, MathF.Sin(a) * rad);
var n = new Vector3(MathF.Cos((a0 + a1) / 2), 0, MathF.Sin((a0 + a1) / 2));
Quad(Pt(a0, r, 0), Pt(a1, r, 0), Pt(a1, rTop, -h), Pt(a0, rTop, -h), n, col, z0, z0, z0, z0);
Quad(Pt(a0, rTop, -h), Pt(a1, rTop, -h), c + new Vector3(0, -h, 0), c + new Vector3(0, -h, 0), -Vector3.UnitY, col, z0, z0, z0, z0);
}
}
public void Freeze() { VA = V.ToArray(); IA = I.ToArray(); }
}
readonly ArenaLook _look;
readonly List<Part> _parts = new();

View File

@@ -21,6 +21,10 @@ namespace GladiatorIdle.Arena
/// Nach dem Kampf: langsam auf den Sieger zufahren (null = wieder beide zeigen).
public float? FocusX;
/// Reise-Ansicht: der Figur frei folgen (keine Begrenzung auf die Arena-Mitte).
public float? FollowX;
public float FollowZoom = 1f;
public void Punch(float amount, Vector2 at) { _punch = MathF.Max(_punch, amount); _punchAt = at; }
/// Ziel: Mitte zwischen den Kämpfern, je näher, desto enger.
@@ -32,6 +36,7 @@ namespace GladiatorIdle.Arena
var target = new Vector2(MathHelper.Clamp(mid, W / 2 - 220, W / 2 + 220), H / 2 + 40);
float k = 1 - MathF.Exp(-dt * 3.5f);
if (FocusX is float fx) { targetZoom = 1.4f; target = new Vector2(fx, H / 2 + 30); k = 1 - MathF.Exp(-dt * 1.2f); }
if (FollowX is float fw) { targetZoom = FollowZoom; target = new Vector2(fw, H / 2 + 40); k = 1 - MathF.Exp(-dt * 4f); } // Reise: ohne Begrenzung
Center += (target - Center) * k;
Zoom += (targetZoom - Zoom) * k;
_trauma = MathF.Max(0, _trauma - dt * 1.7f);

View File

@@ -80,7 +80,20 @@ namespace GladiatorIdle.Arena
int _countShown = -1;
public bool Paused;
public bool Won { get; private set; }
public bool Finished => _phase == Phase.End && _phaseTime > 1.2f;
public bool Finished => _phase == Phase.End && (_missio ? _decidedAt >= 0 && _missioT - _decidedAt > 1.8f : _phaseTime > 1.2f);
// ── Gnadenstoß (Missio): das Publikum stimmt ab, der Sieger wählt ──
readonly Ui _ui = new();
bool _missio; float _missioT, _voteK = 0.5f, _decidedAt = -1, _chantIn;
bool _crowdMercy;
bool? _mercy, _spared;
sealed class Chant { public string Text = ""; public Vector2 Pos; public float Age; public Color Color; }
readonly List<Chant> _chants = new();
/// Ergebnis für das Spiel: Wahl des Siegers, Wunsch des Publikums; nach einer Niederlage: verschont?
public bool? MercyChosen => _mercy;
public bool CrowdMercy => _crowdMercy;
public bool? Spared => _spared;
public float MissioTime => _missio ? _missioT : -1;
public bool Over => _phase == Phase.End;
sealed class Floater { public string Text = ""; public Vector2 Pos; public Color Color; public float Size, Age, Life = 1.1f; public bool Big; }
@@ -184,6 +197,7 @@ namespace GladiatorIdle.Arena
var pc = game.PlayerCombat();
Duel = new Duel(pc.MaxHp, pc.Crit, game.ClassDef.Special, enemy.Hp, game.DuelRatio(enemy), enemy.IsChampion,
game.Equipped[(int)ItemSlot.Weapon]?.Base == "trident", new Random(seed), game.Perks);
Duel.SetStyle(Duel.StyleOf(enemy.Art ?? Art.Enemy(enemy.NameKey), enemy.IsChampion)); // Kampfstil des Gegners
// eigener Gladiator: Vorlage in Teamfarbe (sonst das Klassenbild)
string hero = Art.Hero(game.Class, game.Look.Preset);
_pv = Assets.Has(hero) ? new FighterView(hero, 0, game.Look.Color) : new FighterView(Art.Fighter(game.Class), 0, -1, game.Look.Color);
@@ -220,8 +234,9 @@ namespace GladiatorIdle.Arena
// ── Takt ────────────────────────────────────────────────────
public void Update(float realDt, Input input)
public void Update(float realDt, Input input, Matrix ui)
{
_ui.Begin(input, ui);
if (Paused) return;
_time += realDt;
// Trefferstopp friert die Kämpfer kurz ein, Zeitlupe verlangsamt das Ende
@@ -258,6 +273,10 @@ namespace GladiatorIdle.Arena
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;
_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;
if (!_calm) _cam.HoldYaw(Won ? 24 : -24); // langsame Fahrt um den Sieger
if (Won) SoundManager.PlayVictory(); else SoundManager.PlayDefeat();
@@ -266,6 +285,7 @@ namespace GladiatorIdle.Arena
case Phase.End:
Duel.Step(dt);
HandleEvents();
if (_missio) MissioUpdate(realDt, input);
break;
}
@@ -469,6 +489,13 @@ namespace GladiatorIdle.Arena
Big(L.t(TextKeys.Of(Duel.PlayerSpecial)), D.Blue);
SoundManager.PlayCheer();
break;
case DuelEventType.Charge:
Big(L.t("duel.charge"), new Color(255, 90, 60));
_cam.Shake(0.25f);
if (!_calm) _cam.Pulse(-6, 0.8f);
SoundManager.PlayWhoosh();
_crowd.Excite(0.3f);
break;
case DuelEventType.Leap:
_fx.Dust(new Vector2(_pv.X, Stage.FloorY), 10, 90, 50, 70);
if (!_calm) { _cam.Lift(140); _cam.Pulse(10f * (float)Duel.Player.Facing, 1.0f); } // Kamera steigt mit
@@ -608,7 +635,7 @@ namespace GladiatorIdle.Arena
if (e.State == DuelState.Windup) // fair: der Schlag kündigt sich rot an
{
float k = (float)Math.Min(1, e.StateTime / e.Windup);
_ev.DrawAura(gd, fx, new Color(255, 60, 40) * (0.55f * k), 0.035f * k);
_ev.DrawAura(gd, fx, new Color(255, 60, 40) * ((e.Heavy ? 0.85f : 0.55f) * k), (e.Heavy ? 0.075f : 0.035f) * k);
}
if (p.State == DuelState.Wall || p.Invulnerable > 0) _pv.DrawAura(gd, fx, D.Blue * 0.5f, 0.03f);
if (p.Heavy && p.State == DuelState.Windup) _pv.DrawAura(gd, fx, new Color(255, 150, 40) * 0.6f, 0.035f);
@@ -768,12 +795,20 @@ namespace GladiatorIdle.Arena
D.Text(sb, Assets.SansBold, 28, 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 (_phase == Phase.End)
if (_phase == Phase.End && _missio && _decidedAt < 0) DrawMissio(sb);
else if (_phase == Phase.End)
{
float k = MathHelper.Clamp(_phaseTime / 0.6f, 0, 1);
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),
(Won ? D.Gold : D.Red) * k, Align.Center, 1 + 0.4f * (1 - k));
if (_missio)
{
string line = Won ? L.t(_mercy == _crowdMercy ? "missio.react.cheer" : "missio.react.boo")
: L.t(_spared == true ? "missio.spared" : "missio.doomed");
D.Text(sb, Assets.Serif, 30, line, new Vector2(Camera.W / 2, 520), Color.White * k, Align.Center);
}
if (Finished)
D.Text(sb, Assets.SansBold, 30, L.t("mono.next"), new Vector2(Camera.W / 2, 600), Color.White, Align.Center);
}
@@ -785,6 +820,102 @@ namespace GladiatorIdle.Arena
}
}
// ── Gnadenstoß ──────────────────────────────────────────────
void MissioUpdate(float realDt, Input input)
{
_missioT += realDt;
bool wantMercy = Won ? _crowdMercy : _spared == true;
float target = wantMercy ? 0.12f : 0.88f;
// Abstimmung: die Stimmung schwankt und kippt dann zum Wunsch der Menge
if (_missioT > 0.9f && _decidedAt < 0)
{
float k = MathHelper.Clamp((_missioT - 0.9f) / 2.0f, 0, 1);
float wobble = (1 - k) * 0.25f * MathF.Sin(_missioT * 7.3f) * MathF.Sin(_missioT * 3.1f);
_voteK = MathHelper.Lerp(0.5f, target, k * k) + wobble;
if (!_calm && (_chantIn -= realDt) <= 0)
{
_chantIn = 0.11f;
bool mercyChant = Random.Shared.NextDouble() < (1 - _voteK);
_chants.Add(new Chant
{
Text = L.t(mercyChant ? "missio.mitte" : "missio.iugula"),
Pos = new Vector2(80 + (float)Random.Shared.NextDouble() * (Camera.W - 160), 960 + (float)Random.Shared.NextDouble() * 60),
Color = mercyChant ? D.Gold : new Color(255, 110, 70),
});
_crowd.Excite(0.08f);
}
}
for (int i = _chants.Count - 1; i >= 0; i--)
{
_chants[i].Age += realDt;
_chants[i].Pos.Y -= 90 * realDt;
if (_chants[i].Age > 1.6f) _chants.RemoveAt(i);
}
if (_decidedAt >= 0) return;
if (!Won)
{
if (_missioT >= 3.0f) Decide(_spared == true);
return;
}
if (_missioT < 3.0f) return;
// Wahl des Siegers: Knöpfe, Tasten 1/2, Gamepad X/Y; Testlauf und Zeitablauf: Wunsch der Menge
if (input.Pressed(Keys.D1) || input.Pressed(Keys.NumPad1) || input.PadPressed(Buttons.X)) Decide(true);
else if (input.Pressed(Keys.D2) || input.Pressed(Keys.NumPad2) || input.PadPressed(Buttons.Y)) Decide(false);
else if (Bot != null && _missioT > 3.8f) Decide(_crowdMercy);
else if (_missioT > 9.5f) Decide(_crowdMercy);
}
void Decide(bool mercy)
{
if (_decidedAt >= 0) return;
_decidedAt = _missioT;
if (!Won) { if (mercy) SoundManager.PlayCheer(); else SoundManager.PlayBoo(); return; }
_mercy = mercy;
bool match = mercy == _crowdMercy;
if (match) { _crowd.Wave(); SoundManager.PlayCheer(); } 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));
}
void DrawMissio(SpriteBatch sb)
{
float a = MathHelper.Clamp(_missioT / 0.6f, 0, 1);
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * (0.32f * a));
D.Text(sb, Assets.Serif, 120, L.t("missio.title"), new Vector2(Camera.W / 2, 240), D.Gold * a, Align.Center);
D.Text(sb, Assets.Serif, 30, L.t(Won ? "missio.crowd" : "missio.crowd.you"), new Vector2(Camera.W / 2, 330), D.Sand * a, Align.Center);
// Stimmungsleiste: links Gnade (Mitte!), rechts Ende (Iugula!)
var bar = new RectangleF(Camera.W / 2 - 460, 410, 920, 26);
D.Rect(sb, bar, new Color(20, 14, 10) * (0.9f * a));
D.Rect(sb, new RectangleF(bar.X, bar.Y, bar.Width * (1 - _voteK), bar.Height), D.Gold * (0.75f * a));
D.Rect(sb, new RectangleF(bar.X + bar.Width * (1 - _voteK), bar.Y, bar.Width * _voteK, bar.Height), new Color(200, 70, 50) * (0.75f * a));
D.Frame(sb, bar, D.Border * a, 2);
float mx = bar.X + bar.Width * (1 - _voteK);
D.Glow(sb, new Vector2(mx, bar.Center.Y), new Vector2(60, 90), Color.White * (0.8f * a));
D.Text(sb, Assets.Serif, 34, L.t("missio.mitte"), new Vector2(bar.X, bar.Y - 30), D.Gold * a);
D.Text(sb, Assets.Sans, 18, L.t("missio.mitte.hint"), new Vector2(bar.X, bar.Bottom + 24), D.Sand * a);
D.Text(sb, Assets.Serif, 34, L.t("missio.iugula"), new Vector2(bar.Right, bar.Y - 30), new Color(255, 120, 80) * a, Align.Right);
D.Text(sb, Assets.Sans, 18, L.t("missio.iugula.hint"), new Vector2(bar.Right, bar.Bottom + 24), D.Sand * a, Align.Right);
foreach (var c in _chants)
{
float ca = MathF.Min(1, c.Age * 4) * MathF.Max(0, 1 - c.Age / 1.6f);
D.Text(sb, Assets.Serif, 30, c.Text, c.Pos + new Vector2(2, 2), Color.Black * (0.6f * ca), Align.Center);
D.Text(sb, Assets.Serif, 30, c.Text, c.Pos, c.Color * ca, Align.Center);
}
if (!Won || _missioT < 3.0f) return;
float b = MathHelper.Clamp((_missioT - 3.0f) / 0.4f, 0, 1);
D.Text(sb, Assets.SansBold, 26, L.t(_crowdMercy ? "missio.wants.mercy" : "missio.wants.end"), new Vector2(Camera.W / 2, 520), Color.White * b, Align.Center);
var r1 = new RectangleF(Camera.W / 2 - 470, 580, 450, 84);
var r2 = new RectangleF(Camera.W / 2 + 20, 580, 450, 84);
if (_ui.Button(sb, r1, L.t("missio.btn.mercy"), selected: _crowdMercy, size: 26, accent: D.Gold)) Decide(true);
if (_ui.Button(sb, r2, L.t("missio.btn.end"), selected: !_crowdMercy, size: 26, accent: new Color(220, 90, 60))) Decide(false);
float left = MathF.Max(0, 9.5f - _missioT);
D.Text(sb, Assets.Sans, 18, string.Format(L.t("missio.timer"), MathF.Ceiling(left)), new Vector2(Camera.W / 2, 700), D.Dim * b, Align.Center);
}
public void GiveUp()
{
Paused = false;

View File

@@ -103,7 +103,7 @@ namespace GladiatorIdle.Arena
switch (f.State)
{
case DuelState.Windup:
name = atk.Name; t = (float)K(f.Heavy ? Duel.HEAVY_WINDUP : f.Windup) * (impact - lead); _mFree = false; break;
name = atk.Name; t = (float)K(f.Heavy ? (f.IsPlayer ? Duel.HEAVY_WINDUP : Duel.CHARGE_WINDUP) : f.Windup) * (impact - lead); _mFree = false; break;
case DuelState.Strike:
name = atk.Name; t = impact - lead + (float)K(f.StrikeTime) * lead; break;
case DuelState.Recover:
@@ -162,6 +162,12 @@ namespace GladiatorIdle.Arena
break;
}
}
// feste Pose von außen (Gnadenstoß: Kampfschrei), läuft einmal durch und bleibt stehen
if (HoldClip != null && m.Find(HoldClip) is { } pc)
{
_poseT += realDt;
name = HoldClip; t = MathF.Min(_poseT, pc.Length - 0.02f); loop = false;
}
if (name != _mClip) { m.BeginBlend(); _mBlend = 0; _mClip = name; }
_mBlend = MathF.Min(1, _mBlend + realDt / 0.12f);
_mTime = t;
@@ -172,6 +178,10 @@ namespace GladiatorIdle.Arena
_lift += (lift - _lift) * MathF.Min(1, realDt * 30);
}
/// Pose statt des Zustands (null = normal).
public string? HoldClip { get => _pose; set { if (_pose != value) { _pose = value; _poseT = 0; } } }
string? _pose; float _poseT;
Matrix ModelWorld(float grow)
{
float s = Stage.FigH / 180f * (1 + grow);

View File

@@ -45,45 +45,6 @@ namespace GladiatorIdle.Arena
sb.Draw(tex, new Rectangle((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height), src, Color.White * alpha);
}
// ── Schublade: Regionen und Aufbruch ────────────────────────
void DrawExpeditions(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, w = r.Width - 60, y = r.Y + 40;
D.Text(sb, Assets.Serif, 34, L.t("exp.title"), new Vector2(x, y), D.Gold);
D.TextWrap(sb, Assets.Sans, 17, L.t("exp.intro"), new RectangleF(x, y + 26, w, 44), D.Sand);
if (_game.Away == null && !_game.RegionOpen(RegionDef.Get(_expRegion)))
_expRegion = RegionDef.All.Last(reg => _game.RegionOpen(reg)).Id;
const float GX = 20, GY = 18;
float cw = (w - 2 * GX) / 3, ch = 250, y0 = y + 84;
for (int i = 0; i < RegionDef.All.Length; i++)
{
var reg = RegionDef.All[i];
var cr = new RectangleF(x + i % 3 * (cw + GX), y0 + i / 3 * (ch + GY), cw, ch);
bool open = _game.RegionOpen(reg), sel = reg.Id == (_game.Away?.Region ?? _expRegion);
D.Rect(sb, cr, new Color(24, 18, 12) * 0.95f);
DrawPicture(sb, Picture(reg.Art), new RectangleF(cr.X + 5, cr.Y + 5, cr.Width - 10, ch - 80), open ? 1 : 0.3f);
D.Text(sb, Assets.Serif, 22, L.t(reg.Key).ToUpperInvariant(), new Vector2(cr.X + 14, cr.Bottom - 54), open ? D.Gold : D.Dim);
string info = open ? string.Format(L.t("exp.chance"), NumberFormat.Percent(_game.ExpeditionChance(reg)))
: string.Format(L.t("exp.locked"), L.t(ArenaDef.All[reg.Unlock].Key));
D.Text(sb, Assets.Sans, 16, info, new Vector2(cr.X + 14, cr.Bottom - 24), open ? ChanceColor(_game.ExpeditionChance(reg)) : D.Dim);
D.Frame(sb, cr, sel ? D.Gold : D.Border, sel ? 4 : 2);
if (open && _game.Away == null && _ui.Hover(cr) && _ui.Hit(cr)) { _expRegion = reg.Id; SoundManager.PlayClick(); }
}
float by = y0 + 2 * (ch + GY) + 10;
if (_game.Away is { } a) { DrawAwayStatus(sb, new RectangleF(x, by, w, 80), a); return; }
float bw = 240;
for (int d = 0; d < 3; d++)
if (_ui.Button(sb, new RectangleF(x + d * (bw + 12), by + 6, bw, 60), string.Format(L.t("exp.duration"), DurationLabel(d), LootCount(d)),
selected: _expDuration == d, size: 18))
_expDuration = d;
if (_ui.Button(sb, new RectangleF(x + w - 300, by + 6, 300, 60), L.t("exp.start"),
_game.RegionOpen(RegionDef.Get(_expRegion)) && !_game.FreedomEarned, selected: true, size: 24, accent: D.Gold))
if (_game.StartExpedition(_expRegion, _expDuration)) { SoundManager.PlayStart(); _drawer = Drawer.None; }
}
void DrawAwayStatus(SpriteBatch sb, RectangleF r, Expedition a)
{
var reg = RegionDef.Get(a.Region);
@@ -104,6 +65,10 @@ namespace GladiatorIdle.Arena
Ui.Panel(sb, r, D.Gold, 0.92f);
DrawPicture(sb, Picture(reg.Art), new RectangleF(r.X + 20, r.Y + 20, r.Width - 40, 430));
DrawAwayStatus(sb, new RectangleF(r.X + 30, r.Y + 470, r.Width - 60, 90), a);
// Reise in 3D ansehen / Karte
if (_ui.Button(sb, new RectangleF(r.X + 30, r.Bottom - 70, (r.Width - 76) / 2, 54), L.t("exp.watch"), selected: true, size: 20, accent: D.Gold)) OpenJourney();
if (_ui.Button(sb, new RectangleF(r.X + 46 + (r.Width - 76) / 2, r.Bottom - 70, (r.Width - 76) / 2, 54), L.t("exp.map"), size: 20))
{ _overlay = Overlay.Map; SoundManager.PlayDrawer(); }
}
// ── Segen ───────────────────────────────────────────────────
@@ -123,6 +88,7 @@ namespace GladiatorIdle.Arena
void DrawModal(SpriteBatch sb)
{
if (Homecoming) { DrawHomecoming(sb, _game.ExpeditionResult!); return; } // Heimkehr als Szene
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.65f);
if (Welcome is { } w) DrawWelcome(sb, w);
else if (_game.ExpeditionResult is { } rep) DrawReport(sb, rep);

View File

@@ -47,10 +47,10 @@ namespace GladiatorIdle.Arena
}
/// Der wichtigste nächste Schritt in diesem Reiter.
(string, Color) Tip()
(string, Color) Tip(Drawer? which = null)
{
var g = _game;
switch (_drawer)
switch (which ?? _drawer)
{
case Drawer.Gladiator when _page == Page.Skills:
return g.LearnablePoints > 0

View File

@@ -0,0 +1,181 @@
using System;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// <summary>
/// Heimkehr von der Expedition als Szene statt Textfenster: der Gladiator geht in den Ludus
/// (Erfolg: Siegerpose, Horn und Jubel; Misserfolg: langsam, angeschlagen), daneben fährt der
/// Bericht ein – Titel, Tagebuch Zeile für Zeile, Beutekarten drehen sich einzeln um (Glanz und
/// Klang nach Seltenheit), Denare/Ruhm/Erfahrung zählen hoch. Klick oder Leertaste: alles sofort.
/// </summary>
internal sealed partial class HubScene
{
ExpeditionReport? _homeRep;
float _homeT;
int _homeFlipped, _homeSounds;
bool _homeCoins;
bool Homecoming => _game.ExpeditionResult != null && Welcome == null;
/// Ankunftsdauer (Lauf in den Ludus); bei „Effekte reduzieren“ sofort da.
float HomeWalk => AppSettings.ReduceMotion ? 0 : _homeRep?.Success == false ? 3.2f : 2.4f;
/// Takt der Heimkehr; liefert die x-Position des Gladiators (läuft von links herein).
float UpdateHomecoming(float dt, Input input)
{
var rep = _game.ExpeditionResult!;
if (rep != _homeRep)
{
_homeRep = rep; _homeT = 0; _homeFlipped = 0; _homeSounds = 0; _homeCoins = false;
_dummy.Set(DuelState.Ready);
}
float before = _homeT;
_homeT += dt;
if (input.Pressed(Microsoft.Xna.Framework.Input.Keys.Space)) _homeT = MathF.Max(_homeT, HomeEnd(rep));
// Ankunft: Pose und Ton einmal
if (before < HomeWalk && _homeT >= HomeWalk)
{
if (rep.Success) { _dummy.Set(DuelState.Victory); SoundManager.PlayVictory(); SoundManager.PlayCheer(); _crowd.Wave(); }
else { _dummy.Set(DuelState.Stunned); _dummy.StunLeft = 99; SoundManager.PlayDefeat(); }
}
_dummy.StateTime += dt;
float k = HomeWalk <= 0 ? 1 : MathHelper.Clamp(_homeT / HomeWalk, 0, 1);
k = 1 - (1 - k) * (1 - k);
return MathHelper.Lerp(-260, HERO_X, k);
}
// Zeitplan (Sekunden nach der Ankunft)
static float LineAt(int i) => 0.4f + i * 0.75f;
static float CardsAt(ExpeditionReport r) => LineAt(r.Log.Count) + 0.2f;
static float CardAt(ExpeditionReport r, int i) => CardsAt(r) + i * 0.45f;
static float CountAt(ExpeditionReport r) => CardAt(r, r.Loot.Count) + 0.2f;
float HomeEnd(ExpeditionReport r) => HomeWalk + CountAt(r) + 1.3f;
void DrawHomecoming(SpriteBatch sb, ExpeditionReport rep)
{
var reg = RegionDef.Get(rep.Region);
float t = _homeT - HomeWalk; // Zeit seit der Ankunft
bool done = _homeT >= HomeEnd(rep);
var accent = rep.Success ? D.Gold : D.Red;
// Misserfolg: Licht gedämpft
if (!rep.Success) D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), new Color(10, 12, 24) * 0.35f);
if (t < 0) return;
float slide = 1 - MathF.Pow(1 - MathHelper.Clamp(t / 0.5f, 0, 1), 3);
var r = new RectangleF(Camera.W - 940 + (1 - slide) * 300, 110, 900, 880);
Ui.Panel(sb, r, accent, 0.94f * slide);
float x = r.X + 34, y = r.Y + 34, w = r.Width - 68;
// Kopf: Bild der Region und Titel
DrawPicture(sb, Picture(reg.Art), new RectangleF(x, y, 230, 140), slide);
D.Frame(sb, new RectangleF(x, y, 230, 140), accent * slide, 2);
D.TextWrap(sb, Assets.Serif, 38, string.Format(L.t(rep.Success ? "exp.back.ok" : "exp.back.fail"), L.t(reg.Key)),
new RectangleF(x + 260, y + 4, w - 260, 100), accent * slide);
if (!rep.Success) D.TextWrap(sb, Assets.Sans, 18, L.t("exp.back.failtext"), new RectangleF(x + 260, y + 96, w - 260, 50), D.Sand * slide);
y += 170;
// Tagebuch: Zeile für Zeile, Buchstaben laufen ein
for (int i = 0; i < rep.Log.Count; i++)
{
float lt = t - LineAt(i);
if (lt < 0) break;
string full = "· " + L.t("expedition.log." + rep.Log[i]); // i18n-ok
int n = done ? full.Length : Math.Min(full.Length, (int)(lt * 80));
D.TextWrap(sb, Assets.Serif, 21, full[..n], new RectangleF(x, y, w, 80), D.Sand);
y += 14 + 27 * D.WrapLines(Assets.Serif, 21, full, w);
}
// Platz für das ganze Tagebuch freihalten (Beute darunter springt nicht)
float logH = 0;
foreach (int n in rep.Log) logH += 14 + 27 * D.WrapLines(Assets.Serif, 21, "· " + L.t("expedition.log." + n), w); // i18n-ok
y = r.Y + 34 + 170 + logH + 18;
// Beute: Karten drehen sich einzeln um
if (rep.Loot.Count > 0 && t >= CardsAt(rep) - 0.2f)
{
D.Text(sb, Assets.SansBold, 20, L.t("exp.loot"), new Vector2(x, y), D.Sand);
float cw = 150, ch = 200, gap = 18, lx = r.Center.X - (rep.Loot.Count * (cw + gap) - gap) / 2, cy = y + 30;
var back = Assets.Sprite("icon_vexillum");
for (int i = 0; i < rep.Loot.Count; i++)
{
var it = rep.Loot[i];
float ft = done ? 1 : MathHelper.Clamp((t - CardAt(rep, i)) / 0.35f, 0, 1);
if (ft >= 0.5f && i >= _homeFlipped)
{
_homeFlipped = i + 1;
var c = new Vector2(lx + i * (cw + gap) + cw / 2, cy + ch / 2);
if (!AppSettings.ReduceMotion) _fx.Sparks(c, 10 + 10 * (int)it.Rarity, RarityColor(it.Rarity), -MathF.PI / 2, MathF.PI, 500);
if (it.Rarity >= Rarity.Legendary) SoundManager.PlayAchievement();
else if (it.Rarity >= Rarity.Epic) SoundManager.PlayLevelUp();
else SoundManager.PlayEquip();
}
float sx = MathF.Abs(MathF.Cos(MathF.PI * ft)); // 1 → 0 → 1
var cr = new RectangleF(lx + i * (cw + gap) + cw / 2 * (1 - sx), cy, cw * sx, ch);
if (ft < 0.5f)
{
// Rückseite: dunkle Karte mit Feldzeichen
D.Rect(sb, cr, new Color(40, 26, 18));
D.Frame(sb, cr, D.Gold * 0.8f, 3);
if (back != null && cr.Width > 4)
sb.Draw(back, new Rectangle((int)(cr.X + cr.Width * 0.15f), (int)(cr.Y + 30), (int)(cr.Width * 0.7f), (int)(ch - 60)), Color.White * 0.8f);
}
else
{
var col = RarityColor(it.Rarity);
if (it.Rarity >= Rarity.Rare) D.Glow(sb, cr.Center, new Vector2(cw * 1.6f, ch * 1.4f), col * (0.25f + 0.1f * MathF.Sin((float)_t * 4)));
D.Rect(sb, cr, new Color(28, 20, 14));
D.Frame(sb, cr, col, 3);
if (cr.Width > 20)
{
ItemTile(sb, new RectangleF(cr.X + (cr.Width - 110 * sx) / 2, cr.Y + 18, 110 * sx, 110), it, false);
if (sx > 0.8f) D.TextWrap(sb, Assets.SansBold, 15, ItemName(it), new RectangleF(cr.X + 8, cr.Y + 138, cr.Width - 16, 60), col);
}
// Klick auf eine aufgedeckte Karte: Stück im Gladiator-Reiter zeigen
if (done && _ui.Hover(cr) && _ui.Hit(cr))
{
_game.DismissExpeditionResult(); _dummy.Set(DuelState.Ready);
_drawer = Drawer.Gladiator; _page = Page.Gear; _sel = it.Id;
SoundManager.PlayDrawer();
return;
}
}
}
y = cy + ch + 24;
}
// Lohn zählt hoch
float ct = t - CountAt(rep);
if (ct >= 0)
{
if (!_homeCoins) { _homeCoins = true; SoundManager.PlayCoins(); }
float k = done ? 1 : MathHelper.Clamp(ct / 1.2f, 0, 1);
k = 1 - (1 - k) * (1 - k);
void Line(string label, double value, Color c)
{
D.Text(sb, Assets.Sans, 21, label, new Vector2(x + 120, y), D.Sand);
D.Text(sb, Assets.SansBold, 26, "+" + NumberFormat.Format(value * k), new Vector2(r.Right - 154, y), c, Align.Right); // i18n-ok
y += 40;
}
Line(L.t("exp.reward.gold"), rep.Gold, D.Gold);
Line(L.t("exp.reward.fame"), rep.Fame, D.Gold);
Line(L.t("exp.reward.xp"), rep.Xp, D.Blue);
}
// Weiter (oder: Klick überspringt die Inszenierung)
if (done)
{
if (_ui.Button(sb, new RectangleF(r.Center.X - 200, r.Bottom - 92, 400, 66), L.t("exp.ok"), selected: true, size: 24, accent: accent))
{ _game.DismissExpeditionResult(); _dummy.Set(DuelState.Ready); SoundManager.PlayCoins(); }
}
else
{
D.Text(sb, Assets.Sans, 16, L.t("exp.skip"), new Vector2(r.Center.X, r.Bottom - 40), D.Dim, Align.Center);
if (_ui.Hit(r)) _homeT = HomeEnd(rep);
}
}
}
}

View File

@@ -0,0 +1,310 @@
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>
/// Reise-Ansicht (Vollbild): der eigene Gladiator marschiert als 3D-Figur durch die Region –
/// endloser Weg in Perspektive, Bäume, Büsche und Felsen am Rand, Meilensteine, das Regionsbild
/// weit hinten (langsamer, Parallaxe). Tag und Nacht laufen mit der Reisezeit (90 s je Tag),
/// nachts trägt er eine Fackel. Tagebuchzeilen „Tag N: …“ erscheinen nach dem Fortschritt.
/// </summary>
internal sealed partial class HubScene
{
/// Boden, Weg und Bewuchs je Region.
sealed record Land(string Ground, Vector3 GroundTint, string Path, Vector3 PathTint, string[] Props, Vector3 Haze);
static readonly Dictionary<string, Land> Lands = new()
{
["gallia"] = new("tex_grass", new(1f, 1f, 0.95f), "tex_sand", new(0.82f, 0.66f, 0.48f), new[] { "prop_oak", "prop_bush", "prop_rock", "prop_cypress" }, new(0.78f, 0.80f, 0.74f)),
["germania"] = new("tex_grass", new(0.78f, 0.9f, 0.78f), "tex_sand", new(0.66f, 0.54f, 0.42f), new[] { "prop_pine", "prop_pine", "prop_oak", "prop_bush", "prop_rock" }, new(0.62f, 0.68f, 0.66f)),
["britannia"] = new("tex_grass", new(0.88f, 1f, 0.88f), "tex_sand", new(0.72f, 0.62f, 0.52f), new[] { "prop_oak", "prop_bush", "prop_rock", "prop_rock" }, new(0.72f, 0.76f, 0.78f)),
["hispania"] = new("tex_dirt", new(1f, 0.9f, 0.8f), "tex_desert", new(0.95f, 0.85f, 0.7f), new[] { "prop_cypress", "prop_bush", "prop_rock" }, new(0.86f, 0.76f, 0.62f)),
["dacia"] = new("tex_snow", new(0.95f, 0.97f, 1f), "tex_snow", new(0.72f, 0.7f, 0.7f), new[] { "prop_pine", "prop_pine", "prop_rock" }, new(0.80f, 0.84f, 0.90f)),
["aegyptus"] = new("tex_desert", new(1f, 0.95f, 0.85f), "tex_desert", new(0.85f, 0.75f, 0.6f), new[] { "prop_palm", "prop_rock", "prop_palm" }, new(0.90f, 0.80f, 0.62f)),
};
const float WALK_SPEED = 230, CELL = 520;
readonly Camera _jCam = new();
readonly Particles _jfx = new();
readonly DuelFighter _jDummy = new() { IsPlayer = true, X = 0, Facing = 1, MaxHp = 1, Hp = 1 };
FighterView? _jHero;
BasicEffect? _jFx, _jPlane;
AlphaTestEffect? _jPropFx;
Mesh3D? _jGround, _jPath, _jStone;
string? _jRegion;
float _jX;
int _jLine = -1; 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)
readonly VertexPositionColorTexture[] _jBack = new VertexPositionColorTexture[6];
readonly Dictionary<string, (VertexPositionColorTexture[] V, int N)> _jProps = new();
void OpenJourney()
{
if (_game.Away == null) return;
_overlay = Overlay.Journey;
_jX = 0; _jLine = -1;
string hero = Art.Hero(_game.Class, _game.Look.Preset);
_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);
SoundManager.PlayDrawer();
}
void UpdateJourney(float dt)
{
if (_game.Away is not { } away) { _overlay = Overlay.Map; return; }
bool calm = AppSettings.ReduceMotion;
_jX += WALK_SPEED * dt;
_jHero!.Update(dt, dt, _jDummy, _jX, calm);
_jCam.FollowX = _jX + 260;
_jCam.Update(dt, _jX, _jX, calm);
_jfx.Calm = calm;
_jfx.Update(dt);
if (_jRegion != away.Region) BuildJourney(away.Region);
_jLineT += dt;
}
void BuildJourney(string region)
{
_jRegion = region;
var land = Lands[region];
float floor = Stage.FloorY;
// Boden: Gitter um den Ursprung, verschoben in ganzen Kachelbreiten (Textur bleibt an der Welt)
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;
for (int i = 0; i < NX; i++)
for (int k = 0; k < nz; k++)
{
float xa = x0 + (x1 - x0) * i / NX, xb = x0 + (x1 - x0) * (i + 1) / NX;
float za = z0 + (z1 - z0) * k / nz, zb = z0 + (z1 - z0) * (k + 1) / nz;
Vector2 T(float x, float z) => new(x / 420f, z / 420f);
m.Quad(new(xa, y, zb), new(xb, y, zb), new(xb, y, za), new(xa, y, za), -Vector3.UnitY, Color.White,
T(xa, zb), T(xb, zb), T(xb, za), T(xa, za));
}
m.Freeze();
return m;
}
_jGround = Grid(land.Ground, land.GroundTint, -3000, 900, floor, 10);
_jPath = Grid(land.Path, land.PathTint, -230, 150, floor - 0.6f, 2);
// Meilenstein
_jStone = new Mesh3D { Tex = Assets.Pixel };
_jStone.Box(new Vector3(0, floor - 45, 0), new Vector3(34, 90, 30), new Color(170, 164, 150));
_jStone.Box(new Vector3(0, floor - 95, 0), new Vector3(40, 12, 36), new Color(150, 144, 132));
_jStone.Freeze();
_jProps.Clear();
}
/// Licht nach Tageszeit (0 Morgen … 0,25 Mittag … 0,5 Abend … 0,75 Nacht … 1 Morgen).
static (Vector3 SunDir, Vector3 Sun, Vector3 Amb, Vector3 Fog, Vector3 Sky, float Night) DayLight(float p)
{
(float P, Vector3 Dir, Vector3 Sun, Vector3 Amb, Vector3 Fog, Vector3 Sky)[] keys =
{
(0.00f, new(0.8f, 0.35f, -0.5f), new(1.0f, 0.70f, 0.50f), new(0.36f, 0.30f, 0.32f), new(0.88f, 0.70f, 0.60f), new(1.0f, 0.82f, 0.74f)),
(0.25f, new(0.25f, 0.92f, -0.3f), new(1.0f, 0.96f, 0.88f), new(0.48f, 0.46f, 0.44f), new(0.82f, 0.82f, 0.80f), new(1.0f, 1.0f, 1.0f)),
(0.50f, new(-0.8f, 0.35f, -0.5f), new(1.0f, 0.56f, 0.34f), new(0.36f, 0.28f, 0.28f), new(0.82f, 0.52f, 0.40f), new(1.0f, 0.72f, 0.58f)),
(0.62f, new(-0.3f, 0.8f, -0.4f), new(0.30f, 0.36f, 0.60f), new(0.15f, 0.17f, 0.28f), new(0.12f, 0.14f, 0.24f), new(0.26f, 0.30f, 0.48f)),
(0.90f, new(-0.3f, 0.8f, -0.4f), new(0.30f, 0.36f, 0.60f), new(0.15f, 0.17f, 0.28f), new(0.12f, 0.14f, 0.24f), new(0.26f, 0.30f, 0.48f)),
(1.00f, new(0.8f, 0.35f, -0.5f), new(1.0f, 0.70f, 0.50f), new(0.36f, 0.30f, 0.32f), new(0.88f, 0.70f, 0.60f), new(1.0f, 0.82f, 0.74f)),
};
int i = 0;
while (i < keys.Length - 2 && p > keys[i + 1].P) i++;
var a = keys[i]; var b = keys[i + 1];
float k = MathHelper.Clamp((p - a.P) / (b.P - a.P), 0, 1);
k = k * k * (3 - 2 * k);
float night = p < 0.55f ? 0 : p < 0.64f ? (p - 0.55f) / 0.09f : p < 0.9f ? 1 : MathF.Max(0, 1 - (p - 0.9f) / 0.08f);
return (Vector3.Normalize(Vector3.Lerp(a.Dir, b.Dir, k)), Vector3.Lerp(a.Sun, b.Sun, k), Vector3.Lerp(a.Amb, b.Amb, k),
Vector3.Lerp(a.Fog, b.Fog, k), Vector3.Lerp(a.Sky, b.Sky, k), night);
}
void DrawJourney(GraphicsDevice gd, SpriteBatch sb, BasicEffect fx, float scale, Vector2 offset)
{
if (_game.Away is not { } away || _jRegion == null || _jHero == null) return;
var land = Lands[away.Region];
var reg = RegionDef.Get(away.Region);
double total = Adventures.Durations[away.Duration], elapsed = total - away.Left;
float phase = DevDayPhase ?? (float)((elapsed / 90 + 0.12) % 1);
var (sunDir, sun, amb, fogDay, sky, night) = DayLight(phase);
var fog = fogDay * Vector3.Lerp(Vector3.One, land.Haze, 0.5f + 0.5f * (1 - night)) ;
bool calm = AppSettings.ReduceMotion;
int vw = gd.Viewport.Width, vh = gd.Viewport.Height;
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 };
_jPlane ??= new BasicEffect(gd) { TextureEnabled = true, VertexColorEnabled = true, LightingEnabled = false };
_jPropFx ??= new AlphaTestEffect(gd) { VertexColorEnabled = true, ReferenceAlpha = 110, AlphaFunction = CompareFunction.Greater };
_jPlane.World = Matrix.Identity; _jPlane.View = v3; _jPlane.Projection = p3;
gd.Clear(ClearOptions.Target | ClearOptions.DepthBuffer | ClearOptions.Stencil, new Color(fog), 1, 0);
float camX = _jCam.Center.X;
// fernes Regionsbild (gespiegelt wiederholt, langsamer als der Weg: Parallaxe)
if (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));
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];
_jBack[5] = new(new Vector3(xl, bottom, Z), c, new Vector2(u0, 1));
_jFx.World = Matrix.Identity; _jFx.View = v3; _jFx.Projection = p3;
_jFx.LightingEnabled = false; _jFx.FogEnabled = true; _jFx.FogColor = fog; _jFx.FogStart = 4000; _jFx.FogEnd = 16000;
_jFx.DiffuseColor = Vector3.One; _jFx.Texture = pic;
gd.DepthStencilState = DepthStencilState.None; gd.BlendState = BlendState.Opaque; gd.RasterizerState = RasterizerState.CullNone;
foreach (var pass in _jFx.CurrentTechnique.Passes)
{
pass.Apply();
gd.SamplerStates[0] = MirrorSampler;
gd.DrawUserPrimitives(PrimitiveType.TriangleList, _jBack, 0, 2);
}
}
// Boden und Weg (in ganzen Kachelbreiten mitgeführt)
float snap = MathF.Floor(camX / 420f) * 420f;
_jFx.LightingEnabled = true; _jFx.FogStart = 1600; _jFx.FogEnd = 6200;
_jFx.AmbientLightColor = amb; _jFx.DirectionalLight0.Enabled = true; _jFx.DirectionalLight0.Direction = sunDir;
_jFx.DirectionalLight0.DiffuseColor = sun; _jFx.DirectionalLight0.SpecularColor = Vector3.Zero;
_jFx.DirectionalLight1.Enabled = false; _jFx.DirectionalLight2.Enabled = false;
gd.DepthStencilState = DepthStencilState.Default;
foreach (var m in new[] { _jGround!, _jPath! })
{
_jFx.World = Matrix.CreateTranslation(snap, 0, 0);
_jFx.Texture = Assets.Mipmapped(m.Tex!); _jFx.DiffuseColor = m.Tint;
foreach (var pass in _jFx.CurrentTechnique.Passes)
{
pass.Apply();
gd.SamplerStates[0] = SamplerState.AnisotropicWrap;
gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, m.VA, 0, m.VA!.Length, m.IA, 0, m.IA!.Length / 3);
}
}
// 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);
for (int cell = c0; cell <= c1; cell++)
if (cell % 4 == 0)
{
_jFx.World = Matrix.CreateTranslation(cell * CELL, 0, -170);
foreach (var pass in _jFx.CurrentTechnique.Passes)
{
pass.Apply();
gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, _jStone!.VA, 0, _jStone.VA!.Length, _jStone.IA, 0, _jStone.IA!.Length / 3);
}
}
// 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);
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));
for (int cell = c0; cell <= c1; cell++)
{
var rng = new Random(cell * 7919 + away.Region.Length * 104729);
int n = 2 + rng.Next(3);
for (int i = 0; i < n; i++)
{
string kind = land.Props[rng.Next(land.Props.Length)];
if (!_jProps.TryGetValue(kind, out var buf) || Assets.Sprite(kind) is not Texture2D tex) continue;
bool small = kind is "prop_bush" or "prop_rock";
float x = cell * CELL + (float)rng.NextDouble() * CELL;
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 (!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];
if (k + 6 > buf.V.Length) continue;
float half = size / 2, bottom = Stage.FloorY + size * 0.04f, top = bottom - size;
bool flip = rng.Next(2) == 0;
float ua = flip ? 1 : 0, ub = 1 - ua;
var v = buf.V;
v[k] = new(new Vector3(x - half, top, z), light, new Vector2(ua, 0)); v[k + 1] = new(new Vector3(x + half, top, z), light, new Vector2(ub, 0));
v[k + 2] = new(new Vector3(x + half, bottom, z), light, new Vector2(ub, 1)); v[k + 3] = v[k]; v[k + 4] = v[k + 2];
v[k + 5] = new(new Vector3(x - half, bottom, z), light, new Vector2(ua, 1));
counts[kind] = k + 6;
}
}
_jPropFx.World = Matrix.Identity; _jPropFx.View = v3; _jPropFx.Projection = p3;
_jPropFx.FogEnabled = true; _jPropFx.FogColor = fog; _jPropFx.FogStart = 1600; _jPropFx.FogEnd = 6200;
foreach (var (kind, cnt) in counts)
{
if (cnt == 0 || Assets.Sprite(kind) is not Texture2D tex) continue;
_jPropFx.Texture = Assets.Mipmapped(tex);
foreach (var pass in _jPropFx.CurrentTechnique.Passes)
{
pass.Apply();
gd.SamplerStates[0] = SamplerState.AnisotropicClamp;
gd.DrawUserPrimitives(PrimitiveType.TriangleList, _jProps[kind].V, 0, cnt / 3);
}
}
// 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);
var torch = _jHero.Chest + new Vector2(70, -40);
if (night > 0.01f)
{
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, _jPlane);
float fl = 0.85f + 0.15f * MathF.Sin((float)_t * 19) * MathF.Sin((float)_t * 7.7f);
D.Glow(sb, new Vector2(_jHero.X, Stage.FloorY), new Vector2(1300 * fl, 300), new Color(255, 140, 50) * (0.35f * night));
D.Glow(sb, torch, new Vector2(700 * fl), new Color(255, 150, 60) * (0.35f * night));
sb.End();
if (!calm && Random.Shared.NextDouble() < 0.4 * night) _jfx.Sparks(torch, 1, new Color(255, 180, 80), -MathF.PI / 2, 0.7f, 140);
}
Stage3D.BeginFigures(gd);
_jHero.DrawBody(gd, fx, _jDummy, calm);
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, _jPlane);
if (night > 0.01f)
{
float fl = 0.8f + 0.2f * MathF.Sin((float)_t * 23);
D.Glow(sb, torch, new Vector2(90 * fl, 130 * fl), new Color(255, 170, 70) * night);
D.Glow(sb, torch - new Vector2(0, 14), new Vector2(46, 70 * fl), new Color(255, 236, 170) * night);
}
_jfx.DrawAdd(sb);
sb.End();
// Anzeige: oben Region und Rest, Mitte unten Tagebuch, unten Knöpfe
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
for (int i = 0; i < 16; i++) D.Rect(sb, new RectangleF(0, i * 14, Camera.W, 14), Color.Black * (0.6f * (1 - i / 16f)));
D.Glow(sb, new Vector2(Camera.W / 2, Camera.H + 120), new Vector2(3000, 520), Color.Black * 0.6f);
int day = 1 + (int)(elapsed / 90);
D.Text(sb, Assets.Serif, 40, L.t(reg.Key).ToUpperInvariant(), new Vector2(Camera.W / 2, 56), D.Gold, Align.Center);
D.Text(sb, Assets.SansBold, 20, $"{string.Format(L.t("exp.day"), day)} · {string.Format(L.t("exp.left"), NumberFormat.Duration(away.Left))}", // i18n-ok
new Vector2(Camera.W / 2, 100), D.Sand, Align.Center);
float k2 = (float)(elapsed / total);
D.Bar(sb, new RectangleF(Camera.W / 2 - 300, 122, 600, 10), k2, k2, D.Gold);
// 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);
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
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);
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - 330, Camera.H - 120, 320, 60), L.t("exp.map"), size: 22)) _overlay = Overlay.Map;
if (_ui.Button(sb, new RectangleF(Camera.W / 2 + 10, Camera.H - 120, 320, 60), L.t("exp.recall"), size: 18, accent: D.Red))
{ _game.Recall(); SoundManager.PlayBoo(); _overlay = Overlay.Map; }
sb.End();
}
static readonly SamplerState MirrorSampler = new() { AddressU = TextureAddressMode.Mirror, AddressV = TextureAddressMode.Clamp, Filter = TextureFilter.Linear };
}
}

237
Mono/Arena/HubScene.Map.cs Normal file
View File

@@ -0,0 +1,237 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// <summary>
/// Feldzugkarte (Vollbild über dem Hub): das Reich als gemalte Karte, Rom in der Mitte, die
/// Regionen als Feldzeichen. Offene Regionen sind über laufende Wege mit Rom verbunden,
/// gesperrte liegen im Nebel. Rechts die Tafel der gewählten Region (Bild, Chance, Dauer, Lohn,
/// Aufbruch); unterwegs zieht ein Feldzeichen über die Route.
/// </summary>
internal sealed partial class HubScene
{
enum Overlay { None, Map, Journey }
Overlay _overlay;
string? _mapHover;
/// Lage auf der Karte (Anteil am Bild 0–1).
static readonly Dictionary<string, Vector2> MapPos = new()
{
["rome"] = new(0.54f, 0.47f),
["gallia"] = new(0.41f, 0.32f), ["germania"] = new(0.52f, 0.22f), ["britannia"] = new(0.39f, 0.10f),
["hispania"] = new(0.31f, 0.52f), ["dacia"] = new(0.78f, 0.33f), ["aegyptus"] = new(0.83f, 0.79f),
};
Vector2 _mapPan; float _mapZoom = 1;
/// Mitte der Karte auf dem Bildschirm: nach links verschoben, damit rechts die Tafel Platz hat.
static readonly Vector2 MapCenter = new(640, Camera.H / 2);
Vector2 OnMap(Vector2 f) => MapCenter + (f - new Vector2(0.5f)) * new Vector2(Camera.W, Camera.H) * _mapZoom + _mapPan;
/// Punkt auf der gebogenen Route Rom → Region (t = 0 … 1).
Vector2 RoutePoint(string region, float t)
{
Vector2 a = OnMap(MapPos["rome"]), b = OnMap(MapPos[region]);
var d = b - a;
var n = new Vector2(-d.Y, d.X) * 0.18f; // Bogen zur Seite
var c = (a + b) / 2 + n;
float u = 1 - t;
return u * u * a + 2 * u * t * c + t * t * b;
}
void DrawRoute(SpriteBatch sb, string region, Color col, float thick, float phase, float upTo = 1)
{
float len = Vector2.Distance(OnMap(MapPos["rome"]), OnMap(MapPos[region]));
int n = Math.Max(6, (int)(len / 22));
for (int i = -1; i < n; i++)
{
float t0 = (i + phase) / n, t1 = t0 + 0.55f / n;
if (t1 <= 0 || t0 >= upTo) continue;
t0 = MathF.Max(0, t0); t1 = MathF.Min(upTo, t1);
Vector2 p0 = RoutePoint(region, t0), p1 = RoutePoint(region, t1), dv = p1 - p0;
sb.Draw(Assets.Pixel, p0, null, col, MathF.Atan2(dv.Y, dv.X), new Vector2(0, 0.5f), new Vector2(dv.Length(), thick), SpriteEffects.None, 0);
}
}
void DrawMap(SpriteBatch sb)
{
bool calm = AppSettings.ReduceMotion;
float t = (float)_t;
_mapZoom = calm ? 1.08f : 1.08f + 0.02f * MathF.Sin(t * 0.07f);
_mapPan = calm ? Vector2.Zero : new Vector2(14 * MathF.Sin(t * 0.05f), 8 * MathF.Sin(t * 0.04f + 1));
// Karte und Licht
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), new Color(28, 22, 16));
if (Assets.Sprite("map_empire", "jpg") is Texture2D map)
{
var size = new Vector2(Camera.W, Camera.H) * _mapZoom;
sb.Draw(map, MapCenter + _mapPan, null, new Color(0.95f, 0.92f, 0.86f), 0,
new Vector2(map.Width / 2f, map.Height / 2f), size / new Vector2(map.Width, map.Height), SpriteEffects.None, 0);
}
else D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), new Color(60, 48, 34));
D.Glow(sb, new Vector2(-250, Camera.H / 2), new Vector2(1000, 2200), Color.Black * 0.55f);
D.Glow(sb, new Vector2(Camera.W + 250, Camera.H / 2), new Vector2(1300, 2200), Color.Black * 0.7f);
D.Glow(sb, new Vector2(Camera.W / 2, -200), new Vector2(3000, 600), Color.Black * 0.5f);
D.Glow(sb, new Vector2(Camera.W / 2, Camera.H + 200), new Vector2(3000, 600), Color.Black * 0.5f);
var away = _game.Away;
string sel = away?.Region ?? _expRegion;
if (away == null && !_game.RegionOpen(RegionDef.Get(sel)))
sel = _expRegion = RegionDef.All.Last(reg => _game.RegionOpen(reg)).Id;
// Nebel über gesperrten Regionen (treibende Wolken)
int ri = 0;
foreach (var reg in RegionDef.All)
{
ri++;
if (_game.RegionOpen(reg)) continue;
var c = OnMap(MapPos[reg.Id]);
for (int k = 0; k < 6; k++)
{
float a = t * 0.12f + k * 1.7f + ri, r = 70 + 25 * MathF.Sin(t * 0.3f + k);
var p = c + new Vector2(MathF.Cos(a) * r * 1.6f, MathF.Sin(a * 0.8f) * r * 0.7f);
D.Glow(sb, p, new Vector2(330, 200), new Color(120, 124, 136) * 0.75f);
D.Glow(sb, p + new Vector2(-20, -16), new Vector2(200, 120), new Color(225, 225, 232) * 0.45f);
}
D.Glow(sb, c, new Vector2(420, 290), new Color(90, 94, 108) * 0.85f);
}
// Wege von Rom zu den offenen Regionen; der gewählte leuchtet
float phase = calm ? 0 : t * 0.6f % 1;
foreach (var reg in RegionDef.All)
{
if (!_game.RegionOpen(reg)) continue;
bool on = reg.Id == sel || reg.Id == _mapHover;
if (on) DrawRoute(sb, reg.Id, D.Gold * 0.35f, 9, phase);
DrawRoute(sb, reg.Id, on ? new Color(255, 214, 120) : new Color(120, 72, 40) * 0.75f, on ? 4 : 3, phase);
}
// Rom
var rome = OnMap(MapPos["rome"]);
D.Glow(sb, rome, new Vector2(150), D.Gold * (0.45f + 0.15f * MathF.Sin(t * 2)));
sb.Draw(Assets.Disc, rome, null, new Color(150, 30, 30), 0, new Vector2(64), 26f / 128, SpriteEffects.None, 0);
sb.Draw(Assets.Disc, rome, null, D.Gold, 0, new Vector2(64), 16f / 128, SpriteEffects.None, 0);
Label(sb, L.t("exp.rome"), rome + new Vector2(0, 30), D.Gold, 24);
// Feldzeichen der Regionen
_mapHover = null;
var flag = Assets.Sprite("icon_vexillum");
foreach (var reg in RegionDef.All)
{
var p = OnMap(MapPos[reg.Id]);
bool open = _game.RegionOpen(reg), isSel = reg.Id == sel;
var hit = new RectangleF(p.X - 50, p.Y - 110, 100, 150);
bool hover = away == null && open && _ui.Hover(hit);
if (hover) _mapHover = reg.Id;
float pulse = 0.5f + 0.5f * MathF.Sin(t * 2.4f + reg.Unlock);
if (open) D.Glow(sb, p - new Vector2(0, 40), new Vector2(isSel ? 230 : 170), D.Gold * ((isSel ? 0.5f : 0.25f) + 0.15f * pulse));
if (flag != null)
{
float s = (isSel || hover ? 120f : 96f) / flag.Height;
float sway = calm ? 0 : 0.04f * MathF.Sin(t * 1.6f + reg.Tier);
sb.Draw(flag, p + new Vector2(0, 12), null, open ? Color.White : new Color(120, 116, 110) * 0.85f, sway,
new Vector2(flag.Width / 2f, flag.Height * 0.94f), s, SpriteEffects.None, 0);
}
Label(sb, L.t(reg.Key).ToUpperInvariant(), p + new Vector2(0, 34), open ? (isSel ? Color.White : D.Sand) : D.Dim, isSel ? 26 : 22);
if (!open)
Label(sb, string.Format(L.t("exp.locked"), L.t(ArenaDef.All[reg.Unlock].Key)), p + new Vector2(0, 62), D.Dim, 16);
else if (away == null)
Label(sb, NumberFormat.Percent(_game.ExpeditionChance(reg)), p + new Vector2(0, 62), ChanceColor(_game.ExpeditionChance(reg)), 18);
if (hover && _ui.Hit(hit)) { _expRegion = reg.Id; SoundManager.PlayDrawer(); }
}
// Unterwegs: Feldzeichen zieht über die Route, dahinter leuchtet der zurückgelegte Weg
if (away != null)
{
float k = (float)(1 - away.Left / Adventures.Durations[away.Duration]);
DrawRoute(sb, away.Region, new Color(255, 230, 160), 6, 0, k);
var m = RoutePoint(away.Region, k) + new Vector2(0, calm ? 0 : -4 * MathF.Abs(MathF.Sin(t * 5)));
for (int i = 0; i < 4; i++)
D.Glow(sb, m + new Vector2(-14 * i - 10, 18 + 3 * MathF.Sin(t * 7 + i)), new Vector2(46 - 6 * i), new Color(200, 170, 120) * (0.35f - 0.07f * i));
D.Glow(sb, m, new Vector2(140), D.Gold * 0.6f);
if (flag != null) sb.Draw(flag, m, null, Color.White, 0, new Vector2(flag.Width / 2f, flag.Height * 0.94f), 80f / flag.Height, SpriteEffects.None, 0);
}
DrawMapPanel(sb, RegionDef.Get(sel), away);
// Anleitung unten links
var gr = new RectangleF(40, Camera.H - 210, 640, 170);
Ui.Panel(sb, gr, D.Border, 0.9f);
D.TextWrap(sb, Assets.Serif, 19, L.t("guide.expedition.what"), new RectangleF(gr.X + 22, gr.Y + 18, gr.Width - 44, 60), D.Sand);
var (tip, tc) = Tip(Drawer.Expedition);
D.TextWrap(sb, Assets.Sans, 17, tip, new RectangleF(gr.X + 22, gr.Y + 88, gr.Width - 44, 70), tc);
}
/// Text mit dunklem Schatten (lesbar auf der hellen Karte).
static void Label(SpriteBatch sb, string text, Vector2 at, Color c, float size)
{
D.Text(sb, Assets.Serif, size, text, at + new Vector2(2, 2), Color.Black * 0.75f, Align.Center);
D.Text(sb, Assets.Serif, size, text, at, c, Align.Center);
}
/// Tafel rechts: Region, Chance, Dauer und Lohn, Aufbruch – oder der Stand der laufenden Reise.
void DrawMapPanel(SpriteBatch sb, RegionDef reg, Expedition? away)
{
var r = new RectangleF(Camera.W - 490, 30, 460, 1020);
Ui.Panel(sb, r, D.Gold, 0.93f);
float x = r.X + 24, w = r.Width - 48, y = r.Y + 30;
// Kopf: Titel und Zurück
string title = L.t("exp.map").ToUpperInvariant();
float ts = 34;
while (ts > 18 && D.Measure(Assets.Serif, ts, title).X > w - 150) ts -= 1; // längere Sprachen
D.Text(sb, Assets.Serif, ts, title, new Vector2(x, y + 2), D.Gold);
if (_ui.Button(sb, new RectangleF(r.Right - 24 - 130, y - 18, 130, 44), L.t("exp.close"), size: 18)) _overlay = Overlay.None;
y += 48;
DrawPicture(sb, Picture(reg.Art), new RectangleF(x, y, w, 250));
D.Frame(sb, new RectangleF(x, y, w, 250), D.Border, 2);
y += 278;
D.Text(sb, Assets.Serif, 38, L.t(reg.Key).ToUpperInvariant(), new Vector2(x, y), D.Gold);
y += 44;
if (away != null)
{
double total = Adventures.Durations[away.Duration];
float k = (float)(1 - away.Left / total);
D.Text(sb, Assets.SansBold, 21, string.Format(L.t("exp.away"), L.t(reg.Key)), new Vector2(x, y), D.Sand);
D.Text(sb, Assets.Sans, 19, string.Format(L.t("exp.left"), NumberFormat.Duration(away.Left)), new Vector2(x, y + 32), D.Sand);
D.Bar(sb, new RectangleF(x, y + 62, w, 16), k, k, D.Gold);
y += 110;
if (_ui.Button(sb, new RectangleF(x, y, w, 64), L.t("exp.watch"), selected: true, size: 24, accent: D.Gold))
OpenJourney();
if (_ui.Button(sb, new RectangleF(x, y + 80, w, 52), L.t("exp.recall"), size: 18, accent: D.Red))
{ _game.Recall(); SoundManager.PlayBoo(); }
return;
}
double chance = _game.ExpeditionChance(reg);
D.Text(sb, Assets.SansBold, 20, string.Format(L.t("exp.chance"), NumberFormat.Percent(chance)), new Vector2(x, y), ChanceColor(chance));
D.Bar(sb, new RectangleF(x, y + 28, w, 14), (float)chance, (float)chance, ChanceColor(chance));
y += 66;
for (int d = 0; d < 3; d++)
{
if (_ui.Button(sb, new RectangleF(x, y, w, 56), string.Format(L.t("exp.duration"), DurationLabel(d), LootCount(d)),
selected: _expDuration == d, size: 19))
_expDuration = d;
y += 66;
}
// erwarteter Lohn bei Erfolg (wie GameState.FinishExpedition)
double wins = Adventures.Wins[_expDuration];
double gold = Balance.GoldPerWin(reg.Tier) * _game.GoldMult * wins * 0.9, fame = Balance.FamePerWin(reg.Tier) * _game.FameMult * wins * 0.5,
xp = Balance.CharXpPerWin(reg.Tier) * wins * 0.8;
D.Text(sb, Assets.SansBold, 18, L.t("exp.reward"), new Vector2(x, y + 4), D.Sand);
D.Text(sb, Assets.Sans, 18, $"+{NumberFormat.Format(gold)} {L.t("exp.reward.gold")}", new Vector2(x, y + 32), D.Gold); // i18n-ok
D.Text(sb, Assets.Sans, 18, $"+{NumberFormat.Format(fame)} {L.t("exp.reward.fame")} · +{NumberFormat.Format(xp)} {L.t("exp.reward.xp")}", new Vector2(x, y + 58), D.Gold); // i18n-ok
y += 76;
if (_ui.Button(sb, new RectangleF(x, r.Bottom - 96, w, 70), L.t("exp.start"), _game.RegionOpen(reg) && !_game.FreedomEarned,
selected: true, size: 26, accent: D.Gold))
if (_game.StartExpedition(reg.Id, _expDuration)) SoundManager.PlayStart();
}
}
}

View File

@@ -109,7 +109,8 @@ namespace GladiatorIdle.Arena
_toastAge += dt;
_ui.Begin(input, ui);
_game.Tick(dt); // Training, Einnahmen, Erholung
_hero.Update(dt, dt, _dummy, HERO_X, AppSettings.ReduceMotion);
float heroX = Homecoming ? UpdateHomecoming(dt, input) : HERO_X; // Heimkehr: läuft von links herein
_hero.Update(dt, dt, _dummy, heroX, AppSettings.ReduceMotion);
_stage.Cam.Update(dt, Camera.W / 2 - 1800, Camera.W / 2 + 1800, AppSettings.ReduceMotion); // weiter weg, ruhige Drift
_lastDt = dt;
UpdateAdventure();
@@ -119,7 +120,15 @@ namespace GladiatorIdle.Arena
if (_drawer != _drawerSound) { _drawerSound = _drawer; SoundManager.PlayDrawer(); }
float target = _drawer == Drawer.None ? 0 : 1;
_drawerK += (target - _drawerK) * (1 - MathF.Exp(-dt * 14));
if (input.Pressed(Microsoft.Xna.Framework.Input.Keys.Escape) && _drawer != Drawer.None) { _drawer = Drawer.None; input.PrevKeys = input.Keys; }
// Feldzugkarte / Reise: Esc geht eine Stufe zurück; ein Bericht oder Ereignis schließt beide
if (_overlay != Overlay.None)
{
if (Modal) _overlay = Overlay.None;
else if (input.Pressed(Microsoft.Xna.Framework.Input.Keys.Escape))
{ _overlay = _overlay == Overlay.Journey ? Overlay.Map : Overlay.None; input.PrevKeys = input.Keys; }
if (_overlay == Overlay.Journey) UpdateJourney(dt);
}
else if (input.Pressed(Microsoft.Xna.Framework.Input.Keys.Escape) && _drawer != Drawer.None) { _drawer = Drawer.None; input.PrevKeys = input.Keys; }
}
public bool DrawerOpen => _drawer != Drawer.None;
@@ -128,7 +137,9 @@ namespace GladiatorIdle.Arena
/// Testlauf: Schublade öffnen ("none", "gladiator", "skills", "ludus", "expedition", "hall"), sofort ganz offen.
public void DevOpen(string d)
{
_drawer = d switch { "gladiator" or "skills" => Drawer.Gladiator, "ludus" => Drawer.Ludus, "expedition" => Drawer.Expedition, "hall" => Drawer.Hall, _ => Drawer.None };
_drawer = d switch { "gladiator" or "skills" => Drawer.Gladiator, "ludus" => Drawer.Ludus, "hall" => Drawer.Hall, _ => Drawer.None };
_overlay = d == "expedition" ? Overlay.Map : Overlay.None;
if (d == "journey") OpenJourney();
_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;
@@ -141,6 +152,15 @@ namespace GladiatorIdle.Arena
EnsureArena();
D.UiScale = scale;
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
// Vollbild: Reise in 3D oder Feldzugkarte
if (_overlay == Overlay.Journey && _game.Away != null) { DrawJourney(gd, sb, fx, scale, offset); return; }
if (_overlay == Overlay.Map)
{
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
DrawMap(sb);
sb.End();
return;
}
var sw = System.Diagnostics.Stopwatch.StartNew();
RenderCards(gd, fx, _lastDt);
@@ -346,7 +366,7 @@ namespace GladiatorIdle.Arena
}
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 (Tab(ex, Drawer.Expedition, 300, _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.None; _overlay = Overlay.Map; SoundManager.PlayDrawer(); } // Feldzugkarte
if (HallOpen)
{
int open = _game.Legends.Count(l => !_game.LegendsBeaten.Contains(l.Number));
@@ -375,7 +395,7 @@ namespace GladiatorIdle.Arena
}
else if (_drawer == Drawer.Ludus) DrawLudus(sb, r);
else if (_drawer == Drawer.Hall) DrawHall(sb, r);
else if (_drawer == Drawer.Expedition) DrawExpeditions(sb, r);
}
static float Ease(float k) => 1 - (1 - k) * (1 - k);

View File

@@ -250,7 +250,20 @@ namespace GladiatorIdle
else
{
_game!.ResolveFight(_offer!, won);
_hub!.ShowResult(_hub.ResultLines(_before, won), won ? Gfx.Draw.Gold : Gfx.Draw.Red);
var lines = new System.Collections.Generic.List<string>(_hub!.ResultLines(_before, won));
// Gnadenstoß: Folgen der Wahl bzw. Urteil des Publikums
if (won && _scene.MercyChosen is bool mercy)
{
double bonus = _game.ApplyMissio(mercy, _scene.CrowdMercy, _game.FameRun - _before.Fame);
lines.Add(mercy == _scene.CrowdMercy ? string.Format(L.t("missio.toast.match"), NumberFormat.Format(bonus))
: mercy ? string.Format(L.t("missio.toast.mercy"), NumberFormat.Format(bonus)) : L.t("missio.toast.against"));
}
else if (!won && _scene.Spared is bool spared)
{
_game.ApplyVerdict(spared);
lines.Add(L.t(spared ? "missio.spared" : "missio.doomed"));
}
_hub.ShowResult(lines.ToArray(), won ? Gfx.Draw.Gold : Gfx.Draw.Red);
if (won && _offer!.Enemy.IsChampion) Net.Leaderboard.Submit(_game);
}
SoundManager.StartAmbient("music_ludus");
@@ -387,7 +400,7 @@ namespace GladiatorIdle
if ((input.Pressed(Keys.Escape) || input.PadPressed(Buttons.Start)) && !_scene.Over) _scene.Paused = !_scene.Paused;
if (_scene.Paused && input.Pressed(Keys.X)) _scene.GiveUp();
_game!.Tick(dt); // Training läuft auch im Kampf weiter
_scene.Update(dt, input);
_scene.Update(dt, input, ui);
if (DevShot.Active) DevSteps(dt);
if (_scene != null && _scene.Finished && (input.Pressed(Keys.Enter) || input.LeftClick || DevShot.Active && _shots.Contains("m_end") && _capture == null))
EndDuel();
@@ -504,17 +517,34 @@ namespace GladiatorIdle
}
if (DevAdventureRun)
{
// Expeditionen: Auswahl, unterwegs, Rückkehr-Bericht; dann ein Ereignis mit Entscheidung
// Expeditionen: Feldzugkarte, Aufbruch, Karte unterwegs, Reise in 3D zu vier Tageszeiten,
// Rückkehr-Bericht; dann ein Ereignis mit Entscheidung
if (_devTime > 0.8 && !_shots.Contains("x_open")) { _shots.Add("x_open"); _hub!.DevOpen("expedition"); }
if (_devTime > 1.6) Shot("x_regions");
if (_devTime > 1.9 && !_shots.Contains("x_go")) { _shots.Add("x_go"); _hub!.DevOpen("none"); _game!.StartExpedition("gallia", 1); }
if (_devTime > 2.6) Shot("x_away");
if (_devTime > 2.9 && !_shots.Contains("x_back")) { _shots.Add("x_back"); _game!.Tick(Adventures.Durations[1] + 1); }
if (_devTime > 3.6) Shot("x_report");
if (_devTime > 3.9 && !_shots.Contains("x_event")) { _shots.Add("x_event"); _game!.DismissExpeditionResult(); _game.DevEvent("nightduel"); }
if (_devTime > 4.6) Shot("x_eventcard");
if (_devTime > 4.9 && !_shots.Contains("x_choose")) { _shots.Add("x_choose"); _game!.Choose(0); }
if (_devTime > 5.3 && _capture == null && _shots.Contains("x_choose")) { DevShot.Log($"adventure: buffs={_game!.Buffs.Count} gold={_game.Gold:0}"); Exit(); }
if (_devTime > 1.6) Shot("x_map");
if (_devTime > 1.9 && !_shots.Contains("x_go")) { _shots.Add("x_go"); _game!.StartExpedition("gallia", 1); _game.Tick(700); }
if (_devTime > 2.6) Shot("x_map_away");
if (_devTime > 2.9 && !_shots.Contains("x_jopen")) { _shots.Add("x_jopen"); _hub!.DevOpen("journey"); _hub.DevDayPhase = 0.1f; }
if (_devTime > 4.2) Shot("x_journey_morning");
if (_devTime > 4.4 && !_shots.Contains("x_noon")) { _shots.Add("x_noon"); _hub!.DevDayPhase = 0.3f; }
if (_devTime > 5.0) Shot("x_journey_noon");
if (_devTime > 5.2 && !_shots.Contains("x_dusk")) { _shots.Add("x_dusk"); _hub!.DevDayPhase = 0.52f; }
if (_devTime > 5.8) Shot("x_journey_dusk");
if (_devTime > 6.0 && !_shots.Contains("x_night")) { _shots.Add("x_night"); _hub!.DevDayPhase = 0.78f; }
if (_devTime > 6.8) Shot("x_journey_night");
if (_devTime > 7.0 && !_shots.Contains("x_close")) { _shots.Add("x_close"); _hub!.DevOpen("none"); _hub.DevDayPhase = null; }
if (_devTime > 7.6) Shot("x_away");
if (_devTime > 7.9 && !_shots.Contains("x_back")) { _shots.Add("x_back"); _game!.DevExpeditionOutcome = true; _game.Tick(Adventures.Durations[1] + 1); }
// Heimkehr (Erfolg): Lauf, Titel und Tagebuch, Karten, fertig
if (_devTime > 8.8) Shot("x_home_walk");
if (_devTime > 11.4) Shot("x_home_title");
if (_devTime > 14.2) Shot("x_home_cards");
if (_devTime > 19.0) Shot("x_home_done");
if (_devTime > 19.3 && !_shots.Contains("x_fail_go")) { _shots.Add("x_fail_go"); _game!.DismissExpeditionResult(); _game.DevExpeditionOutcome = false; _game.StartExpedition("gallia", 0); _game.Tick(Adventures.Durations[0] + 1); }
if (_devTime > 25.0) Shot("x_home_fail");
if (_devTime > 25.3 && !_shots.Contains("x_event")) { _shots.Add("x_event"); _game!.DismissExpeditionResult(); _game.DevExpeditionOutcome = null; _game.DevEvent("nightduel"); }
if (_devTime > 26.0) Shot("x_eventcard");
if (_devTime > 26.3 && !_shots.Contains("x_choose")) { _shots.Add("x_choose"); _game!.Choose(0); }
if (_devTime > 26.7 && _capture == null && _shots.Contains("x_choose")) { DevShot.Log($"adventure: buffs={_game!.Buffs.Count} gold={_game.Gold:0}"); Exit(); }
return;
}
if (DevChampionRun && !_shots.Contains("m_end"))
@@ -605,6 +635,8 @@ namespace GladiatorIdle
if (d.Player.State == DuelState.Block && d.Player.StateTime > 0.1) Shot("m_block");
if (d.Player.State == DuelState.Hit && d.Player.StateTime < 0.03) Shot("m_hurt");
if (_scene.Over && !_shots.Contains("m_ko")) Shot("m_ko");
if (_scene.MissioTime > 2.2f) Shot("m_missio_vote");
if (_scene.MissioTime > 3.6f) Shot("m_missio_choice");
if (_scene.Finished) Shot("m_end");
if (_shots.Contains("m_end") && _capture == null && !_shots.Contains("m_logged"))
{

View File

@@ -72,6 +72,19 @@ namespace GladiatorIdle.Gfx
if (line.Length > 0 && y <= r.Bottom + lineH) Text(sb, fs, px, line, new Vector2(r.X, y), c);
}
/// Zeilen, die TextWrap für diesen Text in dieser Breite braucht.
public static int WrapLines(FontSystem fs, float px, string text, float width)
{
int lines = 1; string line = "";
foreach (var word in text.Split(' '))
{
string next = line.Length == 0 ? word : line + " " + word;
if (line.Length > 0 && Measure(fs, px, next).X > width) { lines++; line = word; }
else line = next;
}
return lines;
}
/// Balken mit verzögertem Rest (weißer Abschnitt zeigt den gerade verlorenen Teil).
public static void Bar(SpriteBatch sb, RectangleF r, float value, float lag, Color c, bool fromRight = false)
{

62
Mono/Gfx/Mesh3D.cs Normal file
View File

@@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
namespace GladiatorIdle.Gfx
{
/// <summary>
/// Einfaches Gitter für Kulissen (Arena, Reise): Vierecke, Quader, Zylinder mit Farbe und
/// Textur-Koordinaten; einmal gebaut (<see cref="Freeze"/>) und mit BasicEffect gezeichnet.
/// </summary>
internal sealed class Mesh3D
{
public readonly List<VertexPNCT> V = new();
public readonly List<int> I = new();
public Texture2D? Tex;
public bool Lit = true, Wrap, Mirror, Fog = true;
public Vector3 Tint = Vector3.One;
public VertexPNCT[]? VA; public int[]? IA;
public void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 n, Color col,
Vector2 ta, Vector2 tb, Vector2 tc, Vector2 td)
{
int i = V.Count;
V.Add(new VertexPNCT { Position = a, Normal = n, Color = col, Uv = ta });
V.Add(new VertexPNCT { Position = b, Normal = n, Color = col, Uv = tb });
V.Add(new VertexPNCT { Position = c, Normal = n, Color = col, Uv = tc });
V.Add(new VertexPNCT { Position = d, Normal = n, Color = col, Uv = td });
I.AddRange(new[] { i, i + 1, i + 2, i, i + 2, i + 3 });
}
/// Quader (achsengerade), Mitte c, Größe s.
public void Box(Vector3 c, Vector3 s, Color col)
{
var h = s / 2;
Vector3 P(float x, float y, float z) => c + new Vector3(x * h.X, y * h.Y, z * h.Z);
var z0 = Vector2.Zero;
Quad(P(-1, -1, 1), P(1, -1, 1), P(1, 1, 1), P(-1, 1, 1), Vector3.UnitZ, col, z0, z0, z0, z0);
Quad(P(1, -1, -1), P(-1, -1, -1), P(-1, 1, -1), P(1, 1, -1), -Vector3.UnitZ, col, z0, z0, z0, z0);
Quad(P(-1, -1, -1), P(-1, -1, 1), P(-1, 1, 1), P(-1, 1, -1), -Vector3.UnitX, col, z0, z0, z0, z0);
Quad(P(1, -1, 1), P(1, -1, -1), P(1, 1, -1), P(1, 1, 1), Vector3.UnitX, col, z0, z0, z0, z0);
Quad(P(-1, -1, -1), P(1, -1, -1), P(1, -1, 1), P(-1, -1, 1), -Vector3.UnitY, col, z0, z0, z0, z0);
}
/// Senkrechter Zylinder (Becken, Pfosten): Mitte unten c, Radius r, Höhe h (nach oben = −y).
public void Cylinder(Vector3 c, float r, float h, Color col, int seg = 12, float rTop = -1)
{
if (rTop < 0) rTop = r;
var z0 = Vector2.Zero;
for (int i = 0; i < seg; i++)
{
float a0 = MathF.Tau * i / seg, a1 = MathF.Tau * (i + 1) / seg;
Vector3 Pt(float a, float rad, float y) => c + new Vector3(MathF.Cos(a) * rad, y, MathF.Sin(a) * rad);
var n = new Vector3(MathF.Cos((a0 + a1) / 2), 0, MathF.Sin((a0 + a1) / 2));
Quad(Pt(a0, r, 0), Pt(a1, r, 0), Pt(a1, rTop, -h), Pt(a0, rTop, -h), n, col, z0, z0, z0, z0);
Quad(Pt(a0, rTop, -h), Pt(a1, rTop, -h), c + new Vector3(0, -h, 0), c + new Vector3(0, -h, 0), -Vector3.UnitY, col, z0, z0, z0, z0);
}
}
public void Freeze() { VA = V.ToArray(); IA = I.ToArray(); }
}
}