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

543
Mono/Arena/ArenaSet.cs Normal file
View File

@@ -0,0 +1,543 @@
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
{
/// Licht und Ausstattung einer Arena (Duell-Kulisse).
internal sealed record ArenaLook(
string Wall, Vector3 SunDir, Vector3 Sun, Vector3 Ambient, Vector3 Fog, float FogStart, float FogEnd,
Vector3 Sand, Color Banner, int Braziers, bool Posts, float Horizon, float BackdropLight)
{
/// Je Arena (Index wie <see cref="ArenaDef"/>): Tageszeit, Mauer, Farben. Sonnenrichtung = Richtung,
/// in die das Licht fällt (y nach unten = von oben).
public static readonly ArenaLook[] All =
{
// Ludus: Nachmittag, Holzzaun, Übungspfosten
new("wood", new(0.55f, 0.75f, -0.35f), new(1.00f, 0.88f, 0.70f), new(0.44f, 0.40f, 0.36f), new(0.78f, 0.66f, 0.50f), 2600, 11000,
new(1.00f, 0.90f, 0.74f), new Color(150, 60, 40), 0, true, 0.64f, 0.95f),
// Provinz: goldener Abend
new("wood", new(-0.65f, 0.55f, -0.45f), new(1.00f, 0.76f, 0.52f), new(0.40f, 0.33f, 0.30f), new(0.82f, 0.58f, 0.38f), 2400, 10000,
new(1.00f, 0.84f, 0.66f), new Color(190, 140, 50), 2, false, 0.70f, 0.95f),
// Capua: Mittag, Stein
new("stone", new(0.25f, 0.92f, -0.30f), new(1.00f, 0.97f, 0.90f), new(0.48f, 0.46f, 0.44f), new(0.80f, 0.76f, 0.70f), 2800, 12000,
new(1.00f, 0.92f, 0.78f), new Color(170, 40, 35), 0, false, 0.86f, 1.0f),
// Pompeji: Sonnenuntergang
new("stone", new(-0.75f, 0.42f, -0.50f), new(1.00f, 0.62f, 0.40f), new(0.40f, 0.31f, 0.31f), new(0.78f, 0.47f, 0.36f), 2400, 10000,
new(0.98f, 0.80f, 0.64f), new Color(200, 100, 30), 2, false, 0.80f, 0.95f),
// Circus Maximus: staubig
new("stone", new(0.45f, 0.78f, -0.42f), new(1.00f, 0.86f, 0.66f), new(0.46f, 0.40f, 0.34f), new(0.84f, 0.70f, 0.52f), 2000, 9000,
new(1.00f, 0.88f, 0.70f), new Color(40, 120, 70), 0, false, 0.80f, 0.95f),
// Kolosseum: hell unter dem Sonnensegel
new("stone", new(0.30f, 0.88f, -0.32f), new(1.00f, 0.92f, 0.80f), new(0.50f, 0.45f, 0.40f), new(0.80f, 0.70f, 0.56f), 2800, 12000,
new(1.00f, 0.90f, 0.74f), new Color(160, 35, 35), 2, false, 0.84f, 1.0f),
// Vor dem Kaiser: Dämmerung, Fackeln, Marmor
new("marble", new(-0.30f, 0.70f, -0.60f), new(0.80f, 0.64f, 0.72f), new(0.34f, 0.28f, 0.34f), new(0.40f, 0.29f, 0.38f), 2200, 9500,
new(0.92f, 0.78f, 0.68f), new Color(90, 30, 110), 4, false, 0.90f, 0.9f),
};
public static ArenaLook For(int arena) => All[Math.Clamp(arena, 0, All.Length - 1)];
}
/// <summary>
/// Kulisse des Duells in echtem 3D: Sandboden in Perspektive, gebogene Arenamauer mit Toren und
/// Bannern, Kohlebecken (Feuer als Lichter), im Ludus Übungspfosten; dahinter das Arena-Gemälde
/// (bzw. sein Video) weit entfernt auf einem Zylinderstück, sodass die Mauer seinen gemalten
/// Boden verdeckt. Licht und Dunst je Arena (<see cref="ArenaLook"/>).
/// </summary>
internal sealed class ArenaSet
{
// Mauer: Kreisbogen um (CX, ·, ZC); vorderster Punkt bei z = ZC − R
const float CX = Camera.W / 2, ZC = 2400, R = 3800, WALL_H = 300, BACK_R = 6500;
// Ränge hinter der Mauer: Stufen (Höhe, Tiefe), Säulenreihe obenauf
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();
readonly Part _backdrop, _banners;
readonly List<Vector3> _fires = new();
readonly List<(float Angle, float Phase)> _bannerAt = new();
readonly BasicEffect _fx;
readonly Texture2D? _still;
readonly string? _loop;
readonly int _rows;
readonly bool _colonnade;
// Publikum auf den Rängen: Bilder der Zuschauer (ruhig/jubelnd), jedes Bild neu gebaut (wippen, jubeln)
sealed class Fan { public Vector3 Base, Right; public float H, Phase, Threshold; public int Kind; public bool Mirror; }
readonly List<Fan> _fans = new();
readonly List<(Texture2D Calm, Texture2D Cheer)> _fanTex = new();
readonly AlphaTestEffect _fanFx;
// je Bild (ruhig/jubelnd je Zuschauerbild) feste Punkt-Arrays: keine neuen Objekte je Bild
VertexPositionColorTexture[][] _fanV = null!;
int[] _fanN = null!;
// Kulisse je Arena nur einmal bauen (Hub, Duell, Freiheit teilen sie)
static readonly Dictionary<(int, bool), ArenaSet> _cache = new();
public static ArenaSet Get(int arena, string backdropArt, bool calm)
{
if (!_cache.TryGetValue((arena, calm), out var s)) _cache[(arena, calm)] = s = new ArenaSet(arena, backdropArt, calm);
return s;
}
public ArenaLook Look => _look;
ArenaSet(int arena, string backdropArt, bool calm)
{
_look = ArenaLook.For(arena);
_still = Assets.Sprite(backdropArt, "jpg");
_loop = calm ? null : backdropArt;
_fx = new BasicEffect(Assets.Device) { VertexColorEnabled = true, TextureEnabled = true, PreferPerPixelLighting = true };
// Ludus: Hof mit Säulengang, keine Ränge; Provinz: wenige Holzränge; sonst volle Steinränge
_rows = _look.Posts ? 0 : _look.Wall == "wood" ? 4 : 7;
_colonnade = _look.Wall != "wood" || _look.Posts;
_backdrop = BuildBackdrop();
_parts.Add(BuildFloor());
_parts.Add(BuildStands());
if (_colonnade) _parts.Add(BuildColonnade());
_parts.Add(BuildWall());
_parts.Add(BuildCoping());
if (Assets.Sprite("tex_gate", "jpg") is Texture2D gate) _parts.Add(BuildGates(gate));
_parts.Add(BuildProps());
_banners = new Part { Tex = Assets.Sprite("tex_banner", "jpg"), Tint = _look.Banner.ToVector3() * 1.15f };
foreach (var a in new[] { -50f, -14f, 14f, 50f }) _bannerAt.Add((a, a * 0.13f));
foreach (var p in _parts) p.Freeze();
_backdrop.Freeze();
for (int i = 1; i <= 6; i++)
if (Assets.Sprite($"spectator_{i}") is Texture2D idle) _fanTex.Add((idle, Assets.Sprite($"spectator_{i}_cheer") ?? idle));
_fanFx = new AlphaTestEffect(Assets.Device) { VertexColorEnabled = true, ReferenceAlpha = 110, AlphaFunction = CompareFunction.Greater };
if (_fanTex.Count > 0 && _rows > 0) SeatFans(arena);
_fanV = new VertexPositionColorTexture[_fanTex.Count * 2][];
_fanN = new int[_fanV.Length];
for (int i = 0; i < _fanV.Length; i++)
{
int n = 0; foreach (var f in _fans) if (f.Kind == i / 2) n++;
_fanV[i] = new VertexPositionColorTexture[n * 6];
}
}
static float RowTop(int i) => Floor - WALL_H - 14 - (i + 1) * ROW_H;
static float RowR(int i) => R + 30 + i * ROW_D;
/// Stufen der Ränge: je Reihe eine senkrechte Setzstufe und eine waagrechte Sitzfläche.
Part BuildStands()
{
var p = new Part { Tex = Assets.Pixel };
var (tread, riser) = _look.Wall switch
{
"wood" => (new Color(112, 82, 56), new Color(78, 56, 38)),
"marble" => (new Color(222, 214, 202), new Color(168, 156, 148)),
_ => (new Color(186, 172, 150), new Color(132, 120, 104)),
};
const int SEG = 80;
for (int i = 0; i < _rows; i++)
{
float yLow = i == 0 ? Floor - WALL_H - 14 : RowTop(i - 1), yTop = RowTop(i), r0 = RowR(i), r1 = r0 + ROW_D;
var shade = (i % 2 == 0) ? 1f : 0.94f;
for (int k = 0; k < SEG; k++)
{
float d0 = -78 + 156f * k / SEG, d1 = -78 + 156f * (k + 1) / SEG;
var z0 = Vector2.Zero;
p.Quad(OnWall(d0, r0, yTop), OnWall(d1, r0, yTop), OnWall(d1, r0, yLow), OnWall(d0, r0, yLow), Inward((d0 + d1) / 2), riser * shade, z0, z0, z0, z0);
p.Quad(OnWall(d0, r1, yTop), OnWall(d1, r1, yTop), OnWall(d1, r0, yTop), OnWall(d0, r0, yTop), -Vector3.UnitY, tread * shade, z0, z0, z0, z0);
}
}
return p;
}
/// Säulenreihe mit Gebälk über den Rängen (im Ludus: Säulengang hinter dem Zaun), dahinter dunkler Gang.
Part BuildColonnade()
{
var p = new Part { Tex = Assets.Pixel };
float baseY = _rows > 0 ? RowTop(_rows - 1) : Floor, r = _rows > 0 ? RowR(_rows - 1) + ROW_D - 20 : R + 320;
float h = _rows > 0 ? COL_H : COL_H + 160;
var stone = _look.Wall == "marble" ? new Color(226, 218, 204) : _look.Wall == "wood" ? new Color(206, 196, 178) : new Color(196, 184, 162);
float step = _look.Wall == "marble" ? 4.5f : 6;
for (float a = -78; a <= 78.01f; a += step)
{
var c = OnWall(a, r, baseY);
p.Cylinder(c, 24, h, stone, 12);
p.Cylinder(c, 34, 18, stone * 0.9f, 10); // Basis
p.Cylinder(c + new Vector3(0, -h + 20, 0), 32, 20, stone * 0.9f, 10); // Kapitell
}
const int SEG = 80;
for (int k = 0; k < SEG; k++)
{
float d0 = -78 + 156f * k / SEG, d1 = -78 + 156f * (k + 1) / SEG;
var z0 = Vector2.Zero;
float top = baseY - h, n = (d0 + d1) / 2;
// Gebälk vorn und oben
p.Quad(OnWall(d0, r - 40, top - 56), OnWall(d1, r - 40, top - 56), OnWall(d1, r - 40, top), OnWall(d0, r - 40, top), Inward(n), stone, z0, z0, z0, z0);
p.Quad(OnWall(d0, r + 120, top - 56), OnWall(d1, r + 120, top - 56), OnWall(d1, r - 40, top - 56), OnWall(d0, r - 40, top - 56), -Vector3.UnitY, stone * 0.85f, z0, z0, z0, z0);
// hinter den Säulen offen: dort sieht man das Arena-Gemälde (Boden des Gangs bleibt)
p.Quad(OnWall(d0, r + 120, baseY), OnWall(d1, r + 120, baseY), OnWall(d1, r - 40, baseY), OnWall(d0, r - 40, baseY), -Vector3.UnitY, stone * 0.6f, z0, z0, z0, z0);
}
return p;
}
/// Zuschauer auf die Ränge setzen (dichter in großen Arenen; einige Lücken).
void SeatFans(int arena)
{
var rng = new Random(arena * 977 + 13);
float gap = _look.Wall == "wood" ? 74 : 54;
for (int i = 0; i < _rows; i++)
{
float r = RowR(i) + ROW_D * 0.42f;
float step = MathHelper.ToDegrees(gap / r);
for (float a = -77; a <= 77; a += step * (0.8f + 0.4f * (float)rng.NextDouble()))
{
if (rng.NextDouble() < 0.1) continue; // freier Platz
float rad = MathHelper.ToRadians(a);
_fans.Add(new Fan
{
Base = OnWall(a, r, RowTop(i) + 6),
Right = new Vector3(MathF.Cos(rad), 0, MathF.Sin(rad)),
H = 118 * (0.88f + 0.24f * (float)rng.NextDouble()),
Phase = (float)(rng.NextDouble() * 10),
Threshold = 0.15f + 0.8f * (float)rng.NextDouble(),
Kind = rng.Next(_fanTex.Count),
Mirror = rng.NextDouble() < 0.5,
});
}
}
}
void DrawFans(GraphicsDevice gd, Matrix view3, Matrix proj3, double time, float excite)
{
if (_fans.Count == 0) return;
Array.Clear(_fanN);
float t = (float)time;
// Publikum etwas im Halbschatten der Ränge: dunkler als die Kämpfer, die so vorn bleiben
var light = Vector3.Clamp((_look.Ambient + _look.Sun * 0.5f) * 0.74f, Vector3.Zero, Vector3.One);
var col = new Color(light);
foreach (var f in _fans)
{
bool cheer = excite > f.Threshold;
float bob = cheer ? MathF.Abs(MathF.Sin(t * 6.5f + f.Phase)) * 16 * (0.5f + excite) : MathF.Sin(t * 1.4f + f.Phase) * 2;
var (calm, cheerTex) = _fanTex[f.Kind];
var tex = cheer ? cheerTex : calm;
float w = f.H * tex.Width / tex.Height;
var b = f.Base + new Vector3(0, -bob, 0);
var right = f.Right * (w / 2);
var up = new Vector3(0, -f.H, 0);
float u0 = f.Mirror ? 1 : 0, u1 = 1 - u0;
int k = f.Kind * 2 + (cheer ? 1 : 0);
var arr = _fanV[k]; ref int n = ref _fanN[k];
arr[n++] = new VertexPositionColorTexture(b - right + up, col, new Vector2(u0, 0));
arr[n++] = new VertexPositionColorTexture(b + right + up, col, new Vector2(u1, 0));
arr[n++] = new VertexPositionColorTexture(b + right, col, new Vector2(u1, 1));
arr[n++] = new VertexPositionColorTexture(b - right + up, col, new Vector2(u0, 0));
arr[n++] = new VertexPositionColorTexture(b + right, col, new Vector2(u1, 1));
arr[n++] = new VertexPositionColorTexture(b - right, col, new Vector2(u0, 1));
}
_fanFx.World = Matrix.Identity; _fanFx.View = view3; _fanFx.Projection = proj3;
_fanFx.FogEnabled = true; _fanFx.FogColor = _look.Fog; _fanFx.FogStart = _look.FogStart * 0.55f; _fanFx.FogEnd = _look.FogEnd * 0.9f;
gd.DepthStencilState = DepthStencilState.Default;
gd.BlendState = BlendState.Opaque;
for (int k = 0; k < _fanV.Length; k++)
{
if (_fanN[k] == 0) continue;
var (calm, cheerTex) = _fanTex[k / 2];
_fanFx.Texture = Assets.Mipmapped(k % 2 == 1 ? cheerTex : calm);
foreach (var pass in _fanFx.CurrentTechnique.Passes)
{
pass.Apply();
gd.SamplerStates[0] = Clamp;
gd.DrawUserPrimitives(PrimitiveType.TriangleList, _fanV[k], 0, _fanN[k] / 3);
}
}
}
static Vector3 OnWall(float deg, float radius, float y)
{
float a = MathHelper.ToRadians(deg);
return new Vector3(CX + radius * MathF.Sin(a), y, ZC - radius * MathF.Cos(a));
}
static Vector3 Inward(float deg) { float a = MathHelper.ToRadians(deg); return new Vector3(-MathF.Sin(a), 0, MathF.Cos(a)); }
// ── Bauteile ────────────────────────────────────────────────
/// Arena-Gemälde weit hinten: Zylinderstück, ±30° = ganzes Bild, außen gespiegelt (Schwenks).
Part BuildBackdrop()
{
var p = new Part { Lit = false, Mirror = true, Fog = false, Tint = Vector3.Lerp(new Vector3(_look.BackdropLight), _look.Fog, 0.18f) };
const float SPAN = 30, EXTRA = 60;
float width = BACK_R * MathHelper.ToRadians(2 * SPAN), height = width * 9 / 16;
// Bildzeile "Horizon" (dort beginnt der gemalte Boden) liegt knapp unter der Mauerkrone
float wallTop = HorizonY();
float top = wallTop - _look.Horizon * height;
const int SEG = 40;
for (int i = 0; i < SEG; i++)
{
float d0 = -EXTRA + 2 * EXTRA * i / SEG, d1 = -EXTRA + 2 * EXTRA * (i + 1) / SEG;
float u0 = (d0 + SPAN) / (2 * SPAN), u1 = (d1 + SPAN) / (2 * SPAN);
p.Quad(OnWall(d0, BACK_R, top), OnWall(d1, BACK_R, top), OnWall(d1, BACK_R, top + height), OnWall(d0, BACK_R, top + height),
Inward((d0 + d1) / 2), Color.White, new Vector2(u0, 0), new Vector2(u1, 0), new Vector2(u1, 1), new Vector2(u0, 1));
}
return p;
}
/// Höhe (y) auf dem fernen Bild, die hinter der Mauerkrone liegt (von der Kamera aus gesehen).
static float HorizonY()
{
float wFront = (Camera.DIST + (R - ZC)) / Camera.DIST; // Mauer vorn
float wBack = (Camera.DIST + (BACK_R - ZC)) / Camera.DIST; // Gemälde
float screenY = (Floor - WALL_H + Camera.EYE_Y * (wFront - 1)) / wFront;
return screenY * wBack - Camera.EYE_Y * (wBack - 1) + 40;
}
/// Sandboden als Gitter: Farbe leicht dunkler am Mauerfuß und in der getretenen Kampfmitte.
Part BuildFloor()
{
var p = new Part { Tex = Assets.Sprite("tex_sand", "jpg"), Wrap = true, Tint = _look.Sand * new Vector3(0.86f, 0.88f, 0.98f) };
const int NX = 40, NZ = 16;
float x0 = CX - 5200, x1 = CX + 5200, z0 = -(R - ZC) - 900, z1 = 900;
Vector3 Pt(int i, int k) => new(x0 + (x1 - x0) * i / NX, Floor, z0 + (z1 - z0) * k / NZ);
Color Shade(Vector3 v)
{
float toWall = MathF.Sqrt((v.X - CX) * (v.X - CX) + (v.Z - ZC) * (v.Z - ZC));
float ao = MathHelper.Clamp((R - toWall) / 500, 0, 1); // 0 am Mauerfuß
float mid = MathF.Sqrt((v.X - CX) * (v.X - CX) / 1.0f + v.Z * v.Z * 2.2f);
float trod = MathHelper.Clamp(1 - mid / 900, 0, 1);
float s = (0.62f + 0.38f * ao) * (1 - 0.12f * trod);
return new Color(s, s * 0.98f, s * 0.95f);
}
for (int i = 0; i < NX; i++)
for (int k = 0; k < NZ; k++)
{
Vector3 a = Pt(i, k + 1), b = Pt(i + 1, k + 1), c = Pt(i + 1, k), d = Pt(i, k);
Vector2 T(Vector3 v) => new(v.X / 420f, v.Z / 420f);
int n = p.V.Count;
foreach (var v in new[] { a, b, c, d })
p.V.Add(new VertexPNCT { Position = v, Normal = -Vector3.UnitY, Color = Shade(v), Uv = T(v) });
p.I.AddRange(new[] { n, n + 1, n + 2, n, n + 2, n + 3 });
}
return p;
}
string WallTex => _look.Wall switch { "wood" => "tex_wall_wood", "marble" => "tex_wall_marble", _ => "tex_wall_stone" };
Part BuildWall()
{
var tint = _look.Wall == "wood" ? new Vector3(1.05f, 0.82f, 0.62f) : Vector3.One; // Holz wärmer als die graue Vorlage
var p = new Part { Tex = Assets.Sprite(WallTex, "jpg"), Wrap = true, Tint = tint };
const int SEG = 72;
const float FROM = -75, TO = 75;
float tile = WALL_H * 3; // Textur 3:1
for (int i = 0; i < SEG; i++)
{
float d0 = FROM + (TO - FROM) * i / SEG, d1 = FROM + (TO - FROM) * (i + 1) / SEG;
float u0 = R * MathHelper.ToRadians(d0) / tile, u1 = R * MathHelper.ToRadians(d1) / tile;
p.Quad(OnWall(d0, R, Floor - WALL_H), OnWall(d1, R, Floor - WALL_H), OnWall(d1, R, Floor), OnWall(d0, R, Floor),
Inward((d0 + d1) / 2), Color.White, new Vector2(u0, 0), new Vector2(u1, 0), new Vector2(u1, 1), new Vector2(u0, 1));
}
return p;
}
/// Mauerkrone: flache Abdeckung, etwas heller, ragt nach innen.
Part BuildCoping()
{
var p = new Part { Tex = Assets.Pixel };
var col = _look.Wall switch { "wood" => new Color(92, 66, 44), "marble" => new Color(214, 196, 150), _ => new Color(196, 184, 160) };
const int SEG = 72;
for (int i = 0; i < SEG; i++)
{
float d0 = -75 + 150f * i / SEG, d1 = -75 + 150f * (i + 1) / SEG;
var z0 = Vector2.Zero;
float y = Floor - WALL_H;
p.Quad(OnWall(d0, R + 30, y - 14), OnWall(d1, R + 30, y - 14), OnWall(d1, R - 26, y - 14), OnWall(d0, R - 26, y - 14),
-Vector3.UnitY, col, z0, z0, z0, z0);
p.Quad(OnWall(d0, R - 26, y - 14), OnWall(d1, R - 26, y - 14), OnWall(d1, R - 26, y + 10), OnWall(d0, R - 26, y + 10),
Inward((d0 + d1) / 2), col * 0.8f, z0, z0, z0, z0);
}
return p;
}
/// Tore in der Mauer (links und rechts, beim Kaiser auch in der Mitte).
Part BuildGates(Texture2D gate)
{
var p = new Part { Tex = gate };
var at = _look.Wall == "marble" ? new[] { -30f, 0f, 30f } : new[] { -30f, 30f };
foreach (float a in at)
{
float half = MathHelper.ToDegrees(130 / R); // 260 breit
float y0 = Floor - WALL_H + 22;
p.Quad(OnWall(a - half, R - 3, y0), OnWall(a + half, R - 3, y0), OnWall(a + half, R - 3, Floor), OnWall(a - half, R - 3, Floor),
Inward(a), Color.White, new Vector2(0.08f, 0.04f), new Vector2(0.92f, 0.04f), new Vector2(0.92f, 0.98f), new Vector2(0.08f, 0.98f));
}
return p;
}
/// Kohlebecken (Feuer als Licht), im Ludus Holzpfosten.
Part BuildProps()
{
var p = new Part { Tex = Assets.Pixel };
var bronze = new Color(86, 62, 38); var iron = new Color(46, 40, 36); var wood = new Color(104, 72, 46);
float[] fire = _look.Braziers switch { 4 => new[] { -42f, -18f, 18f, 42f }, 2 => new[] { -40f, 40f }, _ => Array.Empty<float>() };
foreach (float a in fire)
{
var c = OnWall(a, R - 170, Floor);
p.Cylinder(c, 9, 120, iron, 8); // Säule
p.Cylinder(c + new Vector3(0, -120, 0), 22, 26, bronze, 14, 46); // Schale (oben weiter)
p.Cylinder(c, 30, 8, iron, 10); // Fuß
_fires.Add(c + new Vector3(0, -150, 0));
}
if (_look.Posts)
foreach (var (x, z, h) in new[] { (180f, -620f, 170f), (1760f, -520f, 150f), (-220f, -980f, 190f), (2240f, -880f, 160f), (960f, -1100f, 140f) })
{
p.Cylinder(new Vector3(x, Floor, z), 20, h, wood, 10);
p.Box(new Vector3(x, Floor - h * 0.7f, z), new Vector3(70, 12, 12), wood * 0.85f); // Querholz
}
return p;
}
// ── Zeichnen ────────────────────────────────────────────────
void Light(Part p)
{
_fx.LightingEnabled = p.Lit;
_fx.FogEnabled = p.Fog;
_fx.FogColor = _look.Fog;
_fx.FogStart = _look.FogStart; _fx.FogEnd = _look.FogEnd;
_fx.DiffuseColor = p.Tint;
if (!p.Lit) return;
_fx.AmbientLightColor = _look.Ambient;
_fx.DirectionalLight0.Enabled = true;
_fx.DirectionalLight0.Direction = Vector3.Normalize(_look.SunDir);
_fx.DirectionalLight0.DiffuseColor = _look.Sun;
_fx.DirectionalLight0.SpecularColor = Vector3.Zero;
_fx.DirectionalLight1.Enabled = false;
_fx.DirectionalLight2.Enabled = false;
}
static readonly SamplerState WrapMirror = new() { AddressU = TextureAddressMode.Mirror, AddressV = TextureAddressMode.Clamp, Filter = TextureFilter.Anisotropic, MaxAnisotropy = 8 };
static readonly SamplerState Wrap = new() { AddressU = TextureAddressMode.Wrap, AddressV = TextureAddressMode.Wrap, Filter = TextureFilter.Anisotropic, MaxAnisotropy = 8 };
static readonly SamplerState Clamp = new() { AddressU = TextureAddressMode.Clamp, AddressV = TextureAddressMode.Clamp, Filter = TextureFilter.Anisotropic, MaxAnisotropy = 8 };
void DrawPart(GraphicsDevice gd, Part p, Texture2D? tex = null)
{
if (p.VA == null || p.VA.Length == 0) return;
// feste Texturen mit Stufen gegen Flimmern in der Tiefe; das ferne Gemälde (Video-Bilder) ohne
_fx.Texture = tex ?? (p.Tex == null || p.Tex == Assets.Pixel ? Assets.Pixel : Assets.Mipmapped(p.Tex));
Light(p);
foreach (var pass in _fx.CurrentTechnique.Passes)
{
pass.Apply();
gd.SamplerStates[0] = p.Mirror ? WrapMirror : p.Wrap ? Wrap : Clamp;
gd.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, p.VA, 0, p.VA.Length, p.IA, 0, p.IA!.Length / 3);
}
}
/// Kulisse zeichnen (mit Tiefe), danach liegen Schatten und Kämpfer darauf.
public void Draw(GraphicsDevice gd, Matrix view3, Matrix proj3, double time, float excite = 0.3f)
{
_fx.World = Matrix.Identity; _fx.View = view3; _fx.Projection = proj3;
gd.BlendState = BlendState.Opaque;
gd.RasterizerState = RasterizerState.CullNone;
// fernes Gemälde ohne Tiefe, dann alles andere mit Tiefe
gd.DepthStencilState = DepthStencilState.None;
var loop = _loop != null ? ClipCache.Video(_loop) : null;
var bg = loop != null ? loop[PingPong(time * 8, loop.Length)] : _still;
if (bg != null) DrawPart(gd, _backdrop, bg);
gd.DepthStencilState = DepthStencilState.Default;
foreach (var p in _parts) DrawPart(gd, p);
DrawFans(gd, view3, proj3, time, excite);
// Banner schwingen leicht: jedes Bild neu
_banners.V.Clear(); _banners.I.Clear();
foreach (var (a, ph) in _bannerAt)
{
float half = MathHelper.ToDegrees(42 / R), sway = 9 * MathF.Sin((float)time * 1.3f + ph);
float y0 = Floor - WALL_H + 4, y1 = y0 + 190;
var top0 = OnWall(a - half, R - 6, y0); var top1 = OnWall(a + half, R - 6, y0);
var off = new Vector3(sway, 0, 0) + Inward(a) * 8;
_banners.Quad(top0, top1, OnWall(a + half, R - 6, y1) + off, OnWall(a - half, R - 6, y1) + off, Inward(a), Color.White,
new Vector2(0, 0), new Vector2(1, 0), new Vector2(1, 1), new Vector2(0, 1));
}
_banners.Freeze();
gd.BlendState = BlendState.Opaque;
DrawPart(gd, _banners);
gd.BlendState = BlendState.AlphaBlend;
}
/// Feuer der Kohlebecken als Licht (Bildschirm-Pixel, additiv), Größe nach Entfernung.
public void DrawFires(SpriteBatch sb, Camera cam, Matrix view3, Matrix proj3, int vpW, int vpH, float screenScale, double time)
{
int i = 0;
foreach (var f in _fires)
{
var px = cam.ToPixel(f, view3, proj3, vpW, vpH, out float w);
float k = screenScale / w, flick = 0.85f + 0.15f * MathF.Sin((float)time * 17 + i * 2.3f) * MathF.Sin((float)time * 5.1f + i);
D.Glow(sb, px + new Vector2(0, 30 * k), new Vector2(520 * k, 300 * k), new Color(255, 120, 40) * (0.30f * flick));
D.Glow(sb, px, new Vector2(110 * k, 160 * k * flick), new Color(255, 170, 60) * 0.9f);
D.Glow(sb, px - new Vector2(0, 18 * k), new Vector2(60 * k, 90 * k * flick), new Color(255, 230, 160) * 0.9f);
i++;
}
}
static int PingPong(double t, int n)
{
if (n <= 1) return 0;
int period = 2 * (n - 1), i = (int)t % period;
return i < n ? i : period - i;
}
}
}

View File

@@ -37,6 +37,7 @@ namespace GladiatorIdle.Arena
_trauma = MathF.Max(0, _trauma - dt * 1.7f);
_punch *= MathF.Exp(-dt * 9f);
if (calm) { _trauma = 0; _punch = 0; }
UpdateYaw(dt, calm);
}
/// Kameraverschiebung durch Rütteln (Design-Pixel).
@@ -48,6 +49,95 @@ namespace GladiatorIdle.Arena
s * (MathF.Cos((float)_t * 89) + 0.6f * MathF.Sin((float)_t * 151 + 0.7f)) / 1.6f);
}
// ── 3D: Perspektive, die die Kampfebene z = 0 genau wie die 2D-Ansicht abbildet ──
// Raum in Design-Pixeln: x rechts, y nach unten, z zum Betrachter; Kämpfer bei z = 0.
/// Augenhöhe (y) und Abstand der Kamera zur Kampfebene; Nah- und Fernebene.
public const float EYE_Y = 330, DIST = 2600, NEAR = 150, FAR = 16000;
/// Augenhöhe jetzt (atmet leicht, steigt beim Sprung mit).
public float EyeY { get; private set; } = EYE_Y;
float _lift, _liftTarget;
/// Kamera hebt sich kurz (Sprungangriff): Ziel in Design-Pixeln nach oben.
public void Lift(float amount) => _liftTarget = amount;
/// Drehung um die Bildmitte (Grad): Kinomomente. Basis gleitet zum Ziel, Puls schwingt hin und zurück.
public float Yaw { get; private set; }
float _yawBase, _yawTarget, _pulseAmp, _pulseDur, _pulseT = -1;
/// Kurzer Schwenk um die Kämpfer und zurück (Raserei, Treffer zum Sieg).
public void Pulse(float degrees, float seconds)
{
// ein laufender, größerer Schwenk wird nicht von einem kleinen unterbrochen
if (_pulseT >= 0 && MathF.Abs(_pulseAmp) > MathF.Abs(degrees) && _pulseT < _pulseDur * 0.7f) return;
_pulseAmp = degrees; _pulseDur = seconds; _pulseT = 0;
}
/// Langsame Fahrt auf einen festen Winkel (Sieg); 0 = zurück zur Seitenansicht.
public void HoldYaw(float degrees) => _yawTarget = degrees;
void UpdateYaw(float dt, bool calm)
{
_yawBase += (_yawTarget - _yawBase) * (1 - MathF.Exp(-dt * 0.9f));
float pulse = 0;
if (_pulseT >= 0)
{
_pulseT += dt;
float k = _pulseT / _pulseDur;
if (k >= 1) _pulseT = -1;
else pulse = _pulseAmp * MathF.Sin(MathF.PI * k);
}
// ständige leichte Bewegung: langsames Pendeln und Atmen der Höhe (wie eine Handkamera am Rand)
float drift = 3.2f * MathF.Sin((float)_t * 0.21f) + 1.3f * MathF.Sin((float)_t * 0.53f + 1.1f);
Yaw = calm ? 0 : _yawBase + pulse + drift;
_lift += (_liftTarget - _lift) * (1 - MathF.Exp(-dt * 4));
_liftTarget *= MathF.Exp(-dt * 1.5f);
EyeY = calm ? EYE_Y : EYE_Y + 22 * MathF.Sin((float)_t * 0.33f) - _lift;
}
/// Welt → Kameraraum (Kamera im Ursprung, Blick nach −z), mit Drehung um die Bildmitte.
public Matrix View3()
{
var pivot = new Vector3(Center.X, 0, 0);
return Matrix.CreateTranslation(-pivot) * Matrix.CreateRotationY(MathHelper.ToRadians(Yaw)) * Matrix.CreateTranslation(pivot)
* Matrix.CreateTranslation(-Center.X, -EyeY, -DIST);
}
/// Kameraraum → Bildschirm (Clip): erst perspektivisch zurück in Design-Pixel der Ebene z = 0,
/// dann dieselbe 2D-Abbildung wie <see cref="View"/> (Zoom, Wackeln, Stoß), dann Pixel → Clip.
public Matrix Proj3(float screenScale, Vector2 offset, int vpW, int vpH)
{
float ex = Center.X, ey = EyeY, d = DIST;
float a = -FAR / (d * (FAR - NEAR)), b = -NEAR * FAR / (d * (FAR - NEAR));
// Zeilen-Vektor-Form: (x, y, z, 1) → (X, Y, Z, W) mit W = −z/d (z = 0 der Welt ⇒ W = 1)
var p = new Matrix(
1, 0, 0, 0,
0, 1, 0, 0,
-ex / d, -ey / d, a, -1 / d,
0, 0, b, 0);
// Kameraraum hat den Ursprung bei (ex, ey, d): Design-Pixel = x_c + ex·W
var v2 = View(screenScale, offset); // nur x/y benutzen (2D-affin)
var a2 = new Matrix(
v2.M11, v2.M12, 0, 0,
v2.M21, v2.M22, 0, 0,
0, 0, 1, 0,
v2.M41, v2.M42, 0, 1);
var clip = new Matrix(
2f / vpW, 0, 0, 0,
0, -2f / vpH, 0, 0,
0, 0, 1, 0,
-1, 1, 0, 1);
return p * a2 * clip;
}
/// Weltpunkt → Bildschirm-Pixel; <c>w</c> &gt; 1 heißt weiter hinten (für Größen von Lichtern).
public Vector2 ToPixel(Vector3 world, Matrix view3, Matrix proj3, int vpW, int vpH, out float w)
{
var c = Vector4.Transform(new Vector4(world, 1), view3 * proj3);
w = MathF.Max(0.001f, c.W);
return new Vector2((c.X / w + 1) * 0.5f * vpW, (1 - c.Y / w) * 0.5f * vpH);
}
/// Design-Pixel → Bildschirm. <paramref name="parallax"/>: 1 = Ebene der Kämpfer, &lt;1 weiter hinten.
public Matrix View(float screenScale, Vector2 offset, float parallax = 1f)
{

View File

@@ -26,7 +26,8 @@ namespace GladiatorIdle.Arena
readonly Ui _ui = new();
readonly Particles _fx = new();
readonly Texture2D? _backdrop = Assets.Sprite("arena_ludus", "jpg");
readonly Stage3D _stage = new(0, AppSettings.ReduceMotion) { }; // Hof des Ludus in 3D
const float PREVIEW_X = 470;
FighterView _preview = null!;
// Vorschaubilder der Vorlagen: aus den 3D-Figuren gerendert (je Klasse einmal geladen)
const int THUMB_W = 296, THUMB_H = 340;
@@ -46,6 +47,7 @@ namespace GladiatorIdle.Arena
public CreatorScene(string name)
{
Name = name;
_stage.Cam.FocusX = 820; // Figur links groß, Auswahl rechts
SetClass(Class);
SoundManager.StartAmbient("music_menu");
}
@@ -75,7 +77,7 @@ namespace GladiatorIdle.Arena
_t += dt;
_ui.Begin(input, ui);
ShowcaseStep(dt);
_preview.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion);
_preview.Update(dt, dt, _dummy, PREVIEW_X, AppSettings.ReduceMotion);
_fx.Motes(AppSettings.ReduceMotion ? 0 : 50, Camera.W, Camera.H);
_fx.Update(dt);
}
@@ -108,32 +110,23 @@ namespace GladiatorIdle.Arena
D.UiScale = scale;
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
// Bühne: der Hof des Ludus in 3D, die Figur steht mit Schatten im Sand, die Kamera wandert langsam
_stage.Cam.Update(1 / 60f, PREVIEW_X, PREVIEW_X, AppSettings.ReduceMotion);
_stage.Cam.HoldYaw(12 * MathF.Sin((float)_t * 0.22f));
_stage.Prepare(gd, scale, offset);
_stage.DrawSet(gd, sb, _t, 0.3f);
_stage.Shadows(gd, sb, 0, _preview);
_stage.FloorLight(sb, PREVIEW_X, 900, 0.22f);
Stage3D.BeginFigures(gd);
_stage.Use(_preview);
_preview.DrawBody(gd, fx, _dummy, AppSettings.ReduceMotion);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
if (_backdrop != null)
{
float k = 1.1f * MathF.Max(Camera.W / _backdrop.Width, Camera.H / _backdrop.Height);
sb.Draw(_backdrop, new Vector2(Camera.W / 2, Camera.H / 2), null, new Color(0.42f, 0.38f, 0.34f), 0,
new Vector2(_backdrop.Width / 2f, _backdrop.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.7f);
D.Glow(sb, new Vector2(Camera.W + 200, Camera.H / 2), new Vector2(1400, 2000), Color.Black * 0.6f);
for (int i = 0; i < 14; i++)
D.Rect(sb, new RectangleF(0, i * 14, 900, 14), Color.Black * (0.45f * (1 - i / 14f)));
D.Text(sb, Assets.Serif, 56, L.t("create.title").ToUpperInvariant(), new Vector2(110, 78), D.Gold);
sb.End();
// Vorschau: eigene Kamera (größer), Lichtkegel, Schatten, Figur
var view = Matrix.CreateTranslation(0, -Stage.FloorY, 0) * Matrix.CreateScale(1.25f) * Matrix.CreateTranslation(470, 905, 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(900, 1100), new Color(255, 190, 120) * 0.16f);
D.Glow(sb, new Vector2(0, Stage.FloorY + 6), new Vector2(700, 120), new Color(255, 180, 110) * 0.25f);
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, view);
_preview.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;
_preview.DrawBody(gd, fx, _dummy, AppSettings.ReduceMotion);
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);
_fx.DrawAdd(sb);
sb.End();

View File

@@ -17,6 +17,22 @@ namespace GladiatorIdle.Arena
public bool Pressed(Keys k) => Keys.IsKeyDown(k) && !PrevKeys.IsKeyDown(k);
public bool LeftClick => Mouse.LeftButton == ButtonState.Pressed && PrevMouse.LeftButton == ButtonState.Released;
public bool RightHeld => Mouse.RightButton == ButtonState.Pressed;
// Gamepad (erster Spieler)
public GamePadState Pad, PrevPad;
/// Zuletzt benutztes Gerät war das Gamepad (Hinweise passen sich an).
public bool UsingPad;
public bool PadDown(Buttons b) => Pad.IsConnected && Pad.IsButtonDown(b);
public bool PadPressed(Buttons b) => Pad.IsConnected && Pad.IsButtonDown(b) && !PrevPad.IsButtonDown(b);
public float PadX => !Pad.IsConnected ? 0 : MathF.Abs(Pad.ThumbSticks.Left.X) > 0.35f ? MathF.Sign(Pad.ThumbSticks.Left.X)
: Pad.DPad.Left == ButtonState.Pressed ? -1 : Pad.DPad.Right == ButtonState.Pressed ? 1 : 0;
/// Gerät erkennen: Tasten/Maus → Tastatur, Knopf/Stick → Gamepad.
public void DetectDevice()
{
if (Pad.IsConnected && (Pad.Buttons != PrevPad.Buttons || Pad.ThumbSticks.Left.Length() > 0.5f || Pad.Triggers.Left > 0.4f || Pad.Triggers.Right > 0.4f)) UsingPad = true;
if (Keys.GetPressedKeyCount() > 0 || Mouse.LeftButton == ButtonState.Pressed || Mouse.Position != PrevMouse.Position) UsingPad = false;
}
}
/// <summary>
@@ -36,8 +52,10 @@ namespace GladiatorIdle.Arena
readonly Camera _cam = new();
readonly Particles _fx = new();
readonly Crowd _crowd;
readonly Texture2D? _backdrop;
readonly string? _loopName;
readonly Texture2D? _backdrop; // Standbild für das Champion-Intro
readonly ArenaSet _set; // 3D-Kulisse: Sand, Mauer, Tore, Feuer, fernes Gemälde
BasicEffect? _plane; // 2D-Effekte auf der Kampfebene (z = 0) durch die 3D-Kamera
bool _wasFury;
readonly bool _calm = AppSettings.ReduceMotion;
readonly AbilityBar _bar = new();
@@ -71,6 +89,94 @@ namespace GladiatorIdle.Arena
/// Testlauf: Bot steuert den Spieler.
public DuelBot? Bot;
// ── Einführung (erster Kampf) ──
public enum TutStep { Off, Move, Strike, Block, Parry, Dodge, Leap, Fury, Finish }
TutStep _tut;
int _tutCount, _tutTries;
double _tutT;
double _enemyWindup;
public TutStep Tutorial => _tut;
public bool TutorialRan { get; private set; }
public void StartTutorial()
{
TutorialRan = true;
_enemyWindup = Duel.Enemy.Windup;
Duel.GuardHp = true;
Duel.EnemyDamageMult = 0.5;
TutGo(TutStep.Move);
}
void TutGo(TutStep s)
{
_tut = s; _tutCount = 0; _tutTries = 0; _tutT = 0;
var e = Duel.Enemy;
Duel.EnemyPassive = s is TutStep.Move or TutStep.Strike or TutStep.Dodge or TutStep.Leap or TutStep.Fury;
Duel.EnemyAttacksOnly = s is TutStep.Block or TutStep.Parry;
e.Windup = s is TutStep.Block or TutStep.Parry ? 0.9 : _enemyWindup; // deutlich angekündigt
if (s == TutStep.Fury) Duel.Player.Rage = 100;
if (s == TutStep.Finish) { Duel.GuardHp = false; Duel.EnemyAttacksOnly = false; }
if (s != TutStep.Move) SoundManager.PlayTip();
}
void TutSkip()
{
Duel.EnemyPassive = Duel.EnemyAttacksOnly = Duel.GuardHp = false;
Duel.EnemyDamageMult = 1;
Duel.Enemy.Windup = _enemyWindup;
_tut = TutStep.Off;
}
/// Schritt an Zuständen erkennen (jedes Bild).
void TutUpdate(float realDt, Input input)
{
if (_tut == TutStep.Off) return;
_tutT += realDt;
if (input.Pressed(Keys.Tab)) { TutSkip(); return; }
var p = Duel.Player; var e = Duel.Enemy;
switch (_tut)
{
case TutStep.Move when Math.Abs(e.X - p.X) < p.Reach: TutGo(TutStep.Strike); break;
case TutStep.Dodge when p.State == DuelState.Dodge: TutGo(TutStep.Leap); break;
case TutStep.Leap when p.State == DuelState.Leap: TutGo(TutStep.Fury); break;
case TutStep.Fury when p.State == DuelState.Super: TutGo(TutStep.Finish); break;
case TutStep.Finish when Duel.Over: _tut = TutStep.Off; break;
}
if (_tut == TutStep.Parry && e.State == DuelState.Strike && e.StateTime < 0.02) _tutTries++;
if (_tut == TutStep.Parry && _tutTries >= 4) TutGo(TutStep.Dodge); // nicht hängen bleiben
}
/// Schritt an Ereignissen erkennen.
void TutEvent(DuelEvent e)
{
switch (_tut)
{
case TutStep.Strike when e.Type == DuelEventType.Hit && e.ByPlayer: if (++_tutCount >= 2) TutGo(TutStep.Block); break;
case TutStep.Block when e.Type == DuelEventType.Blocked && e.ByPlayer: TutGo(TutStep.Parry); break;
case TutStep.Block when e.Type == DuelEventType.Parry && e.ByPlayer: TutGo(TutStep.Dodge); break;
case TutStep.Parry when e.Type == DuelEventType.Parry && e.ByPlayer: TutGo(TutStep.Dodge); break;
}
}
/// Testläufe: erfüllt jeden Schritt der Einführung.
void TutBot()
{
var d = Duel; var p = d.Player; var e = d.Enemy;
int toward = e.X >= p.X ? 1 : -1;
d.MoveDir = 0; d.BlockHeld = false;
switch (_tut)
{
case TutStep.Move: d.MoveDir = toward; break;
case TutStep.Strike: if (!p.Busy) d.PressAttack(); break;
case TutStep.Block: d.BlockHeld = e.State is DuelState.Windup or DuelState.Strike; break;
case TutStep.Parry: d.BlockHeld = e.State == DuelState.Windup && e.StateTime > e.Windup - 0.1 || e.State == DuelState.Strike; break;
case TutStep.Dodge: if (_tutT > 0.8) d.PressDodge(); break;
case TutStep.Leap: if (_tutT > 0.8) d.PressLeap(); break;
case TutStep.Fury: if (_tutT > 0.8) d.PressSuper(); break;
default: Bot?.Act(d); break;
}
}
public DuelScene(GameState game, Enemy enemy, int seed)
{
_game = game;
@@ -88,7 +194,7 @@ namespace GladiatorIdle.Arena
_fx.Calm = _calm;
string arena = Art.Arena(ArenaDef.All[game.Arena]);
_backdrop = Assets.Sprite(arena, "jpg");
_loopName = _calm ? null : arena;
_set = ArenaSet.Get(game.Arena, arena, _calm);
_cam.Center = new Vector2(Camera.W / 2, Camera.H / 2 + 40);
_cam.Zoom = 1.45f; // Auftakt: nah, dann fährt die Kamera auf
_crowd.Excite(0.5f);
@@ -144,14 +250,16 @@ namespace GladiatorIdle.Arena
}
break;
case Phase.Fight:
if (Bot != null) Bot.Act(Duel);
if (Bot != null) { if (_tut != TutStep.Off) TutBot(); else Bot.Act(Duel); }
else Controls(input);
TutUpdate(realDt, input);
Duel.Step(dt);
HandleEvents();
if (Duel.Over)
{
_phase = Phase.End; _phaseTime = 0; Won = Duel.PlayerWon;
_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();
}
break;
@@ -190,6 +298,8 @@ namespace GladiatorIdle.Arena
{
var pl = Duel.Player;
bool fury = pl.State == DuelState.Super;
if (fury && !_wasFury && !_calm) _cam.Pulse(-22, 1.6f); // Kinomoment: die Kamera schwenkt herum und zurück
_wasFury = fury;
_furyDark += ((fury ? 1f : 0f) - _furyDark) * (1 - MathF.Exp(-realDt * (fury ? 7 : 2.5f)));
if (fury && _phase == Phase.Fight) _cam.FocusX = (_pv.X + _ev.X) / 2;
else if (_phase == Phase.Fight && _cam.FocusX != null) _cam.FocusX = null;
@@ -247,25 +357,40 @@ namespace GladiatorIdle.Arena
else if (!_pLanded && p.StateTime >= Duel.LEAP_HIT) { _pLanded = true; SoundManager.PlayLand(); _fx.Dust(new Vector2(_pv.X, Stage.FloorY), 10, 80, 40, 70); }
}
/// W/E ohne gelernte Fähigkeit: Hinweis, wo man sie bekommt (nicht öfter als alle 1,5 s).
void Locked()
{
if (_time - _lockedAt < 1.5) return;
_lockedAt = _time;
Float(L.t("duel.locked"), _pv.Chest - new Vector2(0, 220), D.Sand, 26);
}
double _lockedAt = -9;
static float Lag(float lag, float value, float dt) => lag <= value ? value : MathF.Max(value, lag - dt * 0.6f);
void Controls(Input i)
{
Duel.MoveDir = (i.Down(Keys.D, Keys.Right) ? 1 : 0) - (i.Down(Keys.A, Keys.Left) ? 1 : 0);
Duel.BlockHeld = i.RightHeld || i.Down(Keys.K, Keys.LeftShift);
if (i.LeftClick || i.Pressed(Keys.J)) Duel.PressAttack();
if (i.Pressed(Keys.Space)) Duel.PressLeap();
if (i.Pressed(Keys.S) || i.Pressed(Keys.Down)) Duel.PressDodge();
if (i.Pressed(Keys.R)) Duel.PressSuper();
if (i.Pressed(Keys.Q)) Duel.PressSpecial();
if (i.Pressed(Keys.W)) Duel.PressHeavy();
if (i.Pressed(Keys.E)) Duel.PressWall();
// Tastatur/Maus oder Gamepad: Stick/Steuerkreuz bewegen, A Schlag, B ausweichen, X Sprungangriff,
// LT halten Block, RT Raserei, Y Spezial (Q), LB schwerer Schlag (W), RB Schildwall (E)
int keys = (i.Down(Keys.D, Keys.Right) ? 1 : 0) - (i.Down(Keys.A, Keys.Left) ? 1 : 0);
Duel.MoveDir = keys != 0 ? keys : (int)i.PadX;
Duel.BlockHeld = i.RightHeld || i.Down(Keys.K, Keys.LeftShift) || i.Pad.Triggers.Left > 0.4f;
if (i.LeftClick || i.Pressed(Keys.J) || i.PadPressed(Buttons.A)) Duel.PressAttack();
if (i.Pressed(Keys.Space) || i.PadPressed(Buttons.X)) Duel.PressLeap();
if (i.Pressed(Keys.S) || i.Pressed(Keys.Down) || i.PadPressed(Buttons.B)) Duel.PressDodge();
if (i.Pressed(Keys.R) || i.PadPressed(Buttons.RightTrigger)) Duel.PressSuper();
if (i.Pressed(Keys.Q) || i.PadPressed(Buttons.Y)) Duel.PressSpecial();
if (i.Pressed(Keys.W) || i.PadPressed(Buttons.LeftShoulder)) { if (Duel.Perks.HeavyStrike) Duel.PressHeavy(); else Locked(); }
if (i.Pressed(Keys.E) || i.PadPressed(Buttons.RightShoulder)) { if (Duel.Perks.ShieldWall) Duel.PressWall(); else Locked(); }
_pad = i.UsingPad;
}
bool _pad; // Hinweise für das Gamepad
void HandleEvents()
{
foreach (var e in Duel.Events)
{
TutEvent(e);
var targetView = e.ByPlayer ? _ev : _pv;
var actorView = e.ByPlayer ? _pv : _ev;
var target = e.ByPlayer ? Duel.Enemy : Duel.Player;
@@ -291,12 +416,15 @@ namespace GladiatorIdle.Arena
_hitstop = Math.Max(_hitstop, e.Crit || heavy ? 0.13f : 0.075f);
_cam.Shake(e.Crit || heavy ? 0.6f : 0.38f);
_cam.Punch(e.Crit ? 0.07f : 0.04f, at);
if (!_calm && (e.Crit || heavy)) _cam.Pulse((e.ByPlayer ? 1 : -1) * (heavy ? 9 : 6), 0.7f); // schwerer Treffer: Kamera zuckt herum
_fx.Sparks(at, e.Crit ? 34 : 18, e.Crit ? D.Gold : new Color(255, 230, 190), target.Facing > 0 ? MathF.PI : 0, 1.1f);
_fx.Dust(new Vector2(targetView.X, Stage.FloorY), 6, 50, 80, 70);
targetView.Hurt(e.Crit);
_crowd.Excite(e.Crit ? 0.45f : 0.2f);
Float("-" + NumberFormat.Format(e.Amount) + (e.Crit ? "!" : ""), at - new Vector2(0, 120),
e.ByPlayer ? (e.Crit ? D.Gold : Color.White) : D.Red, e.Crit ? 62 : 44);
bool heavyHit = e.ByPlayer && Duel.Player.Heavy;
Float("-" + NumberFormat.Format(e.Amount) + (e.Crit || heavyHit ? "!" : ""), at - new Vector2(0, 120), // i18n-ok
e.ByPlayer ? (heavyHit ? new Color(255, 150, 40) : e.Crit ? D.Gold : Color.White) : D.Red, heavyHit ? 72 : e.Crit ? 62 : 44);
if (heavyHit) { Big(L.t("skill.heavystrike") + "!", new Color(255, 150, 40)); _cam.Shake(0.4f); } // i18n-ok
SoundManager.PlayHit();
if (e.Crit) SoundManager.PlayCheer();
break;
@@ -343,6 +471,7 @@ namespace GladiatorIdle.Arena
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
_crowd.Excite(0.15f);
break;
case DuelEventType.Super:
@@ -367,6 +496,7 @@ namespace GladiatorIdle.Arena
break;
case DuelEventType.Ko:
_slowmo = _calm ? 0 : 1.4f;
if (!_calm) _cam.Pulse(e.ByPlayer ? -16 : 16, 1.6f); // Kinomoment: Schwenk auf den Fallenden
_hitstop = 0.2f;
_cam.Shake(0.9f); _cam.Punch(0.12f, at);
_screenFlash = 0.5f; _flashColor = Color.White;
@@ -423,31 +553,39 @@ namespace GladiatorIdle.Arena
var view = _cam.View(scale, offset);
fx.View = view;
fx.Projection = Matrix.CreateOrthographicOffCenter(0, gd.Viewport.Width, gd.Viewport.Height, 0, 0, 1);
int vw = gd.Viewport.Width, vh = gd.Viewport.Height;
var v3 = _cam.View3();
var p3 = _cam.Proj3(scale, offset, vw, vh);
_plane ??= new BasicEffect(gd) { TextureEnabled = true, VertexColorEnabled = true, LightingEnabled = false };
_plane.World = Matrix.Identity; _plane.View = v3; _plane.Projection = p3;
void Plane(BlendState blend) => sb.Begin(SpriteSortMode.Deferred, blend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, _plane);
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
// Hintergrund: Arena (Wan-Loop, sonst Standbild) mit Parallaxe, abgedunkelt, Vignette
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, _cam.View(scale, offset, 0.35f));
var loop = _loopName != null ? ClipCache.Video(_loopName) : null;
var bg = loop != null ? loop[PingPong(_time * 8, loop.Length)] : _backdrop;
if (bg != null)
{
float k = 1.18f * 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.66f, 0.62f, 0.58f), 0,
new Vector2(bg.Width / 2f, bg.Height / 2f), k, SpriteEffects.None, 0);
}
// 3D-Kulisse: fernes Gemälde, Sand, Mauer, Tore, Banner, Kohlebecken
gd.Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.Transparent, 1, 0);
_set.Draw(gd, v3, p3, _time, _crowd.Excitement);
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, Matrix.Identity);
_set.DrawFires(sb, _cam, v3, p3, vw, vh, scale, _time);
sb.End();
// Boden, Schatten, Staub (Kampfebene)
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, view);
if (_furyDark > 0.01f) // Raserei: Arena versinkt im Dunkel, nur die Kämpfer bleiben im Licht
D.Rect(sb, new RectangleF(-3000, -3000, Camera.W + 6000, Camera.H + 6000), new Color(20, 4, 0) * (0.62f * _furyDark));
D.Rect(sb, new RectangleF(-1200, Stage.FloorY + 30, Camera.W + 2400, 900), Color.Black * 0.35f);
D.Glow(sb, new Vector2(Camera.W / 2, Stage.FloorY + 20), new Vector2(3600, 260), Color.Black * 0.45f);
{
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), new Color(20, 4, 0) * (0.62f * _furyDark));
sb.End();
}
// Schatten: Figuren flach auf den Sand (Sonne), dazu ein weicher Kontaktschatten unter den Füßen
_pv.UseCamera3D(v3, p3); _ev.UseCamera3D(v3, p3);
_pv.SetLighting(_set.Look); _ev.SetLighting(_set.Look);
float shade = _set.Look.Wall == "marble" ? 0.32f : 0.42f;
Stage3D.SoftShadows(gd, sb, _set.Look.SunDir, shade * (1 - 0.6f * _furyDark), _pv, _ev); // weiche Ränder
Plane(BlendState.AlphaBlend);
_pv.DrawShadow(sb);
_ev.DrawShadow(sb);
sb.End();
// warmer Lichtkegel auf dem Sand, wo gekämpft wird
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, view);
D.Glow(sb, new Vector2((_pv.X + _ev.X) / 2, Stage.FloorY + 10), new Vector2(1500, 230), new Color(255, 180, 110) * 0.22f);
Plane(BlendState.Additive);
D.Glow(sb, new Vector2((_pv.X + _ev.X) / 2, Stage.FloorY + 10), new Vector2(1500, 230), new Color(255, 180, 110) * 0.16f);
if (_furyDark > 0.01f)
{
float flicker = 0.8f + 0.2f * MathF.Sin((float)_time * 23) * MathF.Sin((float)_time * 7.3f);
@@ -455,7 +593,7 @@ namespace GladiatorIdle.Arena
D.Glow(sb, _pv.Chest, new Vector2(Stage.FigH * 2.2f), new Color(255, 120, 30) * (0.35f * _furyDark * flicker));
}
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, view);
Plane(BlendState.AlphaBlend);
_fx.DrawSoft(sb);
DrawSmear(sb, _pv, Duel.Player); DrawSmear(sb, _ev, Duel.Enemy);
sb.End();
@@ -465,7 +603,7 @@ namespace GladiatorIdle.Arena
gd.SamplerStates[0] = SamplerState.LinearClamp;
gd.RasterizerState = RasterizerState.CullNone;
gd.DepthStencilState = DepthStencilState.None;
if (_pv.Is3D || _ev.Is3D) gd.Clear(ClearOptions.DepthBuffer, Color.Transparent, 1, 0); // 3D-Figuren verdecken sich richtig
if (_pv.Is3D || _ev.Is3D) gd.Clear(ClearOptions.DepthBuffer, Color.Transparent, 1, 0); // Kämpfer vor der Kulisse, verdecken sich gegenseitig richtig
var e = Duel.Enemy; var p = Duel.Player;
if (e.State == DuelState.Windup) // fair: der Schlag kündigt sich rot an
{
@@ -487,7 +625,7 @@ namespace GladiatorIdle.Arena
else { _ev.DrawBody(gd, fx, e, _calm); _pv.DrawBody(gd, fx, p, _calm); }
// Licht und Funken (additiv)
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, view);
Plane(BlendState.Additive);
_fx.DrawAdd(sb);
if (e.State == DuelState.Windup)
{
@@ -509,7 +647,6 @@ namespace GladiatorIdle.Arena
_crowd.Draw(sb, _calm);
sb.End();
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
DrawVignette(sb);
// wenig Leben: roter Puls am Rand
@@ -527,8 +664,8 @@ namespace GladiatorIdle.Arena
if (_screenFlash > 0) D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), _flashColor * (_screenFlash * 0.5f));
sb.End();
// Zahlen über den Köpfen (Kamera) und HUD (Bildschirm)
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, view);
// Zahlen über den Köpfen (Kampfebene) und HUD (Bildschirm)
Plane(BlendState.AlphaBlend);
foreach (var f in _floaters) if (!f.Big) DrawFloater(sb, f);
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
@@ -551,6 +688,9 @@ namespace GladiatorIdle.Arena
D.Glow(sb, new Vector2(-200, Camera.H / 2), new Vector2(900, 2000), c);
D.Glow(sb, new Vector2(Camera.W + 200, Camera.H / 2), new Vector2(900, 2000), c);
D.Glow(sb, new Vector2(Camera.W / 2, -160), new Vector2(3200, 520), Color.Black * 0.5f);
// oben dunkler Verlauf, damit Namen und Lebensbalken vor den vollen Rängen lesbar bleiben
for (int i = 0; i < 12; i++)
D.Rect(sb, new RectangleF(0, i * 14, Camera.W, 14), Color.Black * (0.5f * (1 - i / 12f)));
}
/// Wischspur der Waffe beim Schlag: Bogen aus weichen Lichtpunkten vor der Figur.
@@ -599,13 +739,24 @@ namespace GladiatorIdle.Arena
bool full = p.Rage >= 100;
float pulse = full ? 0.75f + 0.25f * MathF.Sin((float)_time * 8) : 1;
D.Bar(sb, new RectangleF(70, 150, 460, 12), (float)(p.Rage / 100), (float)(p.Rage / 100), new Color(255, 140, 40) * pulse);
D.Text(sb, Assets.SansBold, 16, L.t(full ? "duel.super.key" : "duel.rage"), new Vector2(544, 156),
D.Text(sb, Assets.SansBold, 16, L.t(full ? (_pad ? "duel.super.pad" : "duel.super.key") : "duel.rage"), new Vector2(544, 156),
full ? new Color(255, 170, 60) * pulse : D.Sand * 0.8f);
// Gegner rechts oben
D.Text(sb, Assets.Serif, 34, _enemy.Name, new Vector2(Camera.W - 70, 58), D.Red * a, Align.Right);
D.Bar(sb, new RectangleF(Camera.W - 770, 88, 700, 34), (float)(e.Hp / e.MaxHp), _eLag, D.Red, fromRight: true);
D.Text(sb, Assets.Sans, 15, L.t("mono.help"), new Vector2(Camera.W / 2, Camera.H - 13), D.Sand * 0.8f, Align.Center);
D.Text(sb, Assets.Sans, 15, L.t(_pad ? "mono.help.pad" : "mono.help"), new Vector2(Camera.W / 2, Camera.H - 13), D.Sand * 0.8f, Align.Center);
if (_tut != TutStep.Off && _phase == Phase.Fight)
{
// Einführung: Banner mit dem aktuellen Schritt
int n = (int)_tut, total = (int)TutStep.Finish;
var br = new RectangleF(Camera.W / 2 - 620, 310, 1240, 104); // unter den großen Einblendungen
float tutPulse = 0.85f + 0.15f * MathF.Sin((float)_time * 4);
Ui.Panel(sb, br, D.Gold * tutPulse, 0.93f);
D.Text(sb, Assets.SansBold, 17, string.Format(L.t("tut.header"), n, total), new Vector2(br.X + 24, br.Y + 22), D.Gold);
D.Text(sb, Assets.Sans, 15, L.t("tut.skip"), new Vector2(br.Right - 24, br.Y + 22), D.Dim, Align.Right);
D.Text(sb, Assets.Serif, 30, L.t("tut." + _tut.ToString().ToLowerInvariant()), new Vector2(br.Center.X, br.Y + 66), Color.White, Align.Center);
}
if (_phase == Phase.Countdown)
{

View File

@@ -169,12 +169,58 @@ namespace GladiatorIdle.Arena
* Matrix.CreateTranslation(X + _off * Facing * 0.35f * Stage.Scale, Stage.FloorY - _lift, 0);
}
/// Perspektive der Duell-Kulisse (sonst wie bisher orthografisch über die 2D-Ansicht).
Matrix? _view3, _proj3;
public void UseCamera3D(Matrix view3, Matrix proj3) { _view3 = view3; _proj3 = proj3; }
/// Licht der Arena übernehmen (Sonne, Umgebung, kühles Gegenlicht für die Kontur).
public void SetLighting(ArenaLook look)
{
if (_mfx == null) return;
_mfx.AmbientLightColor = look.Ambient * 0.95f + new Vector3(0.04f);
_mfx.DirectionalLight0.Direction = Vector3.Normalize(look.SunDir);
_mfx.DirectionalLight0.DiffuseColor = look.Sun;
_mfx.DirectionalLight1.Direction = Vector3.Normalize(new Vector3(-look.SunDir.X, 0.1f, 0.8f));
_mfx.DirectionalLight1.DiffuseColor = Vector3.Lerp(new Vector3(0.22f, 0.27f, 0.36f), look.Fog * 0.4f, 0.4f);
_mfx.FogEnabled = false;
}
// Schatten: Stencil, damit sich überlappende Teile nicht doppelt abdunkeln
static readonly DepthStencilState ShadowStencil = new()
{
DepthBufferEnable = true, DepthBufferWriteEnable = false,
StencilEnable = true, StencilFunction = CompareFunction.Equal, ReferenceStencil = 0,
StencilPass = StencilOperation.Increment, StencilFail = StencilOperation.Keep, StencilDepthBufferFail = StencilOperation.Keep,
};
/// Figur flach auf den Sand geworfen (Richtung der Sonne), halbdurchsichtig dunkel.
public void DrawCastShadow(GraphicsDevice gd, Vector3 sunDir, float strength)
{
if (_model == null || _mfx == null || _view3 == null) return;
var fx = _mfx;
fx.View = _view3.Value; fx.Projection = _proj3!.Value;
// Licht fällt flach: Schatten nicht endlos lang
var dir = Vector3.Normalize(new Vector3(sunDir.X, MathF.Max(0.45f, sunDir.Y), sunDir.Z));
var shadow = Matrix.CreateShadow(-dir, new Plane(new Vector3(0, -1, 0), Stage.FloorY - 1));
fx.World = ModelWorld(0) * shadow;
fx.LightingEnabled = false;
fx.DiffuseColor = Vector3.Zero;
fx.EmissiveColor = Vector3.Zero;
fx.Alpha = strength;
_model.Draw(gd, fx, depth: ShadowStencil, blend: BlendState.AlphaBlend);
fx.Alpha = 1;
fx.LightingEnabled = true;
fx.DiffuseColor = Vector3.One;
gd.DepthStencilState = DepthStencilState.None;
gd.BlendState = BlendState.AlphaBlend;
}
void DrawModel(GraphicsDevice gd, BasicEffect scene, Color aura, float grow)
{
var fx = _mfx!;
var vp = gd.Viewport;
fx.View = scene.View;
fx.Projection = Matrix.CreateOrthographicOffCenter(0, vp.Width, vp.Height, 0, -100000, 100000);
fx.View = _view3 ?? scene.View;
fx.Projection = _proj3 ?? Matrix.CreateOrthographicOffCenter(0, vp.Width, vp.Height, 0, -100000, 100000);
fx.World = ModelWorld(grow);
if (aura.A > 0)
{

View File

@@ -283,7 +283,7 @@ namespace GladiatorIdle.Arena
public void DrawShadow(SpriteBatch sb)
{
float w = 270 * Stage.Scale * (1 + _sq * 0.4f);
Draw.Glow(sb, new Vector2(X + _off * Facing * 0.5f * Stage.Scale, Stage.FloorY + 4), new Vector2(w, 58 * Stage.Scale), Color.Black * 0.55f);
Draw.Glow(sb, new Vector2(X + _off * Facing * 0.5f * Stage.Scale, Stage.FloorY + 4), new Vector2(w, 58 * Stage.Scale), Color.Black * 0.38f);
}
/// Leuchten hinter der Figur (Silhouette, leicht vergrößert): angekündigter Schlag, Schildwall.

View File

@@ -25,6 +25,9 @@ namespace GladiatorIdle.Arena
readonly Particles _fx = new();
readonly Texture2D? _still = Assets.Sprite("freedom_rudis", "jpg");
readonly FighterView _hero;
// Bilanz und Götter: der freie Gladiator in der Arena vor dem Kaiser, Kamera fährt langsam um ihn
readonly Stage3D _stage = new(Balance.ARENA_COUNT - 1, AppSettings.ReduceMotion);
const float HERO_X = 520;
readonly DuelFighter _dummy = new() { IsPlayer = true, Facing = 1, MaxHp = 1, Hp = 1, State = DuelState.Victory };
readonly float _line2At, _clipTime;
Phase _phase;
@@ -51,6 +54,8 @@ namespace GladiatorIdle.Arena
SoundManager.StopAll();
SoundManager.PlayMusic("music_freedom", loop: true);
_fx.Calm = AppSettings.ReduceMotion;
_stage.Cam.FocusX = 800; // Held links, Platz für die Bilanz rechts
_stage.Cam.HoldYaw(-16);
}
void Next(Phase p)
@@ -75,7 +80,8 @@ namespace GladiatorIdle.Arena
_t += dt; _phaseT += dt;
_ui.Begin(input, ui);
_dummy.StateTime += dt;
_hero.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion);
_hero.Update(dt, dt, _dummy, HERO_X, AppSettings.ReduceMotion);
_stage.Cam.Update(dt, HERO_X, HERO_X, AppSettings.ReduceMotion);
_fx.Motes(AppSettings.ReduceMotion ? 0 : 40, Camera.W, Camera.H);
_fx.Update(dt);
if (_phase == Phase.Clip)
@@ -93,27 +99,29 @@ namespace GladiatorIdle.Arena
{
D.UiScale = scale;
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
if (_phase == Phase.Clip) DrawClip(sb);
else DrawBackdrop(sb);
sb.End();
if (_phase == Phase.Summary)
if (_phase == Phase.Clip)
{
// der freie Gladiator, jubelnd, links in der Bilanz
var view = Matrix.CreateTranslation(0, -Stage.FloorY, 0) * Matrix.CreateScale(1.7f) * Matrix.CreateTranslation(560, 830, 0) * ui;
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, view);
D.Glow(sb, new Vector2(0, Stage.FloorY - 200), new Vector2(700, 800), new Color(255, 200, 120) * 0.25f);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
DrawClip(sb);
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;
gd.Clear(ClearOptions.DepthBuffer, Color.Transparent, 1, 0);
}
else
{
// die Arena vor dem Kaiser in 3D, volle Ränge jubeln; der freie Gladiator steht im Sand
_stage.Prepare(gd, scale, offset);
_stage.DrawSet(gd, sb, _t, 0.95f);
_stage.Shadows(gd, sb, 0, _hero);
_stage.FloorLight(sb, HERO_X, 1000, 0.28f);
Stage3D.BeginFigures(gd);
_stage.Use(_hero);
_hero.DrawBody(gd, fx, _dummy, AppSettings.ReduceMotion);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
// oben und an den Rändern dunkler (Titel lesbar); bei den Göttern tritt die Arena zurück
for (int i = 0; i < 16; i++)
D.Rect(sb, new RectangleF(0, i * 16, Camera.W, 16), Color.Black * (0.55f * (1 - i / 16f)));
D.Glow(sb, new Vector2(Camera.W + 200, Camera.H / 2), new Vector2(1100, 2000), Color.Black * 0.5f);
if (_phase == Phase.Gods) D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.62f);
sb.End();
}
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);

View File

@@ -23,7 +23,10 @@ namespace GladiatorIdle.Arena
static Color ChanceColor(double c) => c >= 0.75 ? D.Green : c >= 0.4 ? D.Gold : D.Red;
/// Ein Fenster liegt über dem Hub (Bericht oder Ereignis): darunter nichts anklickbar.
bool Modal => _game.ExpeditionResult != null || _game.PendingEvent != null || _eventShown != null;
bool Modal => Welcome != null || _game.ExpeditionResult != null || _game.PendingEvent != null || _eventShown != null;
/// Bericht über die Zeit, in der das Spiel zu war (ab 2 Minuten), als erstes Fenster.
public OfflineReport? Welcome { get; set; }
void UpdateAdventure()
{
@@ -121,10 +124,37 @@ namespace GladiatorIdle.Arena
void DrawModal(SpriteBatch sb)
{
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.65f);
if (_game.ExpeditionResult is { } rep) DrawReport(sb, rep);
if (Welcome is { } w) DrawWelcome(sb, w);
else if (_game.ExpeditionResult is { } rep) DrawReport(sb, rep);
else if (_eventShown != null || _game.PendingEvent != null) DrawEvent(sb);
}
void DrawWelcome(SpriteBatch sb, OfflineReport w)
{
var r = new RectangleF(Camera.W / 2 - 480, 200, 960, 640);
Ui.Panel(sb, r, D.Gold, 0.97f);
float y = r.Y + 70;
D.Text(sb, Assets.Serif, 52, L.t("offline.title"), new Vector2(r.Center.X, y), D.Gold, Align.Center);
y += 70;
D.Text(sb, Assets.Serif, 24, string.Format(L.t("offline.away"), NumberFormat.Duration(w.Seconds)), new Vector2(r.Center.X, y), D.Sand, Align.Center);
if (w.Seconds >= _game.OfflineCapSeconds - 1)
D.Text(sb, Assets.Sans, 17, string.Format(L.t("offline.capped"), NumberFormat.Duration(_game.OfflineCapSeconds)), new Vector2(r.Center.X, y + 34), D.Dim, Align.Center);
y += 90;
void Line(string label, string value, Color c)
{
D.Text(sb, Assets.Sans, 24, label, new Vector2(r.X + 160, y), D.Sand);
D.Text(sb, Assets.SansBold, 28, value, new Vector2(r.Right - 160, y), c, Align.Right);
D.Rect(sb, new RectangleF(r.X + 160, y + 26, r.Width - 320, 1), D.Border * 0.6f);
y += 62;
}
if (w.Gold > 0) Line(L.t("offline.gold"), "+" + NumberFormat.Format(w.Gold), D.Gold); // i18n-ok (nur von Expeditionen)
if (w.Fame > 0) Line(L.t("offline.fame"), "+" + NumberFormat.Format(w.Fame), D.Gold); // i18n-ok
Line(L.t("offline.levels"), "+" + w.LevelUps.ToString(NumberFormat.Culture), D.Green); // i18n-ok
if (w.Wins + w.Losses > 0) Line(L.t("offline.fights"), string.Format(L.t("offline.fights.value"), w.Wins, w.Losses), D.Sand);
if (_ui.Button(sb, new RectangleF(r.Center.X - 200, r.Bottom - 100, 400, 68), L.t("offline.ok"), selected: true, size: 26))
{ Welcome = null; SoundManager.PlayCoins(); }
}
void DrawReport(SpriteBatch sb, ExpeditionReport rep)
{
var reg = RegionDef.Get(rep.Region);

View File

@@ -8,7 +8,7 @@ using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// Ausrüstung: Inventar mit Detailkarte (anlegen, verkaufen), Händler und Schmied.
/// Ausrüstung: Inventar mit Detailkarte (anlegen, verkaufen).
internal sealed partial class HubScene
{
long? _sel; // gewähltes Stück (Inventar oder angelegt)
@@ -117,53 +117,5 @@ namespace GladiatorIdle.Arena
if (_ui.Button(sb, new RectangleF(card.X + 28 + bw, by, bw, 42), string.Format(L.t("char.sell"), NumberFormat.Format(Items.SellValue(sel))), size: 16))
if (_game.Sell(sel.Id)) { SoundManager.PlayCoins(); _sel = null; }
}
// ── Forum: Händler (links) und Schmied (rechts) ─────────────
void DrawForum(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, y = r.Y + 40, w = 700;
D.Text(sb, Assets.Serif, 30, L.t("forum.tab.merchant"), new Vector2(x, y), D.Gold);
D.Text(sb, Assets.Sans, 16, string.Format(L.t("merchant.refresh"), NumberFormat.Duration(_game.MerchantRefreshIn)),
new Vector2(x + w, y), D.Dim, Align.Right);
D.Text(sb, Assets.Sans, 16, string.Format(L.t("merchant.bag"), _game.Inventory.Count, Items.INVENTORY), new Vector2(x + w, y + 24), D.Dim, Align.Right);
float ry = y + 50;
foreach (var it in _game.Merchant.ToList())
{
var row = new RectangleF(x, ry, w, 96);
D.Rect(sb, row, new Color(30, 22, 15) * 0.9f);
D.Frame(sb, row, RarityColor(it.Rarity), 2);
ItemTile(sb, new RectangleF(row.X + 10, row.Y + 10, 76, 76), it, false);
D.Text(sb, Assets.SansBold, 20, ItemName(it), new Vector2(row.X + 100, row.Y + 22), RarityColor(it.Rarity));
D.Text(sb, Assets.Sans, 15, ItemMain(it), new Vector2(row.X + 100, row.Y + 48), D.Sand);
string aff = string.Join(" · ", ItemAffixes(it)); // i18n-ok
if (aff.Length > 0) D.Text(sb, Assets.Sans, 14, aff, new Vector2(row.X + 100, row.Y + 72), D.Blue);
var (delta, dc) = PowerDelta(it);
D.Text(sb, Assets.SansBold, 15, delta, new Vector2(row.Right - 200, row.Y + 22), dc, Align.Right);
double price = Items.Value(it);
long id = it.Id;
if (_ui.Button(sb, new RectangleF(row.Right - 180, row.Y + 24, 166, 48), string.Format(L.t("btn.buy"), NumberFormat.Format(price)),
_game.Gold >= price && _game.Inventory.Count < Items.INVENTORY, size: 19))
if (_game.BuyFromMerchant(id)) { SoundManager.PlayPurchase(); _sel = id; }
ry += 104;
}
// Schmied: Ausrüstungsplätze verstärken (wirkt auf jedes Stück im Platz)
float fx = x + w + 50, fw = r.Right - 30 - fx;
D.Text(sb, Assets.Serif, 30, L.t("forum.tab.forge"), new Vector2(fx, y), D.Gold);
for (int i = 0; i < 5; i++)
{
var slot = (ItemSlot)i;
var row = new RectangleF(fx, y + 50 + i * 104, fw, 96);
D.Rect(sb, row, new Color(30, 22, 15) * 0.9f);
D.Frame(sb, row, D.Border, 2);
ItemTile(sb, new RectangleF(row.X + 10, row.Y + 10, 76, 76), _game.Equipped[i], false);
D.Text(sb, Assets.SansBold, 20, L.t("slot." + slot.ToString().ToLowerInvariant()), new Vector2(row.X + 100, row.Y + 30), Color.White);
D.Text(sb, Assets.Sans, 16, string.Format(L.t("forge.level"), _game.SlotLevels[i]), new Vector2(row.X + 100, row.Y + 60), D.Sand);
double cost = _game.UpgradeSlotCost(slot);
if (_ui.Button(sb, new RectangleF(row.Right - 200, row.Y + 24, 186, 48), string.Format(L.t("btn.forge"), NumberFormat.Format(cost)), _game.Gold >= cost, size: 17))
if (_game.UpgradeSlot(slot)) SoundManager.PlayLevelUp();
}
}
}
}

View File

@@ -11,15 +11,15 @@ namespace GladiatorIdle.Arena
/// Tipp, der zum aktuellen Spielstand passt (was jetzt sinnvoll ist).
internal sealed partial class HubScene
{
static string GuideId(Drawer d) => d switch
string GuideId => _drawer switch
{
Drawer.Gladiator => "gladiator", Drawer.Ludus => "ludus", Drawer.Forum => "forum",
Drawer.Skills => "skills", Drawer.Hall => "hall", _ => "expedition"
Drawer.Gladiator => _page == Page.Skills ? "skills" : "gladiator", Drawer.Ludus => "ludus",
Drawer.Hall => "hall", _ => "expedition"
};
void DrawGuide(SpriteBatch sb, RectangleF r)
{
string id = GuideId(_drawer);
string id = GuideId;
Ui.Panel(sb, r, D.Border, 0.94f);
float x = r.X + 26, w = r.Width - 52, y = r.Y + 34;
D.Text(sb, Assets.Serif, 28, L.t("guide.title"), new Vector2(x, y), D.Gold);
@@ -52,6 +52,10 @@ namespace GladiatorIdle.Arena
var g = _game;
switch (_drawer)
{
case Drawer.Gladiator when _page == Page.Skills:
return g.LearnablePoints > 0
? (string.Format(L.t("tip.skills.points"), g.LearnablePoints), D.Gold)
: (string.Format(L.t("tip.skills.next"), g.CharLevel / 2 * 2 + 2), D.Sand);
case Drawer.Gladiator:
{
if (g.AttrPoints > 0) return (string.Format(L.t("tip.gladiator.points"), g.AttrPoints), D.Gold);
@@ -59,6 +63,10 @@ namespace GladiatorIdle.Arena
var better = g.Inventory.Where(it => g.PowerWith(it) > now * 1.005).OrderByDescending(g.PowerWith).FirstOrDefault();
if (better != null) return (string.Format(L.t("tip.gladiator.better"), ItemName(better)), D.Green);
if (g.Inventory.Count >= Items.INVENTORY - 4) return (L.t("tip.gladiator.full"), D.Red);
var slot = Enumerable.Range(0, 5).Select(i => (ItemSlot)i).Where(s => g.Equipped[(int)s] != null)
.OrderBy(g.UpgradeSlotCost).FirstOrDefault();
if (g.Equipped[(int)slot] != null && g.Gold >= g.UpgradeSlotCost(slot))
return (string.Format(L.t("tip.gladiator.forge"), L.t("slot." + slot.ToString().ToLowerInvariant())), D.Green);
return (L.t("tip.gladiator.none"), D.Sand);
}
case Drawer.Ludus:
@@ -69,23 +77,6 @@ namespace GladiatorIdle.Arena
? (string.Format(L.t("tip.ludus.afford"), L.t(cheapest.Key)), D.Green)
: (string.Format(L.t("tip.ludus.save"), L.t(cheapest.Key), NumberFormat.Format(cost - g.Gold)), D.Sand);
}
case Drawer.Forum:
{
double now = g.Power();
var buy = g.Merchant.Where(it => g.Gold >= Items.Value(it) && g.PowerWith(it) > now * 1.005)
.OrderByDescending(g.PowerWith).FirstOrDefault();
if (buy != null)
return (string.Format(L.t("tip.forum.buy"), ItemName(buy), NumberFormat.Percent(g.PowerWith(buy) / now - 1)), D.Green);
var slot = Enumerable.Range(0, 5).Select(i => (ItemSlot)i).Where(s => g.Equipped[(int)s] != null)
.OrderBy(g.UpgradeSlotCost).FirstOrDefault();
if (g.Equipped[(int)slot] != null && g.Gold >= g.UpgradeSlotCost(slot))
return (string.Format(L.t("tip.forum.forge"), L.t("slot." + slot.ToString().ToLowerInvariant())), D.Green);
return (string.Format(L.t("tip.forum.wait"), NumberFormat.Duration(g.MerchantRefreshIn)), D.Sand);
}
case Drawer.Skills:
return g.LearnablePoints > 0
? (string.Format(L.t("tip.skills.points"), g.LearnablePoints), D.Gold)
: (string.Format(L.t("tip.skills.next"), g.CharLevel / 2 * 2 + 2), D.Sand);
case Drawer.Hall:
{
if (g.Legends.Count == 0) return (L.t("tip.hall.none"), D.Sand);

View File

@@ -17,10 +17,9 @@ namespace GladiatorIdle.Arena
void DrawSkills(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, y = r.Y + 40;
D.Text(sb, Assets.Serif, 30, L.t("char.skills"), new Vector2(x, y), D.Gold);
float x = r.X + 30, y = r.Y + 46;
D.Text(sb, Assets.SansBold, 22, string.Format(L.t("char.skillpoints"), _game.SkillPoints),
new Vector2(x + 300, y + 2), _game.SkillPoints > 0 ? D.Gold : D.Dim);
new Vector2(x + 650, y - 2), _game.SkillPoints > 0 ? D.Gold : D.Dim);
if (_ui.Button(sb, new RectangleF(r.Right - 330, y - 22, 300, 44),
string.Format(L.t("char.skillreset"), NumberFormat.Format(_game.SkillResetCost)),
_game.SkillRanks.Count > 0 && _game.Gold >= _game.SkillResetCost, size: 16))
@@ -29,7 +28,7 @@ namespace GladiatorIdle.Arena
_skillHover = null;
_learnFlash = MathF.Max(0, _learnFlash - 1 / 60f * 2.5f);
var branches = new[] { SkillBranch.Offense, SkillBranch.Defense, SkillBranch.Class };
float colW = (r.Width - 60) / 3, top = y + 60, rowH = 142;
float colW = (r.Width - 60) / 3, top = y + 66, rowH = 132;
for (int b = 0; b < 3; b++)
{
var branch = branches[b];

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));
}

View File

@@ -21,7 +21,14 @@ namespace GladiatorIdle.Arena
readonly Ui _ui = new();
readonly Particles _fx = new();
readonly Texture2D? _backdrop = Assets.Sprite("arena_colosseum", "jpg");
// Kolosseum in 3D als Bühne; die drei Besten stehen als Figuren ihrer Klasse auf dem Podest
readonly Stage3D _stage = new(5, AppSettings.ReduceMotion);
readonly Dictionary<string, FighterView> _podiumViews = new();
readonly DuelFighter _podiumDummy = new() { IsPlayer = true, Facing = 1, MaxHp = 1, Hp = 1, State = DuelState.Victory };
readonly RenderTarget2D?[] _podiumRt = new RenderTarget2D?[3];
BasicEffect? _figFx;
float _time;
const int FIG_W = 220, FIG_H = 300;
readonly string _me = Leaderboard.PlayerId;
List<LeaderEntry>? _all;
bool _loading = true, _offline, _dev;
@@ -79,17 +86,47 @@ namespace GladiatorIdle.Arena
// ── Zeichnen ────────────────────────────────────────────────
/// Siegerfiguren der Plätze 1–3 in ihre Bildflächen (vor allem anderen: Zielwechsel leert das Bild).
void RenderPodium(GraphicsDevice gd, List<LeaderEntry> list)
{
_figFx ??= new BasicEffect(gd) { VertexColorEnabled = true };
_podiumDummy.StateTime = 0.6f + (_time % 4f) * 0.5f; // Siegesjubel immer wieder
var previous = gd.GetRenderTargets();
for (int i = 0; i < 3; i++)
{
_podiumRt[i] = null;
if (i >= list.Count || !Enum.TryParse<GladiatorClass>(list[i].Class, out var cls)) continue;
string art = Art.Hero(cls, 1);
if (!_podiumViews.TryGetValue(art, out var v)) _podiumViews[art] = v = new FighterView(art, i * 0.7f, -1, i == 0 ? 4 : i == 1 ? 7 : 0);
v.Update(1 / 60f, 1 / 60f, _podiumDummy, 0, true);
if (!v.Is3D) continue;
var rt = _podiumRtCache[i] ??= new RenderTarget2D(gd, FIG_W, FIG_H, false, SurfaceFormat.Color, DepthFormat.Depth24);
gd.SetRenderTarget(rt);
gd.Clear(Color.Transparent);
_figFx.View = Matrix.CreateTranslation(0, -Stage.FloorY, 0) * Matrix.CreateScale(0.78f) * Matrix.CreateTranslation(FIG_W / 2f, FIG_H - 6, 0);
_figFx.Projection = Matrix.CreateOrthographicOffCenter(0, FIG_W, FIG_H, 0, 0, 1);
gd.BlendState = BlendState.AlphaBlend; gd.DepthStencilState = DepthStencilState.None; gd.RasterizerState = RasterizerState.CullNone;
v.DrawBody(gd, _figFx, _podiumDummy, true);
_podiumRt[i] = rt;
}
gd.SetRenderTargets(previous);
gd.Clear(Color.Black);
}
readonly RenderTarget2D?[] _podiumRtCache = new RenderTarget2D?[3];
public void Draw(SpriteBatch sb, float scale, Vector2 offset)
{
D.UiScale = scale;
var gd = sb.GraphicsDevice;
_time += 1 / 60f;
var ranked = !_loading && !_offline ? Ranked() : new List<LeaderEntry>();
RenderPodium(gd, ranked);
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
_stage.Cam.Update(1 / 60f, Camera.W / 2 - 1800, Camera.W / 2 + 1800, AppSettings.ReduceMotion);
_stage.Prepare(gd, scale, offset);
_stage.DrawSet(gd, sb, _time, 0.8f);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
if (_backdrop != null)
{
float k = 1.08f * MathF.Max(Camera.W / _backdrop.Width, Camera.H / _backdrop.Height);
sb.Draw(_backdrop, new Vector2(Camera.W / 2, Camera.H / 2), null, new Color(0.3f, 0.27f, 0.24f), 0,
new Vector2(_backdrop.Width / 2f, _backdrop.Height / 2f), k, SpriteEffects.None, 0);
}
D.Rect(sb, new RectangleF(0, 0, Camera.W, Camera.H), Color.Black * 0.45f); // Tafeln lesbar
sb.End();
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);
_fx.DrawAdd(sb);
@@ -134,19 +171,27 @@ namespace GladiatorIdle.Arena
var r = new RectangleF(x, baseY - h, w, h);
D.Rect(sb, r, new Color(30, 22, 15) * 0.92f);
D.Frame(sb, r, e.Id == _me ? D.Purple : medal[i], e.Id == _me ? 4 : 3);
D.Text(sb, Assets.Serif, 44, (i + 1).ToString(NumberFormat.Culture), new Vector2(r.Center.X, r.Y + 30), medal[i], Align.Center);
D.Text(sb, Assets.Serif, 28, e.Name, new Vector2(r.Center.X, r.Y + 72), Color.White, Align.Center);
if (h >= 170) D.Text(sb, Assets.Sans, 17, $"{ClassName(e)} · {string.Format(L.t("ludus.level"), e.Level)}", new Vector2(r.Center.X, r.Y + 104), D.Sand, Align.Center); // i18n-ok
D.Text(sb, Assets.SansBold, 24, Value(e), new Vector2(r.Center.X, r.Bottom - 26), medal[i], Align.Center);
float tx = r.Center.X;
if (_podiumRt[i] is RenderTarget2D fig)
{
// Figur steht links auf der Tafel und ragt nach oben heraus
float k = (h + 60) / FIG_H;
sb.Draw(fig, new Vector2(r.X + 70, r.Bottom - 8), null, Color.White, 0, new Vector2(FIG_W / 2f, FIG_H - 6), k, SpriteEffects.None, 0);
tx = r.X + 230;
}
D.Text(sb, Assets.Serif, 44, (i + 1).ToString(NumberFormat.Culture), new Vector2(tx, r.Y + 30), medal[i], Align.Center);
D.Text(sb, Assets.Serif, e.Name.Length > 11 ? 22 : 28, e.Name, new Vector2(tx, r.Y + 72), Color.White, Align.Center);
if (h >= 170) D.Text(sb, Assets.Sans, 16, $"{ClassName(e)} · {string.Format(L.t("ludus.level"), e.Level)}", new Vector2(tx, r.Y + 104), D.Sand, Align.Center); // i18n-ok
D.Text(sb, Assets.SansBold, 24, Value(e), new Vector2(tx, r.Bottom - 26), medal[i], Align.Center);
}
// Plätze 4–15
float x0 = Camera.W / 2 - 560, y = 512, rowH = 36, wAll = 1120;
D.Text(sb, Assets.Sans, 15, L.t("lb.col.rank"), new Vector2(x0 + 20, y), D.Dim);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.name"), new Vector2(x0 + 90, y), D.Dim);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.class"), new Vector2(x0 + 470, y), D.Dim);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.freedoms"), new Vector2(x0 + 760, y), D.Dim, Align.Center);
D.Text(sb, Assets.Sans, 15, L.t(_tab == Tab.Power ? "lb.tab.power" : "lb.tab.fastest"), new Vector2(x0 + wAll - 20, y), D.Dim, Align.Right);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.rank"), new Vector2(x0 + 20, y), D.Sand);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.name"), new Vector2(x0 + 90, y), D.Sand);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.class"), new Vector2(x0 + 470, y), D.Sand);
D.Text(sb, Assets.Sans, 15, L.t("lb.col.freedoms"), new Vector2(x0 + 760, y), D.Sand, Align.Center);
D.Text(sb, Assets.Sans, 15, L.t(_tab == Tab.Power ? "lb.tab.power" : "lb.tab.fastest"), new Vector2(x0 + wAll - 20, y), D.Sand, Align.Right);
y += 26;
for (int i = 3; i < Math.Min(15, list.Count); i++) { Row(sb, list[i], i, x0, y, wAll, rowH); y += rowH; }
int mine = list.FindIndex(e => e.Id == _me);

View File

@@ -48,9 +48,11 @@ namespace GladiatorIdle.Arena
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
if (_backdrop != null)
{
// langsames Heranfahren
float k = (1.08f + 0.03f * (float)Math.Sin(_t * 0.05)) * MathF.Max(Camera.W / _backdrop.Width, Camera.H / _backdrop.Height);
sb.Draw(_backdrop, new Vector2(Camera.W / 2, Camera.H / 2), null, new Color(0.62f, 0.58f, 0.54f), 0,
// langsames Heranfahren und Wandern (Ken Burns, etwa 40 s je Schwung); still bei "Effekte reduzieren"
double t = AppSettings.ReduceMotion ? 0 : _t;
float k = (1.1f + 0.04f * (float)Math.Sin(t * 0.16)) * MathF.Max(Camera.W / _backdrop.Width, Camera.H / _backdrop.Height);
var pan = new Vector2(38 * (float)Math.Sin(t * 0.11), 14 * (float)Math.Sin(t * 0.07 + 1));
sb.Draw(_backdrop, new Vector2(Camera.W / 2, Camera.H / 2) + pan, null, new Color(0.62f, 0.58f, 0.54f), 0,
new Vector2(_backdrop.Width / 2f, _backdrop.Height / 2f), k, SpriteEffects.None, 0);
}
D.Glow(sb, new Vector2(Camera.W / 2, Camera.H / 2), new Vector2(Camera.W * 0.9f, Camera.H * 1.2f), Color.Black * 0.35f);

View File

@@ -33,7 +33,7 @@ namespace GladiatorIdle.Arena
// --model=<name>: andere Figur ansehen (Standard: hero_murmillo_1)
string name = Array.Find(Environment.GetCommandLineArgs(), x => x.StartsWith("--model="))?[8..] ?? "hero_murmillo_1";
Model = Model3D.Load(gd, name);
Model?.Arm(name);
Model?.Arm(Array.Find(Environment.GetCommandLineArgs(), x => x.StartsWith("--arm="))?[6..] ?? name); // --arm=<figur>: deren Ausrüstung
if (Model != null) DevShot.Log($"model3d {name}: {Model.BladeLog}");
_backdrop = Assets.Sprite("arena_colosseum", "jpg");
_fx = new BasicEffect(gd) { VertexColorEnabled = true, LightingEnabled = true, PreferPerPixelLighting = true };

View File

@@ -19,6 +19,13 @@ namespace GladiatorIdle.Arena
public SettingsOverlay(Action toggleFullscreen) => _toggleFullscreen = toggleFullscreen;
/// Bildrate geändert: Grafik neu einstellen (VSync, feste Rate).
public Action ApplyGraphics = () => { };
/// Einführung: null = kein Spielstand, true = schon gesehen; ReplayTutorial schaltet sie wieder ein.
public Func<bool?> Tutorial = () => null;
public Action ReplayTutorial = () => { };
public void Update(Input input, Matrix ui)
{
_ui.Begin(input, ui);
@@ -39,7 +46,7 @@ namespace GladiatorIdle.Arena
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
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, 100, 840, 880);
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);
@@ -64,6 +71,17 @@ namespace GladiatorIdle.Arena
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);
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)
&& 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);
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++)
@@ -72,6 +90,13 @@ namespace GladiatorIdle.Arena
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 (L.Current != lang && DevShot.Lang == null) L.Set(lang);
}
y += 70;
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))
ReplayTutorial();
}
if (_ui.Button(sb, new RectangleF(r.Center.X - 160, r.Bottom - 100, 320, 64), L.t("select.back"), selected: true, size: 26))
Open = false;

135
Mono/Arena/Stage3D.cs Normal file
View File

@@ -0,0 +1,135 @@
using System;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// <summary>
/// Gemeinsame 3D-Bühne für Duell, Hub, Freiheit und Erstellung: Kamera mit Perspektive,
/// Arena-Kulisse (<see cref="ArenaSet"/>), Schattenwurf der Figuren und ein Effekt, mit dem
/// SpriteBatch auf der Kampfebene (z = 0) zeichnet, sodass 2D-Effekte zur 3D-Kamera passen.
/// Ablauf je Bild: <see cref="Prepare"/>, <see cref="DrawSet"/>, <see cref="Shadows"/>,
/// dann Figuren (<see cref="Use"/>) und Ebenen-Batches (<see cref="BeginPlane"/>).
/// </summary>
internal sealed class Stage3D
{
public readonly Camera Cam = new();
public ArenaSet Set { get; private set; }
public int Arena { get; private set; }
public Matrix View3 { get; private set; }
public Matrix Proj3 { get; private set; }
readonly bool _calm;
BasicEffect? _plane;
int _vw, _vh; float _scale = 1;
public Stage3D(int arena, bool calm)
{
_calm = calm;
Arena = arena;
Set = ArenaSet.Get(arena, Art.Arena(ArenaDef.All[Math.Clamp(arena, 0, ArenaDef.All.Length - 1)]), calm);
Cam.Center = new Vector2(Camera.W / 2, Camera.H / 2 + 40);
}
/// Andere Arena (Aufstieg): Kulisse neu bauen.
public void SetArena(int arena)
{
if (arena == Arena) return;
Arena = arena;
Set = ArenaSet.Get(arena, Art.Arena(ArenaDef.All[Math.Clamp(arena, 0, ArenaDef.All.Length - 1)]), _calm);
}
/// Matrizen für dieses Bild.
public void Prepare(GraphicsDevice gd, float scale, Vector2 offset)
{
_vw = gd.Viewport.Width; _vh = gd.Viewport.Height; _scale = scale;
View3 = Cam.View3();
Proj3 = Cam.Proj3(scale, offset, _vw, _vh);
_plane ??= new BasicEffect(gd) { TextureEnabled = true, VertexColorEnabled = true, LightingEnabled = false };
_plane.World = Matrix.Identity; _plane.View = View3; _plane.Projection = Proj3;
}
/// Kulisse (Tiefe und Stencil frisch), Feuer als Licht.
public void DrawSet(GraphicsDevice gd, SpriteBatch sb, double time, float excite)
{
gd.Clear(ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.Transparent, 1, 0);
Set.Draw(gd, View3, Proj3, time, excite);
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, Matrix.Identity);
Set.DrawFires(sb, Cam, View3, Proj3, _vw, _vh, _scale, time);
sb.End();
}
/// Figur auf diese Bühne einstellen (Kamera und Licht der Arena).
public void Use(FighterView f)
{
f.UseCamera3D(View3, Proj3);
f.SetLighting(Set.Look);
}
/// Schattenwurf auf dem Sand und weicher Kontaktschatten unter den Füßen.
public void Shadows(GraphicsDevice gd, SpriteBatch sb, float dim, params FighterView[] figs)
{
float shade = (Set.Look.Wall == "marble" ? 0.32f : 0.42f) * (1 - 0.6f * dim);
foreach (var f in figs) Use(f);
SoftShadows(gd, sb, Set.Look.SunDir, shade, figs);
BeginPlane(sb, BlendState.AlphaBlend);
foreach (var f in figs) f.DrawShadow(sb);
sb.End();
}
static RenderTarget2D? _shadowRt;
/// Weicher Schattenwurf: die Figuren flach und deckend schwarz in eine halb so große Fläche,
/// dann mehrfach leicht versetzt auf das Bild gelegt (weiche Ränder, kein doppeltes Abdunkeln).
/// Die Figuren müssen schon auf die Kamera eingestellt sein (<see cref="FighterView.UseCamera3D"/>).
public static void SoftShadows(GraphicsDevice gd, SpriteBatch sb, Vector3 sunDir, float strength, params FighterView[] figs)
{
int vw = gd.Viewport.Width, vh = gd.Viewport.Height;
if (_shadowRt == null || _shadowRt.Width != vw / 2 || _shadowRt.Height != vh / 2)
{
_shadowRt?.Dispose();
_shadowRt = new RenderTarget2D(gd, Math.Max(1, vw / 2), Math.Max(1, vh / 2), false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8, 0, RenderTargetUsage.DiscardContents);
}
var previous = gd.GetRenderTargets();
gd.SetRenderTarget(_shadowRt);
gd.Clear(ClearOptions.Target | ClearOptions.DepthBuffer | ClearOptions.Stencil, Color.Transparent, 1, 0);
foreach (var f in figs) f.DrawCastShadow(gd, sunDir, 1f);
gd.SetRenderTargets(previous);
// 8 versetzte Abzüge im Kreis + Mitte: Gesamtdeckung im Kern = strength
const int TAPS = 9;
float a = 1 - MathF.Pow(1 - strength, 1f / TAPS);
float r = MathF.Max(2.5f, vw / 700f);
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone);
var dst = new Rectangle(0, 0, vw, vh);
for (int i = 0; i < TAPS; i++)
{
var off = i == 0 ? Vector2.Zero : new Vector2(MathF.Cos(i * MathF.Tau / 8), MathF.Sin(i * MathF.Tau / 8)) * r * (i % 2 == 0 ? 1f : 0.6f);
sb.Draw(_shadowRt, new Rectangle(dst.X + (int)off.X, dst.Y + (int)off.Y, dst.Width, dst.Height), Color.White * a);
}
sb.End();
}
/// SpriteBatch auf der Kampfebene (Design-Pixel bei z = 0, durch die 3D-Kamera).
public void BeginPlane(SpriteBatch sb, BlendState blend) =>
sb.Begin(SpriteSortMode.Deferred, blend, SamplerState.LinearClamp, DepthStencilState.None, RasterizerState.CullNone, _plane);
/// Warmer Lichtfleck auf dem Sand um eine Stelle (additiv, auf der Kampfebene).
public void FloorLight(SpriteBatch sb, float x, float width, float strength)
{
BeginPlane(sb, BlendState.Additive);
D.Glow(sb, new Vector2(x, Stage.FloorY + 10), new Vector2(width, 230), new Color(255, 180, 110) * strength);
sb.End();
}
/// Zeichenzustand für die Figuren danach (Tiefe neu, damit sie vor der Kulisse stehen).
public static void BeginFigures(GraphicsDevice gd)
{
gd.BlendState = BlendState.AlphaBlend;
gd.SamplerStates[0] = SamplerState.LinearClamp;
gd.RasterizerState = RasterizerState.CullNone;
gd.DepthStencilState = DepthStencilState.None;
gd.Clear(ClearOptions.DepthBuffer, Color.Transparent, 1, 0);
}
}
}