Oath speech in the deep warrior voice, cinematic camera, crowd calls your name
Stand von main 730ac6a2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -53,6 +53,8 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
// 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;
|
||||
/// Innenkreis der Arena (für die Kamera).
|
||||
public static (Vector2 Center, float R) Ring => (new Vector2(CX, ZC), R);
|
||||
// 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;
|
||||
@@ -107,7 +109,7 @@ namespace GladiatorIdle.Arena
|
||||
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 a in new[] { -50f, -14f, 14f, 50f, 85f, -85f, 150f, -150f }) _bannerAt.Add((a, a * 0.13f));
|
||||
foreach (var p in _parts) p.Freeze();
|
||||
_backdrop.Freeze();
|
||||
|
||||
@@ -115,6 +117,9 @@ namespace GladiatorIdle.Arena
|
||||
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);
|
||||
// Stufen aller Texturen jetzt rechnen, nicht beim ersten Jubel mitten im Kampf (Ruckler)
|
||||
foreach (var (calmTex, cheerTex) in _fanTex) { Assets.Mipmapped(calmTex); Assets.Mipmapped(cheerTex); }
|
||||
foreach (var part in _parts) if (part.Tex != null && part.Tex != Assets.Pixel) Assets.Mipmapped(part.Tex);
|
||||
_fanV = new VertexPositionColorTexture[_fanTex.Count * 2][];
|
||||
_fanN = new int[_fanV.Length];
|
||||
for (int i = 0; i < _fanV.Length; i++)
|
||||
@@ -137,14 +142,14 @@ namespace GladiatorIdle.Arena
|
||||
"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;
|
||||
const int SEG = 180;
|
||||
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;
|
||||
float d0 = -180 + 360f * k / SEG, d1 = -180 + 360f * (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);
|
||||
@@ -161,17 +166,17 @@ namespace GladiatorIdle.Arena
|
||||
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)
|
||||
for (float a = -180; a < 179.99f; 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;
|
||||
const int SEG = 180;
|
||||
for (int k = 0; k < SEG; k++)
|
||||
{
|
||||
float d0 = -78 + 156f * k / SEG, d1 = -78 + 156f * (k + 1) / SEG;
|
||||
float d0 = -180 + 360f * k / SEG, d1 = -180 + 360f * (k + 1) / SEG;
|
||||
var z0 = Vector2.Zero;
|
||||
float top = baseY - h, n = (d0 + d1) / 2;
|
||||
// Gebälk vorn und oben
|
||||
@@ -192,7 +197,7 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
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()))
|
||||
for (float a = -180; a < 179; a += step * (0.8f + 0.4f * (float)rng.NextDouble()))
|
||||
{
|
||||
if (rng.NextDouble() < 0.1) continue; // freier Platz
|
||||
float rad = MathHelper.ToRadians(a);
|
||||
@@ -270,18 +275,21 @@ namespace GladiatorIdle.Arena
|
||||
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;
|
||||
const float SPAN = 30, EXTRA = 180;
|
||||
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;
|
||||
const int SEG = 120;
|
||||
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));
|
||||
// Himmel: oberste Zeile des Bildes weit nach oben gezogen
|
||||
p.Quad(OnWall(d0, BACK_R, top - height * 2.5f), OnWall(d1, BACK_R, top - height * 2.5f), OnWall(d1, BACK_R, top), OnWall(d0, BACK_R, top),
|
||||
Inward((d0 + d1) / 2), Color.White, new Vector2(u0, 0), new Vector2(u1, 0), new Vector2(u1, 0.004f), new Vector2(u0, 0.004f));
|
||||
}
|
||||
return p;
|
||||
}
|
||||
@@ -299,8 +307,8 @@ namespace GladiatorIdle.Arena
|
||||
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;
|
||||
const int NX = 40, NZ = 40;
|
||||
float x0 = CX - 5200, x1 = CX + 5200, z0 = -(R - ZC) - 900, z1 = ZC + R + 900; // rundum bis hinter die Kamera
|
||||
Vector3 Pt(int i, int k) => new(x0 + (x1 - x0) * i / NX, Floor, z0 + (z1 - z0) * k / NZ);
|
||||
Color Shade(Vector3 v)
|
||||
{
|
||||
@@ -330,8 +338,8 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
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;
|
||||
const int SEG = 170;
|
||||
const float FROM = -180, TO = 180; // rundum (Kinofahrten drehen bis 360°)
|
||||
float tile = WALL_H * 3; // Textur 3:1
|
||||
for (int i = 0; i < SEG; i++)
|
||||
{
|
||||
@@ -348,10 +356,10 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
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;
|
||||
const int SEG = 170;
|
||||
for (int i = 0; i < SEG; i++)
|
||||
{
|
||||
float d0 = -75 + 150f * i / SEG, d1 = -75 + 150f * (i + 1) / SEG;
|
||||
float d0 = -180 + 360f * i / SEG, d1 = -180 + 360f * (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),
|
||||
@@ -366,7 +374,7 @@ namespace GladiatorIdle.Arena
|
||||
Part BuildGates(Texture2D gate)
|
||||
{
|
||||
var p = new Part { Tex = gate };
|
||||
var at = _look.Wall == "marble" ? new[] { -30f, 0f, 30f } : new[] { -30f, 30f };
|
||||
var at = _look.Wall == "marble" ? new[] { -30f, 0f, 30f, 180f, -120f, 120f } : new[] { -30f, 30f, 180f, -120f, 120f };
|
||||
foreach (float a in at)
|
||||
{
|
||||
float half = MathHelper.ToDegrees(130 / R); // 260 breit
|
||||
|
||||
@@ -37,14 +37,94 @@ namespace GladiatorIdle.Arena
|
||||
float k = 1 - MathF.Exp(-dt * 3.5f);
|
||||
if (FocusX is float fx) { targetZoom = 1.4f; target = new Vector2(fx, H / 2 + 30); k = 1 - MathF.Exp(-dt * 1.2f); }
|
||||
if (FollowX is float fw) { targetZoom = FollowZoom; target = new Vector2(fw, H / 2 + 40); k = 1 - MathF.Exp(-dt * 4f); } // Reise: ohne Begrenzung
|
||||
if (CineWeight > 0.01f) { target = Vector2.Lerp(target, new Vector2(CinePivot.X + CineFrameX, CinePivot.Y), CineWeight); targetZoom = MathHelper.Lerp(targetZoom, 1, CineWeight); }
|
||||
Center += (target - Center) * k;
|
||||
Zoom += (targetZoom - Zoom) * k;
|
||||
_trauma = MathF.Max(0, _trauma - dt * 1.7f);
|
||||
_punch *= MathF.Exp(-dt * 9f);
|
||||
if (calm) { _trauma = 0; _punch = 0; }
|
||||
UpdateYaw(dt, calm);
|
||||
UpdateCine(dt, calm);
|
||||
}
|
||||
|
||||
// ── Kinokamera: Fahrten um einen Drehpunkt (360°), Neigung (Untersicht), Heranfahren ──
|
||||
|
||||
/// Schlüsselbild einer Fahrt: Zeit (s), Drehung (Grad, beliebig, auch über 360), Neigung
|
||||
/// (Grad, negativ = von unten nach oben), Heranfahren (Design-Pixel näher).
|
||||
public readonly record struct Key(float T, float Yaw, float Pitch, float Dolly);
|
||||
|
||||
/// Drehpunkt der Fahrt (Weltpunkt, meist Brust eines Kämpfers); setzt die Szene jedes Bild.
|
||||
public Vector3 CinePivot;
|
||||
/// Bildlage des Drehpunkts: + schiebt ihn nach links (Platz für Tafeln rechts).
|
||||
public float CineFrameX;
|
||||
public float CineYaw { get; private set; }
|
||||
public float CinePitch { get; private set; }
|
||||
public float CineDolly { get; private set; }
|
||||
/// 0 = normale Seitenansicht, 1 = ganz in der Fahrt (Ein- und Ausblenden weich).
|
||||
public float CineWeight { get; private set; }
|
||||
Key[]? _shot; float _shotT, _orbitSpeed; bool _orbit; Key _orbitKey;
|
||||
|
||||
/// Fahrt aus Schlüsselbildern; danach weich zurück zur Seitenansicht.
|
||||
public void Shot(params Key[] keys) { if (keys.Length > 0) { _shot = keys; _shotT = 0; _orbit = false; } }
|
||||
|
||||
/// Fortlaufende Umrundung (Grad/s) mit fester Neigung und Nähe, bis <see cref="StopCine"/>.
|
||||
public void Orbit(float degPerSec, float pitch, float dolly)
|
||||
{
|
||||
_orbit = true; _shot = null; _orbitSpeed = degPerSec;
|
||||
_orbitKey = new Key(0, CineWeight > 0.01f ? CineYaw : 0, pitch, dolly);
|
||||
}
|
||||
|
||||
public void StopCine() { _shot = null; _orbit = false; }
|
||||
public bool CineActive => _shot != null || _orbit;
|
||||
|
||||
void UpdateCine(float dt, bool calm)
|
||||
{
|
||||
if (calm) { _shot = null; _orbit = false; CineWeight = 0; return; }
|
||||
float target = 0;
|
||||
if (_orbit)
|
||||
{
|
||||
_orbitKey = _orbitKey with { Yaw = _orbitKey.Yaw + _orbitSpeed * dt };
|
||||
Blend(_orbitKey, dt);
|
||||
target = 1;
|
||||
}
|
||||
else if (_shot is { } keys)
|
||||
{
|
||||
_shotT += dt;
|
||||
int i = 0;
|
||||
while (i < keys.Length - 1 && _shotT > keys[i + 1].T) i++;
|
||||
Key a = keys[i], b = keys[Math.Min(i + 1, keys.Length - 1)];
|
||||
float k = b.T > a.T ? MathHelper.Clamp((_shotT - a.T) / (b.T - a.T), 0, 1) : 1;
|
||||
k = k * k * (3 - 2 * k);
|
||||
CineYaw = MathHelper.Lerp(a.Yaw, b.Yaw, k); CinePitch = MathHelper.Lerp(a.Pitch, b.Pitch, k); CineDolly = MathHelper.Lerp(a.Dolly, b.Dolly, k);
|
||||
if (_shotT > keys[^1].T) _shot = null;
|
||||
target = 1;
|
||||
CineWeight = 1;
|
||||
}
|
||||
if (target == 0)
|
||||
{
|
||||
// zurück: Winkel auf den nächsten Vollkreis, Neigung und Nähe auf 0
|
||||
float home = MathF.Round(CineYaw / 360) * 360;
|
||||
float k = 1 - MathF.Exp(-dt * 3.2f);
|
||||
CineYaw += (home - CineYaw) * k; CinePitch -= CinePitch * k; CineDolly -= CineDolly * k;
|
||||
if (MathF.Abs(CineYaw - home) < 0.3f && MathF.Abs(CinePitch) < 0.2f && MathF.Abs(CineDolly) < 2) { CineYaw = 0; CinePitch = 0; CineDolly = 0; CineWeight = 0; }
|
||||
else CineWeight = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void Blend(Key to, float dt)
|
||||
{
|
||||
float k = CineWeight < 1 ? 1 - MathF.Exp(-dt * 3f) : 1;
|
||||
CineYaw += (to.Yaw - CineYaw) * (_orbit && CineWeight >= 1 ? 1 : k);
|
||||
CinePitch += (to.Pitch - CinePitch) * k; CineDolly += (to.Dolly - CineDolly) * k;
|
||||
CineWeight = 1;
|
||||
}
|
||||
|
||||
/// Wie sichtbar die Kampfebene (2D-Effekte) gerade ist: 1 von vorn, 0 von der Seite.
|
||||
public float PlaneAlpha => MathHelper.Clamp((MathF.Abs(MathF.Cos(MathHelper.ToRadians(Yaw + CineYaw))) - 0.35f) / 0.4f, 0, 1);
|
||||
/// Publikum im Vordergrund (Bildschirm-Ebene) nur in der Seitenansicht.
|
||||
public float FrontAlpha => 1 - CineWeight; // während einer Fahrt tritt das Publikum im Vordergrund ganz zurück
|
||||
static float WrapDeg(float d) { d %= 360; return d > 180 ? d - 360 : d < -180 ? d + 360 : d; }
|
||||
|
||||
/// Kameraverschiebung durch Rütteln (Design-Pixel).
|
||||
Vector2 ShakeOffset()
|
||||
{
|
||||
@@ -104,15 +184,58 @@ namespace GladiatorIdle.Arena
|
||||
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);
|
||||
var view = Matrix.CreateTranslation(-pivot) * Matrix.CreateRotationY(MathHelper.ToRadians(Yaw)) * Matrix.CreateTranslation(pivot);
|
||||
if (CineWeight > 0.001f)
|
||||
{
|
||||
// Kinofahrt: um den Drehpunkt drehen und neigen, dann heranfahren
|
||||
var cp = new Vector3(Center.X, CinePivot.Y, CinePivot.Z);
|
||||
view *= Matrix.CreateTranslation(-cp) * Matrix.CreateRotationY(MathHelper.ToRadians(CineYaw))
|
||||
* Matrix.CreateRotationX(MathHelper.ToRadians(CinePitch)) * Matrix.CreateTranslation(cp)
|
||||
* Matrix.CreateTranslation(0, 0, CineDolly - FitPull);
|
||||
}
|
||||
return view * Matrix.CreateTranslation(-Center.X, -EyeNow, -DIST);
|
||||
}
|
||||
|
||||
/// Augenhöhe mit Fahrt: wandert zum Drehpunkt, damit das Heranfahren auf ihn zielt.
|
||||
float EyeNow => MathHelper.Lerp(EyeY, CinePivot.Y, CineWeight * 0.85f);
|
||||
|
||||
/// Sicherung: so weit fährt die Kamera gerade zurück, damit alle Figuren im Bild bleiben.
|
||||
public float FitPull { get; private set; }
|
||||
|
||||
/// Figuren im Bild halten: ragt ein Punkt (Kopf, Füße) aus dem sicheren Bereich, zieht die
|
||||
/// Kamera schnell auf; ist genug Platz, kehrt sie langsam zur geplanten Nähe zurück.
|
||||
public void KeepInView(ReadOnlySpan<Vector3> points, float screenScale, Vector2 offset, int vpW, int vpH, float dt)
|
||||
{
|
||||
if (CineWeight < 0.01f && FitPull <= 0) return;
|
||||
var vp = View3() * Proj3(screenScale, offset, vpW, vpH);
|
||||
float worst = 0;
|
||||
foreach (var pt in points)
|
||||
{
|
||||
var c = Vector4.Transform(new Vector4(pt, 1), vp);
|
||||
if (c.W <= 1e-3f) { worst = MathF.Max(worst, 1); continue; } // hinter der Kamera
|
||||
float x = c.X / c.W, y = c.Y / c.W;
|
||||
worst = MathF.Max(worst, MathF.Max(MathF.Abs(x) - 0.78f, MathF.Abs(y) - 0.76f));
|
||||
}
|
||||
if (worst > 0) FitPull += (900 + 6000 * worst) * dt;
|
||||
else if (worst < -0.08f) FitPull = MathF.Max(0, FitPull - 260 * dt);
|
||||
FitPull = MathF.Min(FitPull, CineDolly + 1400); // höchstens etwas weiter weg als die Seitenansicht
|
||||
// nie hinter die Arenamauer: steht die Kamera außerhalb des Rings, fährt sie wieder heran
|
||||
if (Ring is { } ring && CineWeight > 0.01f)
|
||||
{
|
||||
var eye = Matrix.Invert(View3()).Translation;
|
||||
float d = Vector2.Distance(new Vector2(eye.X, eye.Z), ring.Center);
|
||||
if (d > ring.R - 260) FitPull -= (d - (ring.R - 260)) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
/// Ring der Arena (Mitte x/z, Radius): die Kinokamera bleibt innen.
|
||||
public (Vector2 Center, float R)? Ring;
|
||||
|
||||
/// 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 ex = Center.X, ey = EyeNow, 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(
|
||||
|
||||
@@ -65,9 +65,10 @@ namespace GladiatorIdle.Arena
|
||||
/// Getippte Zeichen (vom Fenster) für den Namen.
|
||||
public void OnText(char c, Keys key)
|
||||
{
|
||||
if (key == Keys.Back) { if (Name.Length > 0) Name = Name[..^1]; return; }
|
||||
if (key == Keys.Back) { if (Name.Length > 0) Name = Name[..^1]; _typedAt = _t; return; }
|
||||
if (key == Keys.Enter) return;
|
||||
if (!char.IsControl(c) && Name.Length < 18) Name += c;
|
||||
_typedAt = _t;
|
||||
}
|
||||
|
||||
// ── Takt ────────────────────────────────────────────────────
|
||||
@@ -168,8 +169,13 @@ namespace GladiatorIdle.Arena
|
||||
_thumbClass = Class; _thumbTint = Tint; _thumbsDirty = false;
|
||||
}
|
||||
|
||||
double _typedAt = -1;
|
||||
|
||||
void DrawNameField(SpriteBatch sb)
|
||||
{
|
||||
// nach ~1 s Tipp-Pause: Stimme für Name und Schwur im Hintergrund vorbereiten
|
||||
if (_typedAt >= 0 && _t - _typedAt > 1.0 && Name.Trim().Length > 0) { NameVoice.Prepare(Name); _typedAt = -1; }
|
||||
|
||||
var r = new RectangleF(170, 968, 600, 68);
|
||||
D.Text(sb, Assets.SansBold, 20, L.t("create.name"), new Vector2(r.X, r.Y - 22), D.Sand);
|
||||
Ui.Panel(sb, r, D.Gold);
|
||||
|
||||
@@ -123,8 +123,12 @@ namespace GladiatorIdle.Arena
|
||||
}
|
||||
|
||||
/// Zeichnen in der Vordergrund-Ebene (eigene Kamera-Matrix mit Parallaxe).
|
||||
/// Deckkraft (Kinofahrt: das Publikum im Vordergrund tritt zurück).
|
||||
public float Alpha = 1;
|
||||
|
||||
public void Draw(SpriteBatch sb, bool calm)
|
||||
{
|
||||
if (Alpha <= 0.01f) return;
|
||||
foreach (var f in _fans)
|
||||
{
|
||||
// jubelnd: Fäuste im eigenen Takt hoch und runter (Wechsel der Bilder)
|
||||
@@ -139,7 +143,7 @@ namespace GladiatorIdle.Arena
|
||||
float scale = f.H / tex.Height;
|
||||
float bottom = f.H > 260 ? Camera.H + 175 : Camera.H + 70;
|
||||
var pos = new Vector2(f.X, bottom - bob);
|
||||
var c = new Color(f.Shade * 1.1f, f.Shade * 0.9f, f.Shade * 0.75f);
|
||||
var c = new Color(f.Shade * 1.1f, f.Shade * 0.9f, f.Shade * 0.75f) * Alpha;
|
||||
sb.Draw(tex, pos, null, c, calm ? 0 : f.Tilt, new Vector2(tex.Width / 2f, tex.Height),
|
||||
new Vector2(scale / MathF.Sqrt(stretch), scale * stretch * breathe),
|
||||
f.Mirror ? SpriteEffects.FlipHorizontally : SpriteEffects.None, 0);
|
||||
@@ -149,7 +153,7 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
float a = MathF.Min(1, p.Life * 1.5f);
|
||||
float flip = MathF.Abs(MathF.Cos(p.Angle * 1.7f)); // dreht sich in der Luft
|
||||
sb.Draw(Assets.Disc, p.Pos, null, p.Color * a, p.Angle, new Vector2(64), new Vector2(p.Size / 128f, p.Size * (0.35f + 0.65f * flip) / 128f / 1.6f),
|
||||
sb.Draw(Assets.Disc, p.Pos, null, p.Color * (a * Alpha), p.Angle, new Vector2(64), new Vector2(p.Size / 128f, p.Size * (0.35f + 0.65f * flip) / 128f / 1.6f),
|
||||
SpriteEffects.None, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,31 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
enum Phase { Intro, Countdown, Fight, End }
|
||||
|
||||
const float COUNTDOWN = 2.2f, SPREAD = 1.3f;
|
||||
const float SPREAD = 1.3f;
|
||||
float COUNTDOWN => _calm ? 2.2f : 3.4f; // mit Kinofahrt etwas länger
|
||||
|
||||
// ── Kinofahrten: worum sich die Kamera dreht ──
|
||||
enum Pivot { Mid, Player, PlayerHead, Enemy, Winner }
|
||||
Pivot _pivot;
|
||||
Vector3 PivotPos() => _pivot switch
|
||||
{
|
||||
Pivot.Player => new Vector3(_pv.X, Stage.FloorY - Stage.FigH * 0.55f, 0),
|
||||
Pivot.PlayerHead => new Vector3(_pv.X, Stage.FloorY - Stage.FigH * 0.86f, 0),
|
||||
Pivot.Enemy => new Vector3(_ev.X, Stage.FloorY - Stage.FigH * 0.55f, 0),
|
||||
Pivot.Winner => new Vector3(Won ? _pv.X : _ev.X, Stage.FloorY - Stage.FigH * 0.55f, 0),
|
||||
_ => new Vector3((_pv.X + _ev.X) / 2, Stage.FloorY - Stage.FigH * 0.5f, 0),
|
||||
};
|
||||
|
||||
/// Fahrt ab dem jetzigen Stand der Kamera (weicher Übergang).
|
||||
void Cine(Pivot pivot, params Camera.Key[] keys)
|
||||
{
|
||||
if (_calm) return;
|
||||
_pivot = pivot;
|
||||
var all = new Camera.Key[keys.Length + 1];
|
||||
all[0] = new Camera.Key(0, _cam.CineYaw, _cam.CinePitch, _cam.CineDolly);
|
||||
Array.Copy(keys, 0, all, 1, keys.Length);
|
||||
_cam.Shot(all);
|
||||
}
|
||||
|
||||
readonly GameState _game;
|
||||
readonly Enemy _enemy;
|
||||
@@ -55,7 +79,8 @@ namespace GladiatorIdle.Arena
|
||||
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;
|
||||
bool _wasFury, _announced;
|
||||
Matrix _v3, _p3; int _vw = 1, _vh = 1; float _scale = 1; Vector2 _offset;
|
||||
readonly bool _calm = AppSettings.ReduceMotion;
|
||||
readonly AbilityBar _bar = new();
|
||||
|
||||
@@ -209,6 +234,7 @@ namespace GladiatorIdle.Arena
|
||||
string arena = Art.Arena(ArenaDef.All[game.Arena]);
|
||||
_backdrop = Assets.Sprite(arena, "jpg");
|
||||
_set = ArenaSet.Get(game.Arena, arena, _calm);
|
||||
_cam.Ring = ArenaSet.Ring;
|
||||
_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);
|
||||
@@ -255,6 +281,15 @@ namespace GladiatorIdle.Arena
|
||||
}
|
||||
return;
|
||||
case Phase.Countdown:
|
||||
if (!_announced)
|
||||
{
|
||||
_announced = true;
|
||||
NameVoice.Play(NameVoice.Kind.Enter, 1f, 8); // „Gladiator Spartacus!“
|
||||
if (_enemy.IsChampion) // Champion: von unten nah heran, dann hoch und zurück
|
||||
Cine(Pivot.Enemy, new(0.01f, -35, -24, 1700), new(1.7f, -55, -16, 1550), new(COUNTDOWN, 0, 0, 0));
|
||||
else if (_tut == TutStep.Off) // volle Umrundung beider Kämpfer
|
||||
Cine(Pivot.Mid, new(0.01f, -320, 5, 1100), new(2.7f, -20, 2, 600), new(COUNTDOWN, 0, 0, 0));
|
||||
}
|
||||
int n = 3 - (int)(_phaseTime / (COUNTDOWN / 3));
|
||||
if (n != _countShown) { _countShown = n; if (n >= 1) SoundManager.PlayTick(); }
|
||||
if (_phaseTime >= COUNTDOWN)
|
||||
@@ -275,10 +310,12 @@ namespace GladiatorIdle.Arena
|
||||
_phase = Phase.End; _phaseTime = 0; Won = Duel.PlayerWon;
|
||||
// Gnadenstoß: nicht in der Einführung und nicht gegen Legenden
|
||||
_missio = !TutorialRan && _enemy.Display == null;
|
||||
if (Won && !_missio) NameVoice.Play(NameVoice.Kind.Chant, 1f, 0);
|
||||
_crowdMercy = Duel.DamageToPlayer >= Duel.Player.MaxHp * 0.3 || Duel.Time >= 25; // tapferer Gegner
|
||||
if (!Won) _spared = Duel.PlayerParries >= 2 || Duel.Enemy.Hp <= Duel.Enemy.MaxHp * 0.5 || Duel.Time >= 30;
|
||||
_cam.FocusX = Won ? _pv.X : _ev.X;
|
||||
if (!_calm) _cam.HoldYaw(Won ? 24 : -24); // langsame Fahrt um den Sieger
|
||||
// Kinomoment: Kamera kippt nach unten, Nahansicht auf den Sieger über dem Gefallenen
|
||||
Cine(Pivot.Winner, new(0.6f, Won ? 35 : -35, -20, 1500), new(2.8f, Won ? 70 : -70, -17, 1450));
|
||||
if (Won) SoundManager.PlayVictory(); else SoundManager.PlayDefeat();
|
||||
}
|
||||
break;
|
||||
@@ -296,7 +333,16 @@ namespace GladiatorIdle.Arena
|
||||
if (_ev.Update(dt, realDt, Duel.Enemy, Spread(Duel.Enemy.X), _calm)) { _fx.Dust(new Vector2(_ev.X, Stage.FloorY), 2, 30, 30, 40); SoundManager.PlayStep(); }
|
||||
StateSounds();
|
||||
FuryUpdate(realDt);
|
||||
_cam.CinePivot = PivotPos();
|
||||
_cam.Update(realDt, _pv.X, _ev.X, _calm);
|
||||
_crowd.Alpha = _cam.FrontAlpha;
|
||||
// beide Kämpfer immer ganz im Bild (Kopf und Füße)
|
||||
float head = Stage.FloorY - Stage.FigH * 1.08f, feet = Stage.FloorY + 12;
|
||||
Span<Vector3> pts = stackalloc Vector3[]
|
||||
{
|
||||
new(_pv.X - 60, head, 0), new(_pv.X + 60, feet, 0), new(_ev.X - 60, head, 0), new(_ev.X + 60, feet, 0),
|
||||
};
|
||||
_cam.KeepInView(pts, _scale, _offset, _vw, _vh, realDt);
|
||||
_fx.Motes(_calm ? 0 : 60, Camera.W, Camera.H);
|
||||
_fx.Update(dt > 0 ? dt : realDt * 0.15f);
|
||||
_crowd.Update(realDt);
|
||||
@@ -318,7 +364,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
|
||||
if (fury && !_wasFury) // Kinomoment: aufs Gesicht, dann zurück zur Hiebserie
|
||||
Cine(Pivot.PlayerHead, new(0.3f, -28 * _pv.Facing, -9, 1750), new(0.75f, -34 * _pv.Facing, -7, 1700), new(1.15f, 0, 0, 0));
|
||||
_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;
|
||||
@@ -498,7 +545,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
|
||||
if (!_calm) { _cam.Lift(140); Cine(Pivot.Player, new(0.35f, 14f * (float)Duel.Player.Facing, -12, 450), new(0.95f, 0, 0, 0)); } // Untersicht folgt dem Sprung
|
||||
_crowd.Excite(0.15f);
|
||||
break;
|
||||
case DuelEventType.Super:
|
||||
@@ -585,6 +632,8 @@ namespace GladiatorIdle.Arena
|
||||
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;
|
||||
_plane.Alpha = _cam.PlaneAlpha; // Kinofahrt: 2D-Effekte nicht von der Kante zeigen
|
||||
_v3 = v3; _p3 = p3; _vw = vw; _vh = vh; _scale = scale; _offset = offset;
|
||||
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);
|
||||
|
||||
@@ -691,12 +740,9 @@ 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 (Kampfebene) und HUD (Bildschirm)
|
||||
Plane(BlendState.AlphaBlend);
|
||||
foreach (var f in _floaters) if (!f.Big) DrawFloater(sb, f);
|
||||
sb.End();
|
||||
// Zahlen über den Köpfen (an der Welt-Stelle, aber am Bildschirm gezeichnet: auch beim Schwenk lesbar) und HUD
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
||||
foreach (var f in _floaters) if (f.Big) DrawFloater(sb, f);
|
||||
foreach (var f in _floaters) DrawFloater(sb, f);
|
||||
DrawHud(sb);
|
||||
sb.End();
|
||||
_bar.Draw(gd, sb, ui);
|
||||
@@ -745,6 +791,13 @@ namespace GladiatorIdle.Arena
|
||||
float pop = f.Big ? 1 + 0.6f * MathF.Max(0, 1 - f.Age * 6) : 1 + 0.5f * MathF.Max(0, 1 - f.Age * 8);
|
||||
float a = MathHelper.Clamp((1 - k) * 2.5f, 0, 1);
|
||||
var pos = f.Pos - new Vector2(0, f.Big ? 0 : 110 * MathF.Sqrt(k));
|
||||
if (!f.Big)
|
||||
{
|
||||
// Weltpunkt der Kampfebene → Bildschirm → Design-Pixel
|
||||
var px = _cam.ToPixel(new Vector3(pos, 0), _v3, _p3, _vw, _vh, out float w);
|
||||
pos = (px - _offset) / _scale;
|
||||
pop /= MathF.Max(0.6f, w);
|
||||
}
|
||||
D.Text(sb, f.Big ? Assets.Serif : Assets.SansBold, f.Size, f.Text, pos, f.Color * a, Align.Center, pop);
|
||||
}
|
||||
|
||||
@@ -824,6 +877,7 @@ namespace GladiatorIdle.Arena
|
||||
|
||||
void MissioUpdate(float realDt, Input input)
|
||||
{
|
||||
if (_missioT == 0 && !_calm) { _pivot = Pivot.Mid; _cam.Orbit(Won ? 42 : -42, -8, 1350); } // die Ränge rundum
|
||||
_missioT += realDt;
|
||||
bool wantMercy = Won ? _crowdMercy : _spared == true;
|
||||
float target = wantMercy ? 0.12f : 0.88f;
|
||||
@@ -870,10 +924,13 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
if (_decidedAt >= 0) return;
|
||||
_decidedAt = _missioT;
|
||||
float y0 = _cam.CineYaw;
|
||||
Cine(Pivot.Winner, new(1.2f, y0 + 50, -22, 1550), new(5f, y0 + 120, -18, 1480)); // Heldenblick von unten
|
||||
if (!Won) { if (mercy) SoundManager.PlayCheer(); else SoundManager.PlayBoo(); return; }
|
||||
_mercy = mercy;
|
||||
bool match = mercy == _crowdMercy;
|
||||
if (match) { _crowd.Wave(); SoundManager.PlayCheer(); } else SoundManager.PlayBoo();
|
||||
if (match) { _crowd.Wave(); SoundManager.PlayCheer(); NameVoice.Play(_enemy.IsChampion ? NameVoice.Kind.Win : NameVoice.Kind.Chant, 1f, 0); }
|
||||
else SoundManager.PlayBoo();
|
||||
if (!mercy) { _pv.HoldClip = "powerup"; _cam.Shake(0.35f); SoundManager.PlayFury(); } // Kampfschrei, keine Tötung
|
||||
Big(L.t(mercy ? "missio.mitte" : "missio.iugula"), mercy ? D.Gold : new Color(255, 120, 70));
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ namespace GladiatorIdle.Arena
|
||||
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);
|
||||
_stage.Cam.Orbit(18, -8, 1250);
|
||||
_stage.Cam.CineFrameX = 600; // Gladiator links, die Bilanz rechts // langsam um den freien Gladiator, leicht von unten
|
||||
}
|
||||
|
||||
void Next(Phase p)
|
||||
@@ -63,6 +64,7 @@ namespace GladiatorIdle.Arena
|
||||
if (p != Phase.Clip) SoundManager.StopVoice();
|
||||
_phase = p; _phaseT = 0;
|
||||
SoundManager.PlayClick();
|
||||
if (p == Phase.Summary) NameVoice.Play(NameVoice.Kind.Chant, 1f, 0); // die Arena ruft den Namen
|
||||
if (p == Phase.Summary && !AppSettings.ReduceMotion)
|
||||
{
|
||||
// Goldregen zum Auftakt der Bilanz
|
||||
@@ -81,7 +83,10 @@ namespace GladiatorIdle.Arena
|
||||
_ui.Begin(input, ui);
|
||||
_dummy.StateTime += dt;
|
||||
_hero.Update(dt, dt, _dummy, HERO_X, AppSettings.ReduceMotion);
|
||||
_stage.Cam.CinePivot = new Vector3(HERO_X, Stage.FloorY - Stage.FigH * 0.55f, 0);
|
||||
_stage.Cam.Update(dt, HERO_X, HERO_X, AppSettings.ReduceMotion);
|
||||
Span<Vector3> pts = stackalloc Vector3[] { new(HERO_X - 80, Stage.FloorY - Stage.FigH * 1.1f, 0), new(HERO_X + 80, Stage.FloorY + 12, 0) };
|
||||
_stage.Cam.KeepInView(pts, _stage.LastScale, _stage.LastOffset, _stage.LastW, _stage.LastH, dt);
|
||||
_fx.Motes(AppSettings.ReduceMotion ? 0 : 40, Camera.W, Camera.H);
|
||||
_fx.Update(dt);
|
||||
if (_phase == Phase.Clip)
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace GladiatorIdle.Arena
|
||||
// Ankunft: Pose und Ton einmal
|
||||
if (before < HomeWalk && _homeT >= HomeWalk)
|
||||
{
|
||||
if (rep.Success) { _dummy.Set(DuelState.Victory); SoundManager.PlayVictory(); SoundManager.PlayCheer(); _crowd.Wave(); }
|
||||
if (rep.Success) { _dummy.Set(DuelState.Victory); SoundManager.PlayVictory(); SoundManager.PlayCheer(); _crowd.Wave(); NameVoice.Play(NameVoice.Kind.Chant, 0.6f); }
|
||||
else { _dummy.Set(DuelState.Stunned); _dummy.StunLeft = 99; SoundManager.PlayDefeat(); }
|
||||
}
|
||||
_dummy.StateTime += dt;
|
||||
|
||||
@@ -102,6 +102,8 @@ namespace GladiatorIdle.Arena
|
||||
_jStone.Box(new Vector3(0, floor - 95, 0), new Vector3(40, 12, 36), new Color(150, 144, 132));
|
||||
_jStone.Freeze();
|
||||
_jProps.Clear();
|
||||
foreach (var k in land.Props) if (Assets.Sprite(k) is Texture2D t) Assets.Mipmapped(t); // vorab, kein Ruckler
|
||||
foreach (var m in new[] { _jGround, _jPath }) if (m?.Tex != null) Assets.Mipmapped(m.Tex);
|
||||
}
|
||||
|
||||
/// Licht nach Tageszeit (0 Morgen … 0,25 Mittag … 0,5 Abend … 0,75 Nacht … 1 Morgen).
|
||||
|
||||
@@ -111,7 +111,16 @@ namespace GladiatorIdle.Arena
|
||||
_game.Tick(dt); // Training, Einnahmen, Erholung
|
||||
float heroX = Homecoming ? UpdateHomecoming(dt, input) : HERO_X; // Heimkehr: läuft von links herein
|
||||
_hero.Update(dt, dt, _dummy, heroX, AppSettings.ReduceMotion);
|
||||
_stage.Cam.CinePivot = new Vector3(HERO_X, Stage.FloorY - Stage.FigH * 0.55f, 0);
|
||||
if ((_cineIn -= dt) <= 0 && _drawerK < 0.02f && _overlay == Overlay.None && !Modal)
|
||||
{
|
||||
_cineIn = 25;
|
||||
_stage.Cam.Shot(new Camera.Key(0, 0, 0, 0), new Camera.Key(3, 38, -6, 900), new Camera.Key(6.5f, 0, 0, 0)); // sanfte Fahrt um den Gladiator
|
||||
}
|
||||
_stage.Cam.Update(dt, Camera.W / 2 - 1800, Camera.W / 2 + 1800, AppSettings.ReduceMotion); // weiter weg, ruhige Drift
|
||||
_crowd.Alpha = _stage.Cam.FrontAlpha;
|
||||
Span<Vector3> pts = stackalloc Vector3[] { new(HERO_X - 80, Stage.FloorY - Stage.FigH * 1.1f, 0), new(HERO_X + 80, Stage.FloorY + 12, 0) };
|
||||
_stage.Cam.KeepInView(pts, _stage.LastScale, _stage.LastOffset, _stage.LastW, _stage.LastH, dt);
|
||||
_lastDt = dt;
|
||||
UpdateAdventure();
|
||||
_crowd.Update(dt);
|
||||
@@ -133,6 +142,7 @@ namespace GladiatorIdle.Arena
|
||||
|
||||
public bool DrawerOpen => _drawer != Drawer.None;
|
||||
float _lastDt = 1 / 60f;
|
||||
float _cineIn = 12;
|
||||
|
||||
/// Testlauf: Schublade öffnen ("none", "gladiator", "skills", "ludus", "expedition", "hall"), sofort ganz offen.
|
||||
public void DevOpen(string d)
|
||||
|
||||
158
Mono/Arena/OathScene.cs
Normal file
158
Mono/Arena/OathScene.cs
Normal file
@@ -0,0 +1,158 @@
|
||||
using System;
|
||||
using GladiatorIdle.Gfx;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using D = GladiatorIdle.Gfx.Draw;
|
||||
|
||||
namespace GladiatorIdle.Arena
|
||||
{
|
||||
/// <summary>
|
||||
/// Schwur nach der Erstellung: der neue Gladiator steht in einer kleinen Arena, die Kamera fährt
|
||||
/// von unten langsam hoch und um ihn herum, er spricht seine Rede mit dem eigenen Namen
|
||||
/// (<see cref="NameVoice.Kind.Oath"/>, Untertitel je Satz). Beim letzten Satz reckt er die Waffe,
|
||||
/// das Publikum ruft seinen Namen. Klick, Leertaste oder Esc überspringt.
|
||||
/// </summary>
|
||||
internal sealed class OathScene
|
||||
{
|
||||
readonly GameState _game;
|
||||
readonly Stage3D _stage = new(1, AppSettings.ReduceMotion);
|
||||
readonly FighterView _hero;
|
||||
readonly DuelFighter _dummy = new() { IsPlayer = true, Facing = 1, MaxHp = 1, Hp = 1 };
|
||||
readonly Particles _fx = new();
|
||||
const float HERO_X = 960, WAIT = 3.4f, SILENT_LINE = 3.2f, PRELUDE = 1.8f;
|
||||
float _t, _start = -1, _length, _endAt = -1;
|
||||
int _shown = -1;
|
||||
bool _voiced, _cheered;
|
||||
float[] _times = Array.Empty<float>();
|
||||
string[] _lines = Array.Empty<string>();
|
||||
|
||||
public bool Done { get; private set; }
|
||||
|
||||
public OathScene(GameState game)
|
||||
{
|
||||
_game = game;
|
||||
string hero = Art.Hero(game.Class, game.Look.Preset);
|
||||
_hero = Assets.Has(hero) ? new FighterView(hero, 0, game.Look.Color) : new FighterView(Art.Fighter(game.Class), 0, -1, game.Look.Color);
|
||||
_fx.Calm = AppSettings.ReduceMotion;
|
||||
_stage.Cam.CinePivot = new Vector3(HERO_X, Stage.FloorY - Stage.FigH * 0.6f, 0);
|
||||
// Atmosphäre: schwere Trommeln und Bläser, Publikum in der Ferne; die Rede setzt nach dem Vorspiel ein
|
||||
SoundManager.StopAll();
|
||||
SoundManager.PlayMusic("music_oath", loop: false);
|
||||
SoundManager.PlayAmbience("amb_crowd");
|
||||
}
|
||||
|
||||
/// Testläufe: Zeit der Rede setzen (Aufnahmen).
|
||||
public float Time => _start < 0 ? -1 : _t - _start;
|
||||
|
||||
void Begin()
|
||||
{
|
||||
_lines = NameVoice.OathLines;
|
||||
var pcm = AppSettings.Narration ? NameVoice.Get(NameVoice.Kind.Oath) : null;
|
||||
if (pcm != null && NameVoice.OathTimes.Length == _lines.Length)
|
||||
{
|
||||
_times = NameVoice.OathTimes;
|
||||
_length = pcm.Length / 2f / 44100f;
|
||||
SoundManager.PlayPcm("oath", pcm);
|
||||
_voiced = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// ohne Stimme: nur Untertitel
|
||||
_times = new float[_lines.Length];
|
||||
for (int i = 0; i < _times.Length; i++) _times[i] = i * SILENT_LINE;
|
||||
_length = _lines.Length * SILENT_LINE;
|
||||
}
|
||||
_start = _t;
|
||||
// Kamera: nah von unten, langsam hoch und herum, am Ende aufziehen
|
||||
_stage.Cam.Shot(new Camera.Key(0, -25, -24, 1750), new Camera.Key(_length * 0.55f, 35, -13, 1450),
|
||||
new Camera.Key(_length + 0.6f, 85, -6, 900), new Camera.Key(_length + 4, 110, -4, 700));
|
||||
}
|
||||
|
||||
public void Update(float dt, Input input)
|
||||
{
|
||||
_t += dt;
|
||||
if (_start < 0 && _t >= PRELUDE && (NameVoice.Get(NameVoice.Kind.Oath) != null || _t > WAIT || !NameVoice.OathAvailable)) Begin();
|
||||
float s = Time;
|
||||
if (s >= 0)
|
||||
{
|
||||
int line = 0;
|
||||
while (line < _times.Length - 1 && s >= _times[line + 1]) line++;
|
||||
if (line != _shown) _shown = line;
|
||||
// letzter Satz: Waffe hoch, Menge jubelt, danach ruft sie den Namen
|
||||
if (_lines.Length > 0 && line == _lines.Length - 1 && _dummy.State != DuelState.Victory) _dummy.Set(DuelState.Victory);
|
||||
if (!_cheered && s >= _length + 0.2f)
|
||||
{
|
||||
_cheered = true;
|
||||
SoundManager.PlayCheer();
|
||||
NameVoice.Play(NameVoice.Kind.Chant, 1f, 0);
|
||||
_endAt = _t + 4.2f;
|
||||
}
|
||||
}
|
||||
_dummy.StateTime += dt;
|
||||
_hero.Update(dt, dt, _dummy, HERO_X, AppSettings.ReduceMotion);
|
||||
_stage.Cam.CinePivot = new Vector3(HERO_X, Stage.FloorY - Stage.FigH * 0.6f, 0);
|
||||
_stage.Cam.Update(dt, HERO_X, HERO_X, AppSettings.ReduceMotion);
|
||||
Span<Vector3> pts = stackalloc Vector3[] { new(HERO_X - 90, Stage.FloorY - Stage.FigH * 1.1f, 0), new(HERO_X + 90, Stage.FloorY + 12, 0) };
|
||||
_stage.Cam.KeepInView(pts, _stage.LastScale, _stage.LastOffset, _stage.LastW, _stage.LastH, dt);
|
||||
_fx.Motes(AppSettings.ReduceMotion ? 0 : 50, Camera.W, Camera.H);
|
||||
_fx.Update(dt);
|
||||
if (_endAt > 0 && _t >= _endAt) Done = true;
|
||||
if (input.LeftClick || input.Pressed(Keys.Space) || input.Pressed(Keys.Escape) || input.Pressed(Keys.Enter))
|
||||
{
|
||||
if (_voiced) SoundManager.CutEffects(); // Rede weich ausblenden
|
||||
Done = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw(GraphicsDevice gd, SpriteBatch sb, BasicEffect fx, float scale, Vector2 offset)
|
||||
{
|
||||
D.UiScale = scale;
|
||||
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
|
||||
_stage.Prepare(gd, scale, offset);
|
||||
_stage.DrawSet(gd, sb, _t, _cheered ? 1f : 0.35f);
|
||||
_stage.Shadows(gd, sb, 0, _hero);
|
||||
_stage.FloorLight(sb, HERO_X, 900, 0.25f);
|
||||
Stage3D.BeginFigures(gd);
|
||||
_stage.Use(_hero);
|
||||
_hero.DrawBody(gd, fx, _dummy, AppSettings.ReduceMotion);
|
||||
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);
|
||||
_fx.DrawAdd(sb);
|
||||
sb.End();
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
||||
// Kinobalken oben und unten
|
||||
float bar = Camera.H * 0.09f;
|
||||
D.Rect(sb, new RectangleF(0, 0, Camera.W, bar), Color.Black);
|
||||
D.Rect(sb, new RectangleF(0, Camera.H - bar, Camera.W, bar), Color.Black);
|
||||
float s = Time;
|
||||
if (s >= 0 && _shown >= 0 && _shown < _lines.Length && s < _length + 0.4f)
|
||||
{
|
||||
float since = s - _times[_shown];
|
||||
float a = MathHelper.Clamp(since / 0.35f, 0, 1);
|
||||
D.Glow(sb, new Vector2(Camera.W / 2, Camera.H - 170), new Vector2(1900, 230), Color.Black * (0.55f * a));
|
||||
// mittig, bei Bedarf in zwei Zeilen (am Leerzeichen nahe der Mitte geteilt)
|
||||
string text = _lines[_shown];
|
||||
var col = new Color(250, 238, 210) * a;
|
||||
if (D.Measure(Assets.Serif, 38, text).X <= 1600)
|
||||
D.Text(sb, Assets.Serif, 38, text, new Vector2(Camera.W / 2, Camera.H - 170), col, Align.Center);
|
||||
else
|
||||
{
|
||||
int mid = text.Length / 2, cut = text.LastIndexOf(' ', mid);
|
||||
int after = text.IndexOf(' ', mid);
|
||||
if (cut < 0 || (after >= 0 && after - mid < mid - cut)) cut = after;
|
||||
if (cut < 0) cut = mid;
|
||||
D.Text(sb, Assets.Serif, 38, text[..cut].Trim(), new Vector2(Camera.W / 2, Camera.H - 196), col, Align.Center);
|
||||
D.Text(sb, Assets.Serif, 38, text[cut..].Trim(), new Vector2(Camera.W / 2, Camera.H - 146), col, Align.Center);
|
||||
}
|
||||
}
|
||||
if (_cheered)
|
||||
{
|
||||
float k = MathHelper.Clamp((s - _length - 0.2f) / 0.6f, 0, 1);
|
||||
D.Text(sb, Assets.Serif, 110, _game.Name.ToUpperInvariant(), new Vector2(Camera.W / 2, Camera.H * 0.3f), D.Gold * k, Align.Center, 1 + 0.25f * (1 - k));
|
||||
}
|
||||
D.Text(sb, Assets.Sans, 17, L.t("oath.skip"), new Vector2(Camera.W - 40, Camera.H - bar / 2), D.Dim, Align.Right);
|
||||
sb.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,8 @@ namespace GladiatorIdle.Arena
|
||||
() => { AppSettings.Muted = !AppSettings.Muted; if (!AppSettings.Muted) SoundManager.StartAmbient(); });
|
||||
y += 56;
|
||||
Toggle(sb, x, y, w, L.t("settings.narration"), AppSettings.Narration, () => AppSettings.Narration = !AppSettings.Narration);
|
||||
y += 56;
|
||||
Toggle(sb, x, y, w, L.t("settings.namecalls"), AppSettings.NameCalls, () => AppSettings.NameCalls = !AppSettings.NameCalls);
|
||||
|
||||
// Anzeige
|
||||
y += 80;
|
||||
|
||||
@@ -22,7 +22,11 @@ namespace GladiatorIdle.Arena
|
||||
public Matrix Proj3 { get; private set; }
|
||||
readonly bool _calm;
|
||||
BasicEffect? _plane;
|
||||
int _vw, _vh; float _scale = 1;
|
||||
int _vw = 1920, _vh = 1080; float _scale = 1;
|
||||
public Vector2 LastOffset { get; private set; }
|
||||
public float LastScale => _scale;
|
||||
public int LastW => _vw;
|
||||
public int LastH => _vh;
|
||||
|
||||
public Stage3D(int arena, bool calm)
|
||||
{
|
||||
@@ -30,6 +34,7 @@ namespace GladiatorIdle.Arena
|
||||
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);
|
||||
Cam.Ring = ArenaSet.Ring;
|
||||
}
|
||||
|
||||
/// Andere Arena (Aufstieg): Kulisse neu bauen.
|
||||
@@ -43,11 +48,12 @@ namespace GladiatorIdle.Arena
|
||||
/// Matrizen für dieses Bild.
|
||||
public void Prepare(GraphicsDevice gd, float scale, Vector2 offset)
|
||||
{
|
||||
_vw = gd.Viewport.Width; _vh = gd.Viewport.Height; _scale = scale;
|
||||
_vw = gd.Viewport.Width; _vh = gd.Viewport.Height; _scale = scale; LastOffset = offset;
|
||||
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;
|
||||
_plane.Alpha = Cam.PlaneAlpha; // 2D-Effekte der Kampfebene nicht von der Kante zeigen
|
||||
}
|
||||
|
||||
/// Kulisse (Tiefe und Stencil frisch), Feuer als Licht.
|
||||
|
||||
Reference in New Issue
Block a user