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:
543
Mono/Arena/ArenaSet.cs
Normal file
543
Mono/Arena/ArenaSet.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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> > 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, <1 weiter hinten.
|
||||
public Matrix View(float screenScale, Vector2 offset, float parallax = 1f)
|
||||
{
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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
135
Mono/Arena/Stage3D.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ namespace GladiatorIdle
|
||||
DuelScene? _scene;
|
||||
ModelTestScene? _model; // --model3d: 3D-Test
|
||||
FreedomScene? _freedom; // Freiheit: Clip, Bilanz, Götter
|
||||
OfflineReport? _welcome; // was offline passiert ist (beim Weiterspielen gezeigt)
|
||||
LeaderboardScene? _board; // Bestenliste (aus dem Menü)
|
||||
bool _nextLife; // nächste Erstellung behält das Profil (Legenden, Götter)
|
||||
Legend? _legend; // laufendes Duell gegen eine Legende
|
||||
@@ -36,6 +37,7 @@ namespace GladiatorIdle
|
||||
static readonly bool DevChampionRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--champion") >= 0;
|
||||
static readonly bool DevAdventureRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--adventure") >= 0;
|
||||
static readonly bool DevBoardRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--leaderboard") >= 0;
|
||||
static readonly bool DevTutorialRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--tutorial") >= 0;
|
||||
static readonly bool Model3DTest = Array.IndexOf(Environment.GetCommandLineArgs(), "--model3d") >= 0;
|
||||
SettingsOverlay _settings = null!;
|
||||
bool _paused;
|
||||
@@ -59,9 +61,11 @@ namespace GladiatorIdle
|
||||
|
||||
public ArenaGame()
|
||||
{
|
||||
_gdm = new GraphicsDeviceManager(this) { SynchronizeWithVerticalRetrace = true, GraphicsProfile = GraphicsProfile.HiDef };
|
||||
_gdm = new GraphicsDeviceManager(this) { SynchronizeWithVerticalRetrace = true, GraphicsProfile = GraphicsProfile.HiDef,
|
||||
PreferredDepthStencilFormat = DepthFormat.Depth24Stencil8 }; // Stencil: Schatten im Duell
|
||||
SetMode(AppSettings.Fullscreen);
|
||||
IsFixedTimeStep = false;
|
||||
ApplyFrameLimit(apply: false);
|
||||
IsMouseVisible = true;
|
||||
Window.Title = L.t("app.title");
|
||||
Window.AllowUserResizing = true;
|
||||
@@ -86,6 +90,23 @@ namespace GladiatorIdle
|
||||
}
|
||||
}
|
||||
|
||||
/// Bildrate nach Einstellung: VSync, feste 120 Bilder/s oder unbegrenzt (Testläufe: immer VSync).
|
||||
void ApplyFrameLimit(bool apply = true)
|
||||
{
|
||||
int mode = DevShot.Active ? 0 : AppSettings.FrameLimit;
|
||||
_gdm.SynchronizeWithVerticalRetrace = mode == 0;
|
||||
IsFixedTimeStep = mode == 1;
|
||||
if (mode == 1) TargetElapsedTime = TimeSpan.FromSeconds(1 / 120.0);
|
||||
if (apply) _gdm.ApplyChanges();
|
||||
}
|
||||
|
||||
readonly Gfx.PostFx _post = new();
|
||||
object? _shown; // zuletzt gezeigter Bildschirm (für das Überblenden)
|
||||
double _fadeIn = 1; // 0 → 1 nach einem Wechsel
|
||||
|
||||
/// Spielstand sofort sichern (Absturz-Behandlung); Testläufe speichern ohnehin nie.
|
||||
public void SaveNow() => _game?.Save();
|
||||
|
||||
void ToggleFullscreen()
|
||||
{
|
||||
AppSettings.Fullscreen = !AppSettings.Fullscreen;
|
||||
@@ -111,7 +132,12 @@ namespace GladiatorIdle
|
||||
_sb = new SpriteBatch(GraphicsDevice);
|
||||
_fx = new BasicEffect(GraphicsDevice) { TextureEnabled = true, VertexColorEnabled = true, LightingEnabled = false, World = Matrix.Identity };
|
||||
Assets.Init(GraphicsDevice);
|
||||
_settings = new SettingsOverlay(ToggleFullscreen);
|
||||
_settings = new SettingsOverlay(ToggleFullscreen)
|
||||
{
|
||||
ApplyGraphics = () => ApplyFrameLimit(),
|
||||
Tutorial = () => _game == null ? null : _game.TutorialDone,
|
||||
ReplayTutorial = () => { if (_game != null) { _game.TutorialDone = false; _game.Save(); } }
|
||||
};
|
||||
Window.TextInput += (_, e) => { if (!_settings.Open) _creator?.OnText(e.Character, e.Key); };
|
||||
// eigener Spielstand fürs neue Spiel; vorhandenen laden und Abwesenheit nachrechnen
|
||||
GameState.SaveFile = "arena.json";
|
||||
@@ -119,8 +145,8 @@ namespace GladiatorIdle
|
||||
if (!DevShot.Active && GameState.Load(out var savedUtc) is GameState loaded)
|
||||
{
|
||||
_game = loaded;
|
||||
_game.ManualFights = true;
|
||||
_game.ApplyOffline((DateTime.UtcNow - savedUtc).TotalSeconds);
|
||||
var away = _game.ApplyOffline((DateTime.UtcNow - savedUtc).TotalSeconds);
|
||||
if (away.Seconds >= 120) _welcome = away; // im Hub als erstes Fenster
|
||||
ToMenu();
|
||||
}
|
||||
else if (!DevShot.Active) { _introThenCreate = true; _intro = new IntroScene(); } // erster Start: Intro
|
||||
@@ -156,7 +182,10 @@ namespace GladiatorIdle
|
||||
}
|
||||
// --sim H: weiter vorn einsteigen (Testläufe, Ausprobieren späterer Arenen)
|
||||
if (Array.IndexOf(Environment.GetCommandLineArgs(), "--sim") >= 0) Playtest.Advance(_game, DevShot.SimHours);
|
||||
_game.ManualFights = true;
|
||||
// --duelarena N: gleich in Arena N (Kulisse prüfen)
|
||||
var cmd = Environment.GetCommandLineArgs();
|
||||
int da = Array.IndexOf(cmd, "--duelarena");
|
||||
if (da >= 0 && da + 1 < cmd.Length && int.TryParse(cmd[da + 1], out int arenaN)) _game.DevArena(arenaN);
|
||||
_game.Save();
|
||||
_creator = null;
|
||||
var sw = Stopwatch.StartNew();
|
||||
@@ -183,7 +212,6 @@ namespace GladiatorIdle
|
||||
_offer = null;
|
||||
_enemy = GameState.LegendEnemy(l);
|
||||
_before = _hub!.Snapshot();
|
||||
_game!.BeginDuel();
|
||||
_scene = new DuelScene(_game, _enemy, _seed++);
|
||||
if (DevShot.Active) _scene.Bot = new DuelBot(0.8, new Random(3));
|
||||
DevShot.Log($"legend duel vs #{l.Number} {l.Name} ratio={_game.DuelRatio(_enemy):0.00}");
|
||||
@@ -195,10 +223,11 @@ namespace GladiatorIdle
|
||||
_offer = o;
|
||||
_enemy = o.Enemy;
|
||||
_before = _hub!.Snapshot();
|
||||
_game!.BeginDuel();
|
||||
var sw = Stopwatch.StartNew();
|
||||
_scene = new DuelScene(_game, _enemy, _seed++);
|
||||
DevShot.Log($"timing: duel created in {sw.ElapsedMilliseconds} ms");
|
||||
// erster Kampf eines neuen Profils: Einführung (in Testläufen nur mit --tutorial)
|
||||
if (!_game.TutorialDone && o.Kind != OfferKind.Champion && (!DevShot.Active || DevTutorialRun)) _scene.StartTutorial();
|
||||
if (DevShot.Active) _scene.Bot = new DuelBot(0.8, new Random(3));
|
||||
DevShot.Log($"duel vs {_enemy.NameKey} ({o.Kind}) arena={_game.Arena} rank={_game.Rank} ratio={_game.DuelRatio(_enemy):0.00}");
|
||||
}
|
||||
@@ -207,6 +236,7 @@ namespace GladiatorIdle
|
||||
void EndDuel()
|
||||
{
|
||||
bool won = _scene!.Won;
|
||||
if (_scene.TutorialRan) _game!.TutorialDone = true;
|
||||
if (_legend is Legend l)
|
||||
{
|
||||
bool first = _game!.ResolveLegendDuel(l, won);
|
||||
@@ -227,6 +257,26 @@ namespace GladiatorIdle
|
||||
_game.Save();
|
||||
}
|
||||
|
||||
// Speichern bald nach einem Klick außerhalb des Kampfs (Kauf, Anlegen, Lernen, Opfern, Expedition,
|
||||
// Entscheidung …): gebündelt, höchstens alle 2 s. Testläufe speichern nie (GameState.Save).
|
||||
double _saveSoon = -1, _clock, _lastSave = -9;
|
||||
void SaveSoon(float dt)
|
||||
{
|
||||
_clock += dt;
|
||||
if (_game == null || _creator != null) return;
|
||||
if (_scene == null && _input.LeftClick) _saveSoon = 0.6;
|
||||
if (_saveSoon < 0 || (_saveSoon -= dt) > 0) return;
|
||||
if (_clock - _lastSave < 2) { _saveSoon = 0.3; return; }
|
||||
_game.Save(); _lastSave = _clock; _saveSoon = -1;
|
||||
}
|
||||
|
||||
/// Fenster verliert den Fokus (Alt+Tab, minimiert): sofort speichern.
|
||||
protected override void OnDeactivated(object sender, EventArgs args)
|
||||
{
|
||||
if (_game != null && _creator == null) { _game.Save(); _lastSave = _clock; }
|
||||
base.OnDeactivated(sender, args);
|
||||
}
|
||||
|
||||
readonly Stopwatch _updWatch = new();
|
||||
double _updMs;
|
||||
|
||||
@@ -245,12 +295,16 @@ namespace GladiatorIdle
|
||||
_input.PrevKeys = _input.Keys; _input.PrevMouse = _input.Mouse;
|
||||
_input.Keys = Keyboard.GetState();
|
||||
_input.Mouse = IsActive ? Mouse.GetState() : default;
|
||||
_input.PrevPad = _input.Pad;
|
||||
_input.Pad = IsActive ? GamePad.GetState(PlayerIndex.One) : default;
|
||||
_input.DetectDevice();
|
||||
var ui = UiMatrix(out _, out _);
|
||||
Window.Title = L.t("app.title");
|
||||
|
||||
// Einstellungen liegen über allem und nehmen die Eingaben
|
||||
var input = _input;
|
||||
if (_settings.Open) { _settings.Update(_input, ui); input = _noInput; }
|
||||
SaveSoon(dt);
|
||||
if (DevShot.Active) DevMenu(dt);
|
||||
|
||||
if (_model != null)
|
||||
@@ -293,7 +347,7 @@ namespace GladiatorIdle
|
||||
_menu.Update(dt, input, ui, _settings.Open);
|
||||
switch (_menu.Picked)
|
||||
{
|
||||
case MenuScene.Choice.Continue when _game != null: _menu = null; _hub = new HubScene(_game); break;
|
||||
case MenuScene.Choice.Continue when _game != null: _menu = null; _hub = new HubScene(_game) { Welcome = _welcome }; _welcome = null; break;
|
||||
case MenuScene.Choice.New: _menu = null; _creator = new CreatorScene(DevShot.Active ? DevShot.Name : L.t("gladiator.defaultname")); break;
|
||||
case MenuScene.Choice.Intro: _menu = null; _intro = new IntroScene(); break;
|
||||
case MenuScene.Choice.Leaderboard:
|
||||
@@ -329,7 +383,7 @@ namespace GladiatorIdle
|
||||
{
|
||||
if ((_saveIn -= dt) <= 0) { _saveIn = 30; _game!.Save(); }
|
||||
if (!IsActive && !DevShot.Active && !_scene.Over) _scene.Paused = true; // Fenster verlassen: Pause
|
||||
if (input.Pressed(Keys.Escape) && !_scene.Over) _scene.Paused = !_scene.Paused;
|
||||
if ((input.Pressed(Keys.Escape) || input.PadPressed(Buttons.Start)) && !_scene.Over) _scene.Paused = !_scene.Paused;
|
||||
if (_scene.Paused && input.Pressed(Keys.X)) _scene.GiveUp();
|
||||
_game!.Tick(dt); // Training läuft auch im Kampf weiter
|
||||
_scene.Update(dt, input);
|
||||
@@ -388,6 +442,17 @@ namespace GladiatorIdle
|
||||
if (m.Model == null) { DevShot.Log("model3d: no model"); Exit(); return; }
|
||||
if (_capture != null) return;
|
||||
var clips = m.Model.Clips;
|
||||
// --clip=<name>: 8 Bilder über eine Bewegung verteilt (Seitenansicht), mit Treffermoment im Protokoll
|
||||
var only = Array.Find(Environment.GetCommandLineArgs(), a => a.StartsWith("--clip="))?.Substring(7);
|
||||
int ci = only == null ? -1 : clips.FindIndex(c => c.Name == only);
|
||||
if (ci >= 0)
|
||||
{
|
||||
float impact = m.Model.ImpactTime(clips[ci]);
|
||||
if (_mStep >= 9) { DevShot.Log($"model3d clip {only}: length {clips[ci].Length:0.00} impact {impact:0.00}"); Exit(); return; }
|
||||
if (!_mArmed) { m.Paused = true; m.SetView(2); m.Color = -1; m.Play(ci); m.Time = _mStep == 8 ? impact : clips[ci].Length * _mStep / 7f; _mArmed = true; _mWait = 0.35; return; }
|
||||
if ((_mWait -= dt) > 0) return;
|
||||
_capture = $"clip_{_mStep}"; _mStep++; _mArmed = false; return;
|
||||
}
|
||||
if (_mStep >= 3 + clips.Count)
|
||||
{
|
||||
DevShot.Log($"model3d: {clips.Count} clips, {m.Model.BoneCount} bones, {m.Model.Vertices.Length} vertices, {m.Model.Indices.Length / 3} triangles, draw {_drawMs / Math.Max(1, _frames):0.00} ms/frame");
|
||||
@@ -424,17 +489,24 @@ namespace GladiatorIdle
|
||||
if (DevFreedomRun && _game!.Legends.Count == 0 && _devTime > 0.5) { _game.DevFreedom(); return; }
|
||||
if (DevFreedomRun && _game!.Legends.Count > 0 && !_shots.Contains("m_end"))
|
||||
{
|
||||
if (_devTime > 0.8 && !_shots.Contains("h_hall_open")) { _shots.Add("h_hall_open"); _hub!.DevOpen(5); }
|
||||
if (_devTime > 0.8 && !_shots.Contains("h_hall_open")) { _shots.Add("h_hall_open"); _hub!.DevOpen("hall"); }
|
||||
if (_devTime > 1.5) Shot("h_hall");
|
||||
if (_devTime > 1.8 && _capture == null && _shots.Contains("h_hall")) { _hub!.DevOpen(0); _hub.ChosenLegend = _game.Legends[0]; _devTime = 0; }
|
||||
if (_devTime > 1.8 && _capture == null && _shots.Contains("h_hall")) { _hub!.DevOpen("none"); _hub.ChosenLegend = _game.Legends[0]; _devTime = 0; }
|
||||
return;
|
||||
}
|
||||
if (Array.IndexOf(Environment.GetCommandLineArgs(), "--welcome") >= 0)
|
||||
{
|
||||
if (_devTime > 0.5 && !_shots.Contains("w_set")) { _shots.Add("w_set"); _hub!.Welcome = new OfflineReport(3 * 3600 + 1240, 1840, 96, 0, 0, 7); }
|
||||
if (_devTime > 1.2) Shot("w_welcome");
|
||||
if (_devTime > 1.6 && _capture == null && _shots.Contains("w_welcome")) Exit();
|
||||
return;
|
||||
}
|
||||
if (DevAdventureRun)
|
||||
{
|
||||
// Expeditionen: Auswahl, unterwegs, Rückkehr-Bericht; dann ein Ereignis mit Entscheidung
|
||||
if (_devTime > 0.8 && !_shots.Contains("x_open")) { _shots.Add("x_open"); _hub!.DevOpen(6); }
|
||||
if (_devTime > 0.8 && !_shots.Contains("x_open")) { _shots.Add("x_open"); _hub!.DevOpen("expedition"); }
|
||||
if (_devTime > 1.6) Shot("x_regions");
|
||||
if (_devTime > 1.9 && !_shots.Contains("x_go")) { _shots.Add("x_go"); _hub!.DevOpen(0); _game!.StartExpedition("gallia", 1); }
|
||||
if (_devTime > 1.9 && !_shots.Contains("x_go")) { _shots.Add("x_go"); _hub!.DevOpen("none"); _game!.StartExpedition("gallia", 1); }
|
||||
if (_devTime > 2.6) Shot("x_away");
|
||||
if (_devTime > 2.9 && !_shots.Contains("x_back")) { _shots.Add("x_back"); _game!.Tick(Adventures.Durations[1] + 1); }
|
||||
if (_devTime > 3.6) Shot("x_report");
|
||||
@@ -452,26 +524,26 @@ namespace GladiatorIdle
|
||||
if (!_shots.Contains("m_end"))
|
||||
{
|
||||
if (_devTime > 1.0) Shot("h_hub");
|
||||
if (_devTime > 1.5 && !_shots.Contains("h_pick")) { _shots.Add("h_pick"); _hub!.DevOpen(1); }
|
||||
if (_devTime > 1.5 && !_shots.Contains("h_pick")) { _shots.Add("h_pick"); _hub!.DevOpen("gladiator"); }
|
||||
if (_devTime > 2.2) Shot("h_gladiator");
|
||||
if (_devTime > 2.6 && !_shots.Contains("h_ludus_open")) { _shots.Add("h_ludus_open"); _hub!.DevOpen(2); }
|
||||
if (_devTime > 2.6 && !_shots.Contains("h_ludus_open")) { _shots.Add("h_ludus_open"); _hub!.DevOpen("ludus"); }
|
||||
if (_devTime > 3.3) Shot("h_ludus");
|
||||
if (_devTime > 3.5 && !_shots.Contains("h_forum_open")) { _shots.Add("h_forum_open"); _hub!.DevOpen(3); }
|
||||
if (_devTime > 3.5 && !_shots.Contains("h_forum_open")) { _shots.Add("h_forum_open"); _hub!.DevOpen("gladiator"); }
|
||||
if (_devTime > 4.2) Shot("h_forum");
|
||||
if (_devTime > 4.4 && !_shots.Contains("h_skills_open")) { _shots.Add("h_skills_open"); _hub!.DevOpen(4); }
|
||||
if (_devTime > 4.4 && !_shots.Contains("h_skills_open")) { _shots.Add("h_skills_open"); _hub!.DevOpen("skills"); }
|
||||
if (_devTime > 5.1) Shot("h_skills");
|
||||
if (_devTime > 5.3 && !_shots.Contains("h_hall_tab")) { _shots.Add("h_hall_tab"); _hub!.DevOpen(5); }
|
||||
if (_devTime > 5.3 && !_shots.Contains("h_hall_tab")) { _shots.Add("h_hall_tab"); _hub!.DevOpen("hall"); }
|
||||
if (_devTime > 6.0) Shot("h_hall2");
|
||||
if (_devTime > 6.2 && !_shots.Contains("h_exp_tab")) { _shots.Add("h_exp_tab"); _hub!.DevOpen(6); }
|
||||
if (_devTime > 6.2 && !_shots.Contains("h_exp_tab")) { _shots.Add("h_exp_tab"); _hub!.DevOpen("expedition"); }
|
||||
if (_devTime > 6.9) Shot("h_exp");
|
||||
if (_devTime > 7.3 && _capture == null) { _hub!.DevOpen(0); var offers = _game!.Offers(); _hub.Chosen = offers[Math.Min(1, offers.Count - 1)]; _devTime = 0; }
|
||||
if (_devTime > 7.3 && _capture == null) { _hub!.DevOpen("none"); var offers = _game!.Offers(); _hub.Chosen = offers[Math.Min(1, offers.Count - 1)]; _devTime = 0; }
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_devTime > 0.6) Shot("h_result");
|
||||
if (_devTime > 0.8 && !_shots.Contains("h_inv_open")) { _shots.Add("h_inv_open"); _hub!.DevOpen(1); }
|
||||
if (_devTime > 0.8 && !_shots.Contains("h_inv_open")) { _shots.Add("h_inv_open"); _hub!.DevOpen("gladiator"); }
|
||||
if (_devTime > 1.4) Shot("h_inventory");
|
||||
if (_devTime > 1.6 && !_shots.Contains("h_pause_open")) { _shots.Add("h_pause_open"); _hub!.DevOpen(0); _paused = true; }
|
||||
if (_devTime > 1.6 && !_shots.Contains("h_pause_open")) { _shots.Add("h_pause_open"); _hub!.DevOpen("none"); _paused = true; }
|
||||
if (_devTime > 2.0) Shot("h_pause");
|
||||
if (_shots.Contains("h_pause") && _capture == null && _devTime > 2.2)
|
||||
{
|
||||
@@ -515,6 +587,7 @@ namespace GladiatorIdle
|
||||
if (Perf) { PerfStep(); return; }
|
||||
void Shot(string name) { if (_shots.Add(name)) _capture = name; }
|
||||
if (_scene.InIntro) { if (_devTime > 2.5) Shot("m_champintro"); return; }
|
||||
if (_scene.Tutorial != DuelScene.TutStep.Off) { Shot("t_" + _scene.Tutorial.ToString().ToLowerInvariant()); }
|
||||
if (_devTime > 0.5) Shot("m_countdown");
|
||||
if (d.Time > 0.6) Shot("m_fight");
|
||||
if (d.Enemy.State == DuelState.Windup && d.Enemy.StateTime > d.Enemy.Windup * 0.6) Shot("m_telegraph");
|
||||
@@ -545,15 +618,23 @@ namespace GladiatorIdle
|
||||
static readonly bool Record = Array.IndexOf(Environment.GetCommandLineArgs(), "--record") >= 0;
|
||||
readonly System.Collections.Generic.List<double> _times = new();
|
||||
|
||||
int _gcStart = -1, _duelsStarted;
|
||||
void PerfStep()
|
||||
{
|
||||
if (_devTime > 3) _times.Add(_lastFrameMs);
|
||||
if (_scene!.Over) { var o = _offer!; EndDuel(); StartDuel(o); }
|
||||
if (_devTime > 3)
|
||||
{
|
||||
if (_gcStart < 0) { _gcStart = GC.CollectionCount(0); _duelDraw = 0; _duelFrames = 0; }
|
||||
_times.Add(_lastFrameMs);
|
||||
}
|
||||
// nach jedem Kampf sofort ein neuer: misst auch den Ruckler beim Duellstart
|
||||
if (_scene!.Over) { var o = _offer!; EndDuel(); StartDuel(o); _duelsStarted++; }
|
||||
if (_devTime < 18) return;
|
||||
_times.Sort();
|
||||
double avg = 0; foreach (var t in _times) avg += t; avg /= Math.Max(1, _times.Count);
|
||||
DevShot.Log($"perf {GraphicsDevice.PresentationParameters.BackBufferWidth}x{GraphicsDevice.PresentationParameters.BackBufferHeight}: " +
|
||||
$"avg {avg:0.0} ms ({1000 / avg:0} fps), p95 {_times[(int)(_times.Count * 0.95)]:0.0} ms, frames {_times.Count}");
|
||||
$"avg {avg:0.0} ms ({1000 / avg:0} fps), p95 {_times[(int)(_times.Count * 0.95)]:0.0} ms, p99 {_times[(int)(_times.Count * 0.99)]:0.0} ms, " +
|
||||
$"max {_times[^1]:0.0} ms, draw {_duelDraw / Math.Max(1, _duelFrames):0.00} ms, gc0 {GC.CollectionCount(0) - _gcStart}, " +
|
||||
$"duels restarted {_duelsStarted}, frames {_times.Count}");
|
||||
Exit();
|
||||
}
|
||||
|
||||
@@ -571,9 +652,10 @@ namespace GladiatorIdle
|
||||
if (toTarget && (_rt == null || _rt.Width != w || _rt.Height != h))
|
||||
{
|
||||
_rt?.Dispose();
|
||||
_rt = new RenderTarget2D(gd, w, h, false, SurfaceFormat.Color, DepthFormat.Depth24);
|
||||
_rt = new RenderTarget2D(gd, w, h, false, SurfaceFormat.Color, DepthFormat.Depth24Stencil8);
|
||||
}
|
||||
if (toTarget) gd.SetRenderTarget(_rt);
|
||||
// Bild entsteht in einer Zwischenfläche (Kantenglättung), danach Nachleuchten
|
||||
_post.Begin(gd, w, h, AppSettings.AntiAlias);
|
||||
gd.Clear(Color.Black);
|
||||
float scale = Math.Min(w / Camera.W, h / Camera.H);
|
||||
var offset = new Vector2((w - Camera.W * scale) / 2, (h - Camera.H * scale) / 2);
|
||||
@@ -591,8 +673,21 @@ namespace GladiatorIdle
|
||||
_hub.Draw(gd, _sb, _fx, scale, offset);
|
||||
if (_paused && !_settings.Open) DrawPause(_sb, ui);
|
||||
}
|
||||
// weicher Wechsel zwischen Bildschirmen: neues Bild kommt kurz aus dem Schwarz
|
||||
object? now = (object?)_model ?? _freedom ?? (object?)_board ?? _intro ?? (object?)_menu ?? _creator ?? (object?)_scene ?? _hub;
|
||||
if (!ReferenceEquals(now, _shown)) { _shown = now; _fadeIn = 0; }
|
||||
_fadeIn = Math.Min(1, _fadeIn + gameTime.ElapsedGameTime.TotalSeconds / 0.3);
|
||||
if (_fadeIn < 1)
|
||||
{
|
||||
_sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, ui);
|
||||
Gfx.Draw.Rect(_sb, new Gfx.RectangleF(0, 0, Camera.W, Camera.H), Color.Black * (float)(1 - _fadeIn * _fadeIn * (3 - 2 * _fadeIn)));
|
||||
_sb.End();
|
||||
}
|
||||
if (_settings.Open) _settings.Draw(_sb, scale, offset);
|
||||
|
||||
bool bloomOn = AppSettings.Bloom && !AppSettings.ReduceMotion && _intro == null;
|
||||
_post.End(gd, _sb, toTarget ? _rt : null, bloomOn ? 1f : 0f);
|
||||
|
||||
if (toTarget)
|
||||
{
|
||||
gd.SetRenderTarget(null);
|
||||
|
||||
@@ -101,6 +101,43 @@ namespace GladiatorIdle.Gfx
|
||||
return result;
|
||||
}
|
||||
|
||||
// ── Mipmaps: verkleinerte Stufen für Texturen, die schräg oder weit weg zu sehen sind
|
||||
// (Sand, Mauer, Publikum, Figuren) – sonst flimmern sie in der Tiefe ──
|
||||
static readonly Dictionary<Texture2D, Texture2D> _mipped = new();
|
||||
|
||||
/// Dieselbe Textur mit allen Mipmap-Stufen (einmal je Quelle).
|
||||
public static Texture2D Mipmapped(Texture2D src)
|
||||
{
|
||||
if (src.LevelCount > 1) return src;
|
||||
if (_mipped.TryGetValue(src, out var t)) return t;
|
||||
var data = new Color[src.Width * src.Height];
|
||||
src.GetData(data);
|
||||
return _mipped[src] = MipTexture(data, src.Width, src.Height);
|
||||
}
|
||||
|
||||
/// Textur aus Pixeln mit Mipmap-Stufen (2×2-Mittel je Stufe).
|
||||
public static Texture2D MipTexture(Color[] data, int w, int h)
|
||||
{
|
||||
var t = new Texture2D(_gd, w, h, true, SurfaceFormat.Color);
|
||||
t.SetData(0, null, data, 0, data.Length);
|
||||
var cur = data; int cw = w, ch = h;
|
||||
for (int level = 1; level < t.LevelCount; level++)
|
||||
{
|
||||
int nw = Math.Max(1, cw / 2), nh = Math.Max(1, ch / 2);
|
||||
var next = new Color[nw * nh];
|
||||
for (int y = 0; y < nh; y++)
|
||||
for (int x = 0; x < nw; x++)
|
||||
{
|
||||
int x0 = Math.Min(cw - 1, x * 2), x1 = Math.Min(cw - 1, x * 2 + 1), y0 = Math.Min(ch - 1, y * 2), y1 = Math.Min(ch - 1, y * 2 + 1);
|
||||
var a = cur[y0 * cw + x0]; var b = cur[y0 * cw + x1]; var c = cur[y1 * cw + x0]; var d = cur[y1 * cw + x1];
|
||||
next[y * nw + x] = new Color((a.R + b.R + c.R + d.R + 2) / 4, (a.G + b.G + c.G + d.G + 2) / 4, (a.B + b.B + c.B + d.B + 2) / 4, (a.A + b.A + c.A + d.A + 2) / 4);
|
||||
}
|
||||
t.SetData(level, null, next, 0, next.Length);
|
||||
cur = next; cw = nw; ch = nh;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
/// Bild eines Video-Sprites: Farbe vor Schwarz (JPEG, also schon vormultipliziert)
|
||||
/// plus Deckkraft (Graustufen-PNG) — zusammengesetzt zu einer Textur.
|
||||
public static Texture2D? LoadFrame(string relBase)
|
||||
@@ -160,8 +197,8 @@ namespace GladiatorIdle.Gfx
|
||||
var data = new Color[src.Width * src.Height];
|
||||
src.GetData(data);
|
||||
PaintPixels(data, colorIndex);
|
||||
t = new Texture2D(_gd, src.Width, src.Height);
|
||||
t.SetData(data);
|
||||
if (src.LevelCount > 1) t = MipTexture(data, src.Width, src.Height); // Figuren: Stufen behalten
|
||||
else { t = new Texture2D(_gd, src.Width, src.Height); t.SetData(data); }
|
||||
_painted[(src, colorIndex)] = t;
|
||||
return t;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
@@ -67,10 +68,33 @@ namespace GladiatorIdle.Gfx
|
||||
|
||||
public static Model3D? Load(string name) => Load(Assets.Device, name);
|
||||
|
||||
// Vorlagen je Datei: einmal gelesen, danach teilt jede Figur Gitter, Gewichte, Clips und Textur
|
||||
// und hat nur eigene Haltung, eigene Puffer und eigene Waffen (Duellstart ohne Plattenzugriff).
|
||||
static readonly Dictionary<string, Model3D?> _templates = new();
|
||||
|
||||
public static Model3D? Load(GraphicsDevice gd, string name)
|
||||
{
|
||||
string? path = Assets.RootDir is string root ? Path.Combine(root, "Models", name + ".gim") : null;
|
||||
return path != null && File.Exists(path) ? new Model3D(gd, path) : null;
|
||||
if (!_templates.TryGetValue(name, out var t))
|
||||
{
|
||||
string? path = Assets.RootDir is string root ? Path.Combine(root, "Models", name + ".gim") : null;
|
||||
_templates[name] = t = path != null && File.Exists(path) ? new Model3D(gd, path) : null;
|
||||
}
|
||||
return t == null ? null : new Model3D(t);
|
||||
}
|
||||
|
||||
/// Neue Figur auf den geteilten Daten einer Vorlage.
|
||||
Model3D(Model3D src)
|
||||
{
|
||||
_names = src._names; _parent = src._parent; _rest = src._rest; _offset = src._offset;
|
||||
_pos = src._pos; _nrm = src._nrm; _baseCol = src._baseCol; _bi = src._bi; _bw = src._bw;
|
||||
Indices = src.Indices;
|
||||
Clips = src.Clips;
|
||||
Vertices = (VertexPNCT[])src.Vertices.Clone();
|
||||
Bounds = src.Bounds;
|
||||
_texture = src._texture;
|
||||
Unit = src.Unit;
|
||||
_pose = (float[])_rest.Clone(); _from = (float[])_rest.Clone();
|
||||
_global = new Matrix[_names.Length]; _skin = new Matrix[_names.Length];
|
||||
}
|
||||
|
||||
Model3D(GraphicsDevice gd, string path)
|
||||
@@ -113,7 +137,7 @@ namespace GladiatorIdle.Gfx
|
||||
Clips.Add(clip);
|
||||
}
|
||||
if (v2 && r.ReadInt32() is int texLen && texLen > 0)
|
||||
using (var ms = new MemoryStream(r.ReadBytes(texLen))) _texture = Texture2D.FromStream(gd, ms);
|
||||
using (var ms = new MemoryStream(r.ReadBytes(texLen))) _texture = Assets.Mipmapped(Texture2D.FromStream(gd, ms)); // Stufen: kein Flimmern klein/weit weg
|
||||
Vertices = new VertexPNCT[nv];
|
||||
for (int i = 0; i < nv; i++) Vertices[i] = new VertexPNCT { Position = _pos[i], Normal = _nrm[i], Color = _baseCol[i], Uv = uv[i] };
|
||||
Bounds = BoundingBox.CreateFromPoints(_pos);
|
||||
@@ -157,9 +181,7 @@ namespace GladiatorIdle.Gfx
|
||||
nr = gray + (nr - gray) * boost; ng = gray + (ng - gray) * boost; nb = gray + (nb - gray) * boost;
|
||||
data[i] = new Color(Math.Clamp(nr, 0, 1), Math.Clamp(ng, 0, 1), Math.Clamp(nb, 0, 1), c.A / 255f);
|
||||
}
|
||||
var t = new Texture2D(_texture.GraphicsDevice, _texture.Width, _texture.Height);
|
||||
t.SetData(data);
|
||||
_texture = t;
|
||||
_texture = Assets.MipTexture(data, _texture.Width, _texture.Height);
|
||||
_color = -2; // Teamfarbe neu auf die geänderte Textur
|
||||
}
|
||||
|
||||
@@ -225,17 +247,39 @@ namespace GladiatorIdle.Gfx
|
||||
var keep = (float[])_pose.Clone(); bool posed = _posed;
|
||||
int hand = Bone("RightHand");
|
||||
float best = float.MinValue; t = clip.Length * 0.5f;
|
||||
// Zweihand-Waffe: Ausholen hinter dem Kopf, dann Schlag nach vorn – Treffer, wenn die Spitze
|
||||
// am schnellsten nach vorn schnellt (die höchste Hand wäre mitten im Ausholen).
|
||||
var weapon = _twoHand ? Props.Find(p => !p.Shield && !p.NoAvoid && p.Bone == hand) : null;
|
||||
var dirZ = new List<float>();
|
||||
for (int f = 0; f < clip.Frames && hand >= 0; f++)
|
||||
{
|
||||
_posed = true;
|
||||
Pose(clip, f / clip.Fps, false, 1, true, skin: false);
|
||||
if (weapon != null)
|
||||
{
|
||||
var m = weapon.Local * _global[hand];
|
||||
dirZ.Add(Vector3.Normalize(new Vector3(m.M11, m.M12, m.M13)).Z);
|
||||
continue;
|
||||
}
|
||||
float z = _global[hand].Translation.Z;
|
||||
if (z > best) { best = z; t = f / clip.Fps; }
|
||||
}
|
||||
if (dirZ.Count > 0)
|
||||
{
|
||||
// tiefstes Ausholen (Spitze am weitesten nach hinten), danach erster Moment mit Spitze nach vorn
|
||||
int end = Math.Max(1, (int)(dirZ.Count * 0.85f)); // Rückkehr in die Grundhaltung zählt nicht
|
||||
int back = 0;
|
||||
for (int f = 1; f < end; f++) if (dirZ[f] < dirZ[back]) back = f;
|
||||
int hit = -1;
|
||||
for (int f = back; f < end && hit < 0; f++) if (dirZ[f] > 0.6f) hit = f;
|
||||
if (hit < 0) { hit = back; for (int f = back; f < end; f++) if (dirZ[f] > dirZ[hit]) hit = f; }
|
||||
t = hit / clip.Fps;
|
||||
}
|
||||
Array.Copy(keep, _pose, keep.Length); _posed = posed; Bones();
|
||||
return _impact[clip] = t;
|
||||
}
|
||||
readonly Dictionary<Clip, float> _impact = new();
|
||||
bool _twoHand; // Waffe beidhändig (Großschwert-Bewegungen), siehe AimBlades
|
||||
|
||||
/// Figur auf 180 Einheiten Höhe, Füße auf y = 0, mittig (aus der jetzigen Haltung, robust gegen Ausreißer).
|
||||
public Matrix FitNow()
|
||||
@@ -291,12 +335,13 @@ namespace GladiatorIdle.Gfx
|
||||
DynamicVertexBuffer? _vb;
|
||||
bool _dirty;
|
||||
|
||||
public void Draw(GraphicsDevice gd, BasicEffect fx, bool aura = false)
|
||||
/// Zeichnen; <paramref name="depth"/>/<paramref name="blend"/> überschreiben die Zustände (Schatten auf dem Boden).
|
||||
public void Draw(GraphicsDevice gd, BasicEffect fx, bool aura = false, DepthStencilState? depth = null, BlendState? blend = null)
|
||||
{
|
||||
gd.DepthStencilState = aura ? DepthStencilState.None : DepthStencilState.Default;
|
||||
gd.BlendState = aura ? BlendState.Additive : BlendState.Opaque;
|
||||
gd.DepthStencilState = depth ?? (aura ? DepthStencilState.None : DepthStencilState.Default);
|
||||
gd.BlendState = blend ?? (aura ? BlendState.Additive : BlendState.Opaque);
|
||||
gd.RasterizerState = RasterizerState.CullNone;
|
||||
fx.TextureEnabled = _texture != null && !aura;
|
||||
fx.TextureEnabled = _texture != null && !aura && blend == null;
|
||||
fx.Texture = _painted ?? _texture;
|
||||
// Indizes liegen einmal auf der Grafikkarte, Punkte nur nach einer neuen Haltung neu
|
||||
if (_ib == null)
|
||||
@@ -312,7 +357,7 @@ namespace GladiatorIdle.Gfx
|
||||
foreach (var pass in fx.CurrentTechnique.Passes)
|
||||
{
|
||||
pass.Apply();
|
||||
gd.SamplerStates[0] = SamplerState.LinearClamp;
|
||||
gd.SamplerStates[0] = SamplerState.AnisotropicClamp;
|
||||
gd.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, Indices.Length / 3);
|
||||
}
|
||||
fx.TextureEnabled = false;
|
||||
@@ -390,8 +435,15 @@ namespace GladiatorIdle.Gfx
|
||||
/// Ausrüstung nach Figur: Retiarius Dreizack und Netz, sonst Gladius und Scutum.
|
||||
public void Arm(string art)
|
||||
{
|
||||
if (art.Contains("retiarius")) { AddTrident(); AddNet(); }
|
||||
else { AddSword(); AddShield(); }
|
||||
bool Is(params string[] keys) => keys.Any(k => art.Contains(k));
|
||||
if (Is("retiarius")) { AddTrident(); AddNet(); }
|
||||
else if (Is("thraex")) { AddSword(kind: "sica"); AddShield(kind: "parmula"); }
|
||||
else if (Is("hoplomachus", "eques")) { AddSpear(); AddShield(kind: "round"); }
|
||||
else if (Is("recruit")) { AddSword(kind: "rudis"); AddShield(); }
|
||||
else if (Is("slave")) AddSword(kind: "club");
|
||||
else if (Is("dimachaerus")) { AddSword(); AddSword("Left"); }
|
||||
else if (Is("brawler", "sagittarius", "essedarius", "laquearius", "doctore")) { AddSword(); AddShield(kind: "round"); }
|
||||
else { AddSword(); AddShield(); } // Murmillo, Secutor, Provocator, Prätorianer, Crupellarius, Champions
|
||||
AimBlades();
|
||||
}
|
||||
|
||||
@@ -403,9 +455,22 @@ namespace GladiatorIdle.Gfx
|
||||
{
|
||||
var clip = Find("slash") ?? (Clips.Count > 0 ? Clips[0] : null);
|
||||
if (clip == null) return;
|
||||
float t = ImpactTime(clip);
|
||||
var keep = (float[])_pose.Clone(); bool posed = _posed;
|
||||
_posed = true;
|
||||
// Zweihand-Bewegungen (Großschwert-Pack): in der Grundhaltung liegen beide Hände am Griff –
|
||||
// dann zeigt die Waffe entlang der Linie linke → rechte Hand, gemessen in der Grundhaltung.
|
||||
int rh = Bone("RightHand"), lh = Bone("LeftHand");
|
||||
bool twoHand = false;
|
||||
if (Find("idle") is { } idle && rh >= 0 && lh >= 0)
|
||||
{
|
||||
Pose(idle, 0, false, 1, true, skin: false);
|
||||
var gap = _global[rh].Translation - _global[lh].Translation;
|
||||
float fore = Vector3.Distance(_global[rh].Translation, _global[_parent[rh]].Translation);
|
||||
twoHand = gap.Length() < fore * 0.8f;
|
||||
}
|
||||
_twoHand = twoHand;
|
||||
float t = twoHand ? 0 : ImpactTime(clip);
|
||||
if (twoHand) clip = Find("idle")!;
|
||||
Pose(clip, t, false, 1, true, skin: false);
|
||||
foreach (var p in Props)
|
||||
{
|
||||
@@ -413,9 +478,12 @@ namespace GladiatorIdle.Gfx
|
||||
var m = p.Local * _global[p.Bone];
|
||||
var dir = Vector3.Normalize(new Vector3(m.M11, m.M12, m.M13));
|
||||
var (fa, fu, fs) = ArmFrame(p.Bone);
|
||||
BladeLog = $"blade z {dir.Z:0.00} arm {Vector3.Dot(dir, fa):0.000} up {Vector3.Dot(dir, fu):0.000} side {Vector3.Dot(dir, fs):0.000}"; // i18n-ok
|
||||
BladeLog = $"blade z {dir.Z:0.00} arm {Vector3.Dot(dir, fa):0.000} up {Vector3.Dot(dir, fu):0.000} side {Vector3.Dot(dir, fs):0.000} twohand {twoHand}"; // i18n-ok
|
||||
// Ziel: Lage wie bei den Figuren mit sauberem Skelett (gemessen an vier Figuren)
|
||||
var target = Vector3.Normalize(fa * 0.31f + fu * 0.36f + fs * 0.88f);
|
||||
float mirror = _names[p.Bone].Contains("Left") ? -1 : 1; // linke Hand: gespiegelt
|
||||
var target = twoHand && p.Bone == rh
|
||||
? Vector3.Normalize(_global[rh].Translation - _global[lh].Translation)
|
||||
: Vector3.Normalize(fa * 0.31f + fu * 0.36f + fs * (0.88f * mirror));
|
||||
float cos = MathHelper.Clamp(Vector3.Dot(dir, target), -1, 1);
|
||||
if (cos < 0.97f)
|
||||
{
|
||||
@@ -509,22 +577,73 @@ namespace GladiatorIdle.Gfx
|
||||
}
|
||||
|
||||
/// Gladius in der Faust (Knochen-Präfix "Right"/"Left"). Klinge zeigt vom kleinen Finger zum Zeigefinger.
|
||||
public void AddSword(string side = "Right")
|
||||
public void AddSword(string side = "Right", string kind = "gladius")
|
||||
{
|
||||
var b = new MeshBuilder();
|
||||
var steel = new Color(196, 200, 206); var brass = new Color(176, 136, 62); var wood = new Color(92, 58, 34);
|
||||
b.Box(new Vector3(-9, 0, 0), new Vector3(1.5f, 3.6f, 3.6f), brass); // Knauf
|
||||
b.Box(new Vector3(-3.5f, 0, 0), new Vector3(10, 3, 3), wood); // Griff
|
||||
b.Box(new Vector3(2.2f, 0, 0), new Vector3(1.6f, 4, 11), brass); // Parierstange
|
||||
b.Box(new Vector3(30, 0, 0), new Vector3(54, 0.8f, 5.2f), steel); // Klinge
|
||||
b.Box(new Vector3(60, 0, 0), new Vector3(6, 0.7f, 2.6f), steel); // Spitze
|
||||
var lightWood = new Color(150, 112, 70);
|
||||
float length = 63;
|
||||
switch (kind)
|
||||
{
|
||||
case "rudis": // Holzschwert der Rekruten
|
||||
b.Box(new Vector3(-3.5f, 0, 0), new Vector3(10, 3, 3), wood);
|
||||
b.Box(new Vector3(2, 0, 0), new Vector3(2, 3.6f, 8), wood);
|
||||
b.Box(new Vector3(28, 0, 0), new Vector3(50, 1.6f, 4.6f), lightWood);
|
||||
b.Box(new Vector3(55, 0, 0), new Vector3(4, 1.4f, 3), lightWood);
|
||||
length = 57; break;
|
||||
case "sica": // gebogenes Kurzschwert der Thraker: Klinge biegt zur Schneide hin
|
||||
{
|
||||
b.Box(new Vector3(-9, 0, 0), new Vector3(1.5f, 3.6f, 3.6f), brass);
|
||||
b.Box(new Vector3(-3.5f, 0, 0), new Vector3(10, 3, 3), wood);
|
||||
b.Box(new Vector3(2, 0, 0), new Vector3(1.6f, 4, 8), brass);
|
||||
var at = new Vector3(3, 0, 0); float angle = 0;
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
float seg = i < 4 ? 11 : 9, width = i < 4 ? 4.6f : 3;
|
||||
var dir = new Vector3(MathF.Cos(angle), 0, -MathF.Sin(angle));
|
||||
b.Box(at + dir * seg / 2, new Vector3(seg + 0.6f, 0.8f, width), steel, Matrix.CreateRotationY(angle));
|
||||
at += dir * seg;
|
||||
angle += MathHelper.ToRadians(11);
|
||||
}
|
||||
length = 50; break;
|
||||
}
|
||||
case "club": // Knüppel: dicker werdendes Holz
|
||||
b.Box(new Vector3(-3, 0, 0), new Vector3(12, 3.2f, 3.2f), wood);
|
||||
for (int i = 0; i < 4; i++)
|
||||
b.Box(new Vector3(8 + i * 11, 0, 0), new Vector3(11.5f, 4 + i * 1.3f, 4 + i * 1.3f), i % 2 == 0 ? wood : lightWood);
|
||||
length = 50; break;
|
||||
default: // Gladius
|
||||
b.Box(new Vector3(-9, 0, 0), new Vector3(1.5f, 3.6f, 3.6f), brass);
|
||||
b.Box(new Vector3(-3.5f, 0, 0), new Vector3(10, 3, 3), wood);
|
||||
b.Box(new Vector3(2.2f, 0, 0), new Vector3(1.6f, 4, 11), brass);
|
||||
b.Box(new Vector3(30, 0, 0), new Vector3(54, 0.8f, 5.2f), steel);
|
||||
b.Box(new Vector3(60, 0, 0), new Vector3(6, 0.7f, 2.6f), steel);
|
||||
break;
|
||||
}
|
||||
var sword = b.Build(Bone(side + "Hand"), Grip(side));
|
||||
sword.Length = 63;
|
||||
sword.Length = length;
|
||||
Props.Add(sword);
|
||||
}
|
||||
|
||||
/// Speer (Hasta) der Hoplomachi und Equites, in der Mitte gefasst: Blattspitze nach vorn.
|
||||
public void AddSpear(string side = "Right")
|
||||
{
|
||||
var b = new MeshBuilder();
|
||||
var wood = new Color(118, 82, 48); var bronze = new Color(184, 140, 70); var steel = new Color(200, 204, 210);
|
||||
b.Box(new Vector3(25, 0, 0), new Vector3(170, 2.4f, 2.4f), wood); // Schaft (-60 … +110)
|
||||
b.Box(new Vector3(-61, 0, 0), new Vector3(4, 3, 3), bronze); // Schuh
|
||||
b.Box(new Vector3(111, 0, 0), new Vector3(5, 3.2f, 3.2f), bronze); // Tülle
|
||||
// Blatt: zwei schräge Hälften bilden die Raute
|
||||
b.Box(new Vector3(121, 0, 1.3f), new Vector3(16, 0.8f, 2.6f), steel, Matrix.CreateRotationY(MathHelper.ToRadians(-9)));
|
||||
b.Box(new Vector3(121, 0, -1.3f), new Vector3(16, 0.8f, 2.6f), steel, Matrix.CreateRotationY(MathHelper.ToRadians(9)));
|
||||
b.Box(new Vector3(131, 0, 0), new Vector3(7, 0.7f, 1.6f), steel);
|
||||
var p = b.Build(Bone(side + "Hand"), Grip(side));
|
||||
p.Length = 134;
|
||||
Props.Add(p);
|
||||
}
|
||||
|
||||
/// Gewölbter Schild (Scutum) am Unterarm, Bemalung in Magenta (Teamfarbe), Bronzerand und Buckel.
|
||||
public void AddShield(string side = "Left")
|
||||
public void AddShield(string side = "Left", string kind = "scutum")
|
||||
{
|
||||
var fa = BindPos(side + "ForeArm"); var h = BindPos(side + "Hand");
|
||||
var m = BindPos(side + "HandMiddle1"); var ix = BindPos(side + "HandIndex1"); var pk = BindPos(side + "HandPinky1"); var th = BindPos(side + "HandThumb1");
|
||||
@@ -538,11 +657,23 @@ namespace GladiatorIdle.Gfx
|
||||
var centre = m + knuckles * 7 * Unit;
|
||||
var b = new MeshBuilder();
|
||||
var face = new Color(190, 30, 160); var rim = new Color(150, 112, 52); var boss = new Color(182, 150, 80);
|
||||
const float W = 50, H = 72, BEND = 0.011f;
|
||||
// x: Länge (entlang des Arms), y: Breite, z: nach außen (weg vom Arm), gewölbt um die Längsachse
|
||||
b.Curved(W, H, BEND, face, 1.2f);
|
||||
b.Rim(W, H, BEND, rim);
|
||||
b.Dome(new Vector3(0, 0, 2.5f), 9, 5, boss);
|
||||
float W = 50, H = 72, BEND = 0.011f;
|
||||
if (kind == "round")
|
||||
{
|
||||
// Rundschild (Parma): flach gewölbte Scheibe mit Rand und Buckel
|
||||
W = H = 60; BEND = 0.006f;
|
||||
b.Disc(30, BEND, face, 1.2f);
|
||||
b.Ring(30, BEND, rim);
|
||||
b.Dome(new Vector3(0, 0, 1.5f), 8, 5, boss);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (kind == "parmula") { W = 40; H = 48; BEND = 0.02f; } // kleiner Schild der Thraker
|
||||
// x: Länge (entlang des Arms), y: Breite, z: nach außen (weg vom Arm), gewölbt um die Längsachse
|
||||
b.Curved(W, H, BEND, face, 1.2f);
|
||||
b.Rim(W, H, BEND, rim);
|
||||
b.Dome(new Vector3(0, 0, 2.5f), kind == "parmula" ? 6 : 9, kind == "parmula" ? 4 : 5, boss);
|
||||
}
|
||||
// x (Höhe) = Griff (senkrecht gehalten, wie die Mixamo-Schildbewegungen es erwarten),
|
||||
// y (Breite) = Knöchel × Griff, z (außen) = x × y = Knöchelrichtung
|
||||
var shield = b.Build(Bone(side + "Hand"), Matrix.CreateScale(Unit) * Attach(Bone(side + "Hand"), across, Vector3.Cross(knuckles, across), centre));
|
||||
@@ -710,10 +841,11 @@ namespace GladiatorIdle.Gfx
|
||||
_i.AddRange(new[] { o, o + 1, o + 2, o, o + 2, o + 3 });
|
||||
}
|
||||
|
||||
public void Box(Vector3 c, Vector3 s, Color col)
|
||||
public void Box(Vector3 c, Vector3 s, Color col, Matrix? rot = null)
|
||||
{
|
||||
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 r = rot ?? Matrix.Identity;
|
||||
Vector3 P(float x, float y, float z) => c + Vector3.TransformNormal(new Vector3(x * h.X, y * h.Y, z * h.Z), r);
|
||||
Quad(P(-1, -1, 1), P(1, -1, 1), P(1, 1, 1), P(-1, 1, 1), col);
|
||||
Quad(P(1, -1, -1), P(-1, -1, -1), P(-1, 1, -1), P(1, 1, -1), col);
|
||||
Quad(P(-1, 1, -1), P(-1, 1, 1), P(1, 1, 1), P(1, 1, -1), col);
|
||||
@@ -772,6 +904,34 @@ namespace GladiatorIdle.Gfx
|
||||
}
|
||||
}
|
||||
|
||||
/// Runde, leicht gewölbte Scheibe (Rundschild), Vorder- und Rückseite.
|
||||
public void Disc(float r, float bend, Color col, float thick)
|
||||
{
|
||||
const int SEG = 28, RINGS = 4;
|
||||
var back = new Color(110, 78, 46);
|
||||
Vector3 S(float rad, float a, float off) => new(MathF.Cos(a) * rad, MathF.Sin(a) * rad, -bend * rad * rad + off);
|
||||
for (int side = 0; side < 2; side++)
|
||||
for (int k = 0; k < RINGS; k++)
|
||||
for (int i = 0; i < SEG; i++)
|
||||
{
|
||||
float r0 = r * k / RINGS, r1 = r * (k + 1) / RINGS, a0 = MathF.Tau * i / SEG, a1 = MathF.Tau * (i + 1) / SEG;
|
||||
float off = side == 0 ? 0 : -thick;
|
||||
Quad(S(r0, a0, off), S(r1, a0, off), S(r1, a1, off), S(r0, a1, off), side == 0 ? col : back);
|
||||
}
|
||||
}
|
||||
|
||||
/// Rand eines Rundschilds aus kurzen, gedrehten Stücken.
|
||||
public void Ring(float r, float bend, Color col)
|
||||
{
|
||||
const int SEG = 20;
|
||||
for (int i = 0; i < SEG; i++)
|
||||
{
|
||||
float a = MathF.Tau * (i + 0.5f) / SEG;
|
||||
var c = new Vector3(MathF.Cos(a) * r, MathF.Sin(a) * r, -bend * r * r + 0.6f);
|
||||
Box(c, new Vector3(3, MathF.Tau * r / SEG + 0.4f, 3), col, Matrix.CreateRotationZ(a));
|
||||
}
|
||||
}
|
||||
|
||||
public Prop Build(int bone, Matrix local)
|
||||
{
|
||||
var v = _v.ToArray();
|
||||
|
||||
84
Mono/Gfx/PostFx.cs
Normal file
84
Mono/Gfx/PostFx.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace GladiatorIdle.Gfx
|
||||
{
|
||||
/// <summary>
|
||||
/// Nachbearbeitung ohne eigene Shader: das Bild entsteht in einer Zwischenfläche (mit
|
||||
/// Kantenglättung/MSAA), danach Nachleuchten (Bloom) aus SpriteBatch und Mischmodi:
|
||||
/// verkleinern, dunkle Anteile abziehen (helle bleiben übrig), in drei Stufen weich
|
||||
/// verkleinern und additiv über das Bild legen.
|
||||
/// </summary>
|
||||
internal sealed class PostFx
|
||||
{
|
||||
RenderTarget2D? _scene, _a, _b, _c;
|
||||
int _msaa = -1;
|
||||
|
||||
// dunkle Anteile abziehen: Ziel = Ziel − Quelle
|
||||
static readonly BlendState Subtract = new()
|
||||
{
|
||||
ColorBlendFunction = BlendFunction.ReverseSubtract, ColorSourceBlend = Blend.One, ColorDestinationBlend = Blend.One,
|
||||
AlphaBlendFunction = BlendFunction.Add, AlphaSourceBlend = Blend.Zero, AlphaDestinationBlend = Blend.One,
|
||||
};
|
||||
|
||||
static RenderTarget2D Make(GraphicsDevice gd, int w, int h, int msaa, DepthFormat depth) =>
|
||||
new(gd, Math.Max(1, w), Math.Max(1, h), false, SurfaceFormat.Color, depth, msaa, RenderTargetUsage.PreserveContents);
|
||||
|
||||
/// Zeichnen in die Zwischenfläche beginnen (Größe wie der Bildschirm).
|
||||
public void Begin(GraphicsDevice gd, int w, int h, bool antiAlias)
|
||||
{
|
||||
int msaa = antiAlias ? 4 : 0;
|
||||
if (_scene == null || _scene.Width != w || _scene.Height != h || _msaa != msaa)
|
||||
{
|
||||
_scene?.Dispose(); _a?.Dispose(); _b?.Dispose(); _c?.Dispose();
|
||||
_scene = Make(gd, w, h, msaa, DepthFormat.Depth24Stencil8);
|
||||
_a = Make(gd, w / 4, h / 4, 0, DepthFormat.None);
|
||||
_b = Make(gd, w / 8, h / 8, 0, DepthFormat.None);
|
||||
_c = Make(gd, w / 16, h / 16, 0, DepthFormat.None);
|
||||
_msaa = msaa;
|
||||
}
|
||||
gd.SetRenderTarget(_scene);
|
||||
}
|
||||
|
||||
/// Fertiges Bild nach <paramref name="output"/> (null = Bildschirm), mit Nachleuchten der Stärke <paramref name="bloom"/>.
|
||||
public void End(GraphicsDevice gd, SpriteBatch sb, RenderTarget2D? output, float bloom, float threshold = 0.76f)
|
||||
{
|
||||
if (_scene == null) return;
|
||||
if (bloom > 0)
|
||||
{
|
||||
// ¼: verkleinern, dann Schwelle abziehen (nur Helles bleibt)
|
||||
Blit(gd, sb, _scene, _a!, BlendState.Opaque, Color.White);
|
||||
sb.Begin(SpriteSortMode.Immediate, Subtract);
|
||||
sb.Draw(Assets.Pixel, new Rectangle(0, 0, _a!.Width, _a.Height), new Color(threshold, threshold, threshold, 0f));
|
||||
sb.End();
|
||||
// ⅛ und 1/16: weiter verkleinern = weicher
|
||||
Blit(gd, sb, _a, _b!, BlendState.Opaque, Color.White);
|
||||
Blit(gd, sb, _b!, _c!, BlendState.Opaque, Color.White);
|
||||
}
|
||||
gd.SetRenderTarget(output);
|
||||
int w = output?.Width ?? gd.PresentationParameters.BackBufferWidth, h = output?.Height ?? gd.PresentationParameters.BackBufferHeight;
|
||||
sb.Begin(SpriteSortMode.Immediate, BlendState.Opaque, SamplerState.PointClamp);
|
||||
sb.Draw(_scene, new Rectangle(0, 0, w, h), Color.White);
|
||||
sb.End();
|
||||
if (bloom > 0)
|
||||
{
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp);
|
||||
var full = new Rectangle(0, 0, w, h);
|
||||
sb.Draw(_a, full, Color.White * (0.30f * bloom));
|
||||
sb.Draw(_b, full, Color.White * (0.45f * bloom));
|
||||
sb.Draw(_c, full, Color.White * (0.60f * bloom));
|
||||
sb.End();
|
||||
}
|
||||
}
|
||||
|
||||
static void Blit(GraphicsDevice gd, SpriteBatch sb, Texture2D from, RenderTarget2D to, BlendState blend, Color c)
|
||||
{
|
||||
gd.SetRenderTarget(to);
|
||||
gd.Clear(Color.Black);
|
||||
sb.Begin(SpriteSortMode.Immediate, blend, SamplerState.LinearClamp);
|
||||
sb.Draw(from, new Rectangle(0, 0, to.Width, to.Height), c);
|
||||
sb.End();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -61,7 +61,10 @@ namespace GladiatorIdle.Gfx
|
||||
D.Rect(sb, r, fill * 0.95f);
|
||||
D.Rect(sb, new RectangleF(r.X + 2, r.Y + 2, r.Width - 4, (r.Height - 4) * 0.45f), Color.White * (hover ? 0.08f : 0.04f));
|
||||
D.Frame(sb, r, !enabled ? new Color(60, 48, 36) : selected || hover ? a : D.Border, selected ? 3 : 2);
|
||||
D.Text(sb, Assets.SansBold, size, text, r.Center, !enabled ? D.Dim : selected ? Color.White : D.Sand, Align.Center);
|
||||
// Beschriftung passt sich an (längere Texte in anderen Sprachen): verkleinern bis sie in den Knopf passt
|
||||
float fit = size, room = r.Width - 18;
|
||||
while (fit > 11 && D.Measure(Assets.SansBold, fit, text).X > room) fit -= 1;
|
||||
D.Text(sb, Assets.SansBold, fit, text, r.Center, !enabled ? D.Dim : selected ? Color.White : D.Sand, Align.Center);
|
||||
return enabled && Hit(r);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,46 @@ namespace GladiatorIdle
|
||||
if (DevShot.Active) SoundManager.Enabled = false; // Testläufe stumm
|
||||
if (DevShot.Playtest) { Playtest.Run(); return; }
|
||||
|
||||
using var game = new ArenaGame();
|
||||
game.Run();
|
||||
SoundManager.StopAll();
|
||||
SoundManager.Shutdown();
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => CrashLog(e.ExceptionObject as Exception);
|
||||
try
|
||||
{
|
||||
using var game = new ArenaGame();
|
||||
_game = game;
|
||||
game.Run();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
CrashLog(ex);
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
SoundManager.StopAll();
|
||||
SoundManager.Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
static ArenaGame? _game;
|
||||
static bool _crashed;
|
||||
|
||||
/// Absturz: erst den Spielstand sichern, dann die Ursache nach %AppData%\GladiatorIdle\crash.log
|
||||
/// (die neueste oben). Testläufe schreiben ins Protokoll des Laufs.
|
||||
static void CrashLog(Exception? ex)
|
||||
{
|
||||
if (_crashed) return;
|
||||
_crashed = true;
|
||||
try { _game?.SaveNow(); } catch { /* Spielstand nicht sicherbar */ }
|
||||
try
|
||||
{
|
||||
string text = $"=== {DateTime.Now:yyyy-MM-dd HH:mm:ss} {typeof(Program).Assembly.GetName().Version}\n{ex}\n\n";
|
||||
if (DevShot.Active) { DevShot.Log("CRASH " + ex); return; }
|
||||
string dir = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "GladiatorIdle");
|
||||
System.IO.Directory.CreateDirectory(dir);
|
||||
string file = System.IO.Path.Combine(dir, "crash.log");
|
||||
string old = System.IO.File.Exists(file) ? System.IO.File.ReadAllText(file) : "";
|
||||
System.IO.File.WriteAllText(file, text + (old.Length > 200_000 ? old[..200_000] : old));
|
||||
}
|
||||
catch { /* nichts mehr zu tun */ }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user