Files
GladiatorIdle/Mono/Arena/HubScene.Hall.cs
2026-11-08 13:29:26 +01:00

74 lines
4.3 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
using System.Linq;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// Ehrenhalle: alle freigelassenen Gladiatoren (Legenden), jede im Duell herausforderbar — der
/// erste Sieg über jede bringt Gunst der Götter. Darunter die Götter, denen die Gunst geopfert wird.
internal sealed partial class HubScene
{
int _hallPage;
const int HALL_ROWS = 4;
/// Gewählte Legende (Duell beginnt) — von außen abgeholt.
public Legend? ChosenLegend { get; set; }
void DrawHall(SpriteBatch sb, RectangleF r)
{
float x = r.X + 30, w = r.Width - 60, y = r.Y + 40;
D.Text(sb, Assets.Serif, 34, L.t("hall.title"), new Vector2(x, y), D.Gold);
D.Text(sb, Assets.SansBold, 22, string.Format(L.t("gods.favor"), _game.GodFavor), new Vector2(x + w, y), D.Purple, Align.Right);
D.TextWrap(sb, Assets.Sans, 17, string.Format(L.t("hall.intro"), GameState.LEGEND_FAVOR), new RectangleF(x, y + 26, w, 40), D.Sand);
var list = _game.Legends.AsEnumerable().Reverse().ToList(); // neueste zuerst
int pages = Math.Max(1, (list.Count + HALL_ROWS - 1) / HALL_ROWS);
_hallPage = Math.Clamp(_hallPage, 0, pages - 1);
float ly = y + 80, rowH = 92;
if (list.Count == 0)
D.Text(sb, Assets.Sans, 20, L.t("hall.empty"), new Vector2(r.Center.X, ly + 150), D.Dim, Align.Center);
foreach (var l in list.Skip(_hallPage * HALL_ROWS).Take(HALL_ROWS))
{
var row = new RectangleF(x, ly, w, rowH - 10);
bool beaten = _game.LegendsBeaten.Contains(l.Number);
D.Rect(sb, row, new Color(30, 22, 15) * 0.9f);
D.Frame(sb, row, beaten ? D.Border : D.Purple, 2);
D.Text(sb, Assets.Serif, 24, $"#{l.Number} {l.Name}", new Vector2(row.X + 20, row.Y + 22), D.Gold); // i18n-ok
D.Text(sb, Assets.Sans, 16, $"{L.t(ClassDef.Of(l.Class).Key)} · {string.Format(L.t("ludus.level"), l.Level)} · {l.DateUtc.ToLocalTime():d}", // i18n-ok
new Vector2(row.X + 20, row.Y + 48), D.Sand);
D.Text(sb, Assets.Sans, 15, L.t(beaten ? "hall.beaten" : "hall.unbeaten"), new Vector2(row.X + 20, row.Y + 68), beaten ? D.Green : D.Purple);
double ratio = _game.DuelRatio(GameState.LegendEnemy(l));
float sx = row.X + 470;
void Stat(int i, string label, string value, Color c)
{
D.Text(sb, Assets.Sans, 14, label, new Vector2(sx + i * 150 + 70, row.Y + 24), D.Dim, Align.Center);
D.Text(sb, Assets.SansBold, 20, value, new Vector2(sx + i * 150 + 70, row.Y + 52), c, Align.Center);
}
Stat(0, L.t("freedom.wins"), NumberFormat.Format(l.Wins), D.Sand);
Stat(1, L.t("hall.time"), NumberFormat.Duration(l.RunSeconds), D.Sand);
Stat(2, L.t("hall.power"), NumberFormat.Format(l.Power), ratio >= 1 ? D.Green : ratio >= 0.75 ? D.Gold : D.Red);
var lg = l;
if (_ui.Button(sb, new RectangleF(row.Right - 210, row.Y + 14, 190, 54), L.t("hall.challenge"), _game.CanFight || _game.FreedomEarned,
selected: !beaten, size: 19))
{ ChosenLegend = lg; _drawer = Drawer.None; }
ly += rowH;
}
if (pages > 1)
{
float by = y + 80 + HALL_ROWS * rowH;
if (_ui.Button(sb, new RectangleF(r.Center.X - 160, by, 70, 40), "‹", _hallPage > 0, size: 24)) _hallPage--; // i18n-ok
D.Text(sb, Assets.Sans, 18, $"{_hallPage + 1} / {pages}", new Vector2(r.Center.X, by + 20), D.Sand, Align.Center); // i18n-ok
if (_ui.Button(sb, new RectangleF(r.Center.X + 90, by, 70, 40), "›", _hallPage < pages - 1, size: 24)) _hallPage++; // i18n-ok
}
// Götter: Gunst opfern (wirkt auf alle Gladiatoren)
float gy = r.Bottom - 2 * 168 - 26 - 30;
D.Text(sb, Assets.Serif, 26, L.t("freedom.gods"), new Vector2(x, gy - 26), D.Gold);
FreedomScene.GodCards(sb, _ui, _game, new Vector2(r.Center.X, gy), (w - 60) / 3, 168);
}
}
}