Bestenliste, Expeditionen, Ereignisse, Dreizack und Netz, aufrechte Schilde, dunkle Haut
Stand von main 82292b5c. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,11 +25,13 @@ namespace GladiatorIdle.Arena
|
||||
void InitModel(int color)
|
||||
{
|
||||
_model = Model3D.Load(_art);
|
||||
bool own = _model != null;
|
||||
foreach (var alt in Fallbacks(_art)) _model ??= Model3D.Load(alt);
|
||||
_model ??= Model3D.Load(DefaultModel);
|
||||
// Vorlage mit dunkler Haut, aber noch ohne eigenes Modell: Haut des Ersatzmodells abdunkeln
|
||||
if (!own && _model != null && DarkSkin.Contains(_art)) _model.SetSkin(1);
|
||||
if (_model == null || _model.Clips.Count == 0) { _model = null; return; }
|
||||
_model.AddSword();
|
||||
_model.AddShield();
|
||||
_model.Arm(_art);
|
||||
_model.SetColor(color);
|
||||
var idle = Clip3("idle");
|
||||
_model.Pose(idle, 0, true);
|
||||
@@ -49,6 +51,10 @@ namespace GladiatorIdle.Arena
|
||||
_mfx.SpecularPower = 24;
|
||||
}
|
||||
|
||||
/// Aussehen-Vorlagen mit dunkler Haut (Bilder hero_<klasse>_2).
|
||||
static readonly System.Collections.Generic.HashSet<string> DarkSkin = new()
|
||||
{ "hero_murmillo_2", "hero_secutor_2", "hero_thraex_2", "hero_retiarius_2" };
|
||||
|
||||
/// Figuren ohne eigenes Modell: eine ähnliche vorhandene (in eigener Teamfarbe), bis es eines gibt.
|
||||
static System.Collections.Generic.IEnumerable<string> Fallbacks(string art)
|
||||
{
|
||||
|
||||
204
Mono/Arena/HubScene.Adventure.cs
Normal file
204
Mono/Arena/HubScene.Adventure.cs
Normal file
@@ -0,0 +1,204 @@
|
||||
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
|
||||
{
|
||||
/// Expeditionen (Schublade: Regionen, Dauer, Aufbruch; unterwegs: Fortschritt statt Gegnerwahl),
|
||||
/// Rückkehr-Bericht und Ereignis-Karten mit Entscheidungen (beides als Fenster über dem Hub),
|
||||
/// dazu die laufenden Segen unter der Kopfleiste.
|
||||
internal sealed partial class HubScene
|
||||
{
|
||||
string _expRegion = "gallia";
|
||||
int _expDuration;
|
||||
string? _eventShown; // Ereignis, dessen Karte offen ist
|
||||
string? _eventOutcome; // Text-Key des Ausgangs, nach der Entscheidung
|
||||
string? _eventSeen; // für den Klang beim Erscheinen
|
||||
|
||||
static string DurationLabel(int i) => NumberFormat.Duration(Adventures.Durations[i]);
|
||||
static int LootCount(int duration) => 1 + 2 * duration;
|
||||
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;
|
||||
|
||||
void UpdateAdventure()
|
||||
{
|
||||
if (_game.PendingEvent is string id && _eventSeen != id) { _eventSeen = id; SoundManager.PlayChapterSting(); }
|
||||
}
|
||||
|
||||
Texture2D? Picture(string art) => Assets.Sprite(art, "jpg");
|
||||
|
||||
static void DrawPicture(SpriteBatch sb, Texture2D? tex, RectangleF r, float alpha = 1)
|
||||
{
|
||||
if (tex == null) { D.Rect(sb, r, new Color(30, 22, 15)); return; }
|
||||
// "cover": Bild füllt das Rechteck, mittig beschnitten
|
||||
float k = MathF.Max(r.Width / tex.Width, r.Height / tex.Height);
|
||||
int sw = (int)(r.Width / k), sh = (int)(r.Height / k);
|
||||
var src = new Rectangle((tex.Width - sw) / 2, (tex.Height - sh) / 2, sw, sh);
|
||||
sb.Draw(tex, new Rectangle((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height), src, Color.White * alpha);
|
||||
}
|
||||
|
||||
// ── Schublade: Regionen und Aufbruch ────────────────────────
|
||||
|
||||
void DrawExpeditions(SpriteBatch sb, RectangleF r)
|
||||
{
|
||||
float x = r.X + 30, w = r.Width - 60, y = r.Y + 40;
|
||||
D.Text(sb, Assets.Serif, 34, L.t("exp.title"), new Vector2(x, y), D.Gold);
|
||||
D.TextWrap(sb, Assets.Sans, 17, L.t("exp.intro"), new RectangleF(x, y + 26, w, 44), D.Sand);
|
||||
if (_game.Away == null && !_game.RegionOpen(RegionDef.Get(_expRegion)))
|
||||
_expRegion = RegionDef.All.Last(reg => _game.RegionOpen(reg)).Id;
|
||||
|
||||
const float GX = 20, GY = 18;
|
||||
float cw = (w - 2 * GX) / 3, ch = 250, y0 = y + 84;
|
||||
for (int i = 0; i < RegionDef.All.Length; i++)
|
||||
{
|
||||
var reg = RegionDef.All[i];
|
||||
var cr = new RectangleF(x + i % 3 * (cw + GX), y0 + i / 3 * (ch + GY), cw, ch);
|
||||
bool open = _game.RegionOpen(reg), sel = reg.Id == (_game.Away?.Region ?? _expRegion);
|
||||
D.Rect(sb, cr, new Color(24, 18, 12) * 0.95f);
|
||||
DrawPicture(sb, Picture(reg.Art), new RectangleF(cr.X + 5, cr.Y + 5, cr.Width - 10, ch - 80), open ? 1 : 0.3f);
|
||||
D.Text(sb, Assets.Serif, 22, L.t(reg.Key).ToUpperInvariant(), new Vector2(cr.X + 14, cr.Bottom - 54), open ? D.Gold : D.Dim);
|
||||
string info = open ? string.Format(L.t("exp.chance"), NumberFormat.Percent(_game.ExpeditionChance(reg)))
|
||||
: string.Format(L.t("exp.locked"), L.t(ArenaDef.All[reg.Unlock].Key));
|
||||
D.Text(sb, Assets.Sans, 16, info, new Vector2(cr.X + 14, cr.Bottom - 24), open ? ChanceColor(_game.ExpeditionChance(reg)) : D.Dim);
|
||||
D.Frame(sb, cr, sel ? D.Gold : D.Border, sel ? 4 : 2);
|
||||
if (open && _game.Away == null && _ui.Hover(cr) && _ui.Hit(cr)) { _expRegion = reg.Id; SoundManager.PlayClick(); }
|
||||
}
|
||||
|
||||
float by = y0 + 2 * (ch + GY) + 10;
|
||||
if (_game.Away is { } a) { DrawAwayStatus(sb, new RectangleF(x, by, w, 80), a); return; }
|
||||
float bw = 240;
|
||||
for (int d = 0; d < 3; d++)
|
||||
if (_ui.Button(sb, new RectangleF(x + d * (bw + 12), by + 6, bw, 60), string.Format(L.t("exp.duration"), DurationLabel(d), LootCount(d)),
|
||||
selected: _expDuration == d, size: 18))
|
||||
_expDuration = d;
|
||||
if (_ui.Button(sb, new RectangleF(x + w - 300, by + 6, 300, 60), L.t("exp.start"),
|
||||
_game.RegionOpen(RegionDef.Get(_expRegion)) && !_game.FreedomEarned, selected: true, size: 24, accent: D.Gold))
|
||||
if (_game.StartExpedition(_expRegion, _expDuration)) { SoundManager.PlayStart(); _drawer = Drawer.None; }
|
||||
}
|
||||
|
||||
void DrawAwayStatus(SpriteBatch sb, RectangleF r, Expedition a)
|
||||
{
|
||||
var reg = RegionDef.Get(a.Region);
|
||||
double total = Adventures.Durations[a.Duration];
|
||||
float bw = r.Width - 380;
|
||||
D.Text(sb, Assets.SansBold, 22, string.Format(L.t("exp.away"), L.t(reg.Key)), new Vector2(r.X, r.Y + 14), D.Gold);
|
||||
D.Text(sb, Assets.Sans, 18, string.Format(L.t("exp.left"), NumberFormat.Duration(a.Left)), new Vector2(r.X, r.Y + 44), D.Sand);
|
||||
D.Bar(sb, new RectangleF(r.X, r.Y + 64, bw, 14), (float)(1 - a.Left / total), (float)(1 - a.Left / total), D.Gold);
|
||||
if (_ui.Button(sb, new RectangleF(r.Right - 340, r.Y + 10, 340, 60), L.t("exp.recall"), size: 18, accent: D.Red))
|
||||
{ _game.Recall(); SoundManager.PlayBoo(); }
|
||||
}
|
||||
|
||||
/// Statt der Gegnerwahl, solange der Gladiator unterwegs ist: Bild der Region und Fortschritt.
|
||||
void DrawAwayCard(SpriteBatch sb, Expedition a)
|
||||
{
|
||||
var reg = RegionDef.Get(a.Region);
|
||||
var r = new RectangleF(Camera.W - 860, 150, 820, 640);
|
||||
Ui.Panel(sb, r, D.Gold, 0.92f);
|
||||
DrawPicture(sb, Picture(reg.Art), new RectangleF(r.X + 20, r.Y + 20, r.Width - 40, 430));
|
||||
DrawAwayStatus(sb, new RectangleF(r.X + 30, r.Y + 470, r.Width - 60, 90), a);
|
||||
}
|
||||
|
||||
// ── Segen ───────────────────────────────────────────────────
|
||||
|
||||
void DrawBuffs(SpriteBatch sb)
|
||||
{
|
||||
float y = 136;
|
||||
foreach (var b in _game.Buffs)
|
||||
{
|
||||
string text = string.Format(L.t("buff." + b.Kind.ToString().ToLowerInvariant()), NumberFormat.Percent(b.Mult - 1), NumberFormat.Duration(b.Left));
|
||||
D.Text(sb, Assets.SansBold, 17, text, new Vector2(40, y), D.Blue);
|
||||
y += 24;
|
||||
}
|
||||
}
|
||||
|
||||
// ── Fenster: Rückkehr-Bericht und Ereignis ──────────────────
|
||||
|
||||
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);
|
||||
else if (_eventShown != null || _game.PendingEvent != null) DrawEvent(sb);
|
||||
}
|
||||
|
||||
void DrawReport(SpriteBatch sb, ExpeditionReport rep)
|
||||
{
|
||||
var reg = RegionDef.Get(rep.Region);
|
||||
var r = new RectangleF(Camera.W / 2 - 520, 70, 1040, 940);
|
||||
Ui.Panel(sb, r, rep.Success ? D.Gold : D.Red, 0.97f);
|
||||
DrawPicture(sb, Picture(reg.Art), new RectangleF(r.X + 30, r.Y + 30, r.Width - 60, 300));
|
||||
float y = r.Y + 370;
|
||||
D.Text(sb, Assets.Serif, 36, string.Format(L.t(rep.Success ? "exp.back.ok" : "exp.back.fail"), L.t(reg.Key)),
|
||||
new Vector2(r.Center.X, y), rep.Success ? D.Gold : D.Red, Align.Center);
|
||||
y += 44;
|
||||
if (!rep.Success) { D.Text(sb, Assets.Sans, 18, L.t("exp.back.failtext"), new Vector2(r.Center.X, y), D.Sand, Align.Center); y += 34; }
|
||||
foreach (int n in rep.Log)
|
||||
{
|
||||
D.TextWrap(sb, Assets.Serif, 19, "· " + L.t("expedition.log." + n), new RectangleF(r.X + 80, y - 10, r.Width - 160, 40), D.Sand); // i18n-ok
|
||||
y += 32;
|
||||
}
|
||||
y += 14;
|
||||
void Line(string label, string value)
|
||||
{
|
||||
D.Text(sb, Assets.Sans, 20, label, new Vector2(r.X + 220, y), D.Dim);
|
||||
D.Text(sb, Assets.SansBold, 22, value, new Vector2(r.Right - 220, y), D.Sand, Align.Right);
|
||||
y += 34;
|
||||
}
|
||||
Line(L.t("exp.reward.gold"), "+" + NumberFormat.Format(rep.Gold)); // i18n-ok
|
||||
Line(L.t("exp.reward.fame"), "+" + NumberFormat.Format(rep.Fame)); // i18n-ok
|
||||
Line(L.t("exp.reward.xp"), "+" + NumberFormat.Format(rep.Xp)); // i18n-ok
|
||||
if (rep.Loot.Count > 0)
|
||||
{
|
||||
float size = 88, lx = r.Center.X - (rep.Loot.Count * (size + 12) - 12) / 2;
|
||||
for (int i = 0; i < rep.Loot.Count; i++) ItemTile(sb, new RectangleF(lx + i * (size + 12), y + 4, size, size), rep.Loot[i], false);
|
||||
}
|
||||
if (_ui.Button(sb, new RectangleF(r.Center.X - 170, r.Bottom - 80, 340, 60), L.t("exp.ok"), selected: true, size: 24))
|
||||
{ _game.DismissExpeditionResult(); SoundManager.PlayCoins(); }
|
||||
}
|
||||
|
||||
void DrawEvent(SpriteBatch sb)
|
||||
{
|
||||
_eventShown ??= _game.PendingEvent;
|
||||
var ev = Adventures.GetEvent(_eventShown!);
|
||||
var r = new RectangleF(Camera.W / 2 - 700, 110, 1400, 860);
|
||||
Ui.Panel(sb, r, D.Gold, 0.97f);
|
||||
var pic = new RectangleF(r.X + 34, r.Y + 34, 640, 360);
|
||||
DrawPicture(sb, Picture(ev.Art), pic);
|
||||
D.Frame(sb, pic, D.Border, 2);
|
||||
float tx = pic.Right + 34, tw = r.Right - 34 - tx;
|
||||
D.TextWrap(sb, Assets.Serif, 34, L.t(ev.Title), new RectangleF(tx, r.Y + 30, tw, 100), D.Gold);
|
||||
D.TextWrap(sb, Assets.Serif, 21, L.t(ev.Text), new RectangleF(tx, r.Y + 140, tw, 250), D.Sand);
|
||||
|
||||
float y = pic.Bottom + 34;
|
||||
if (_eventOutcome != null)
|
||||
{
|
||||
D.TextWrap(sb, Assets.Serif, 26, L.t(_eventOutcome), new RectangleF(r.X + 80, y + 20, r.Width - 160, 200), new Color(245, 236, 214));
|
||||
if (_ui.Button(sb, new RectangleF(r.Center.X - 170, r.Bottom - 90, 340, 62), L.t("event.ok"), selected: true, size: 24))
|
||||
{ _eventShown = null; _eventOutcome = null; SoundManager.PlayClick(); }
|
||||
return;
|
||||
}
|
||||
for (int i = 0; i < ev.Choices.Length; i++)
|
||||
{
|
||||
var c = ev.Choices[i];
|
||||
double cost = _game.ChoiceCost(c);
|
||||
string label = L.t(ev.ChoiceKey(c));
|
||||
if (cost > 0) label += " · " + string.Format(L.t("event.cost"), NumberFormat.Format(cost)); // i18n-ok
|
||||
if (c.Chance < 1) label += " · " + L.t("event.risky") + " " + NumberFormat.Percent(c.Chance); // i18n-ok
|
||||
if (_ui.Button(sb, new RectangleF(r.X + 60, y, r.Width - 120, 64), label, _game.Gold >= cost, size: 21))
|
||||
{
|
||||
var outcome = _game.Choose(i);
|
||||
if (outcome != null)
|
||||
{
|
||||
_eventOutcome = outcome;
|
||||
if (outcome.EndsWith(".fail", StringComparison.Ordinal)) SoundManager.PlayBoo(); else SoundManager.PlayGoodEvent();
|
||||
}
|
||||
}
|
||||
y += 76;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace GladiatorIdle.Arena
|
||||
/// </summary>
|
||||
internal sealed partial class HubScene
|
||||
{
|
||||
enum Drawer { None, Gladiator, Ludus, Forum, Skills, Hall }
|
||||
enum Drawer { None, Gladiator, Ludus, Forum, Skills, Hall, Expedition }
|
||||
|
||||
readonly GameState _game;
|
||||
readonly Ui _ui = new();
|
||||
@@ -72,6 +72,7 @@ namespace GladiatorIdle.Arena
|
||||
_ui.Begin(input, ui);
|
||||
_game.Tick(dt); // Training, Einnahmen, Erholung
|
||||
_hero.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion);
|
||||
UpdateAdventure();
|
||||
_crowd.Update(dt);
|
||||
_fx.Motes(AppSettings.ReduceMotion ? 0 : 50, Camera.W, Camera.H);
|
||||
_fx.Update(dt);
|
||||
@@ -136,10 +137,15 @@ namespace GladiatorIdle.Arena
|
||||
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
||||
DrawTopBar(sb);
|
||||
if (_drawerK < 0.98f) DrawOffers(sb);
|
||||
DrawDrawerButtons(sb);
|
||||
DrawToast(sb);
|
||||
if (_drawerK > 0.01f) DrawDrawer(sb);
|
||||
DrawBuffs(sb);
|
||||
if (Modal) DrawModal(sb); // Bericht oder Ereignis: darunter nichts anklickbar
|
||||
else
|
||||
{
|
||||
if (_drawerK < 0.98f) { if (_game.Away is { } away) DrawAwayCard(sb, away); else DrawOffers(sb); }
|
||||
DrawDrawerButtons(sb);
|
||||
DrawToast(sb);
|
||||
if (_drawerK > 0.01f) DrawDrawer(sb);
|
||||
}
|
||||
sb.End();
|
||||
}
|
||||
|
||||
@@ -299,6 +305,10 @@ namespace GladiatorIdle.Arena
|
||||
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;
|
||||
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;
|
||||
}
|
||||
|
||||
void DrawDrawer(SpriteBatch sb)
|
||||
@@ -311,6 +321,7 @@ namespace GladiatorIdle.Arena
|
||||
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);
|
||||
}
|
||||
|
||||
static float Ease(float k) => 1 - (1 - k) * (1 - k);
|
||||
|
||||
172
Mono/Arena/LeaderboardScene.cs
Normal file
172
Mono/Arena/LeaderboardScene.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GladiatorIdle.Gfx;
|
||||
using GladiatorIdle.Net;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using D = GladiatorIdle.Gfx.Draw;
|
||||
|
||||
namespace GladiatorIdle.Arena
|
||||
{
|
||||
/// <summary>
|
||||
/// Bestenliste (aus dem Hauptmenü): Siegertreppchen für die drei Besten, darunter die Plätze 4–15.
|
||||
/// Zwei Wertungen: stärkste Gladiatoren (beste Kampfkraft) und schnellste Freiheit. Der eigene
|
||||
/// Eintrag leuchtet; steht er nicht unter den ersten 15, erscheint er unter der Liste.
|
||||
/// </summary>
|
||||
internal sealed class LeaderboardScene
|
||||
{
|
||||
enum Tab { Power, Fastest }
|
||||
|
||||
readonly Ui _ui = new();
|
||||
readonly Particles _fx = new();
|
||||
readonly Texture2D? _backdrop = Assets.Sprite("arena_colosseum", "jpg");
|
||||
readonly string _me = Leaderboard.PlayerId;
|
||||
List<LeaderEntry>? _all;
|
||||
bool _loading = true, _offline, _dev;
|
||||
Tab _tab;
|
||||
double _t;
|
||||
|
||||
public bool Done { get; private set; }
|
||||
|
||||
public LeaderboardScene(GameState? game)
|
||||
{
|
||||
if (game != null) Leaderboard.Submit(game); // eigenen Stand zuerst aktualisieren
|
||||
Reload();
|
||||
}
|
||||
|
||||
void Reload()
|
||||
{
|
||||
_loading = true;
|
||||
_ = Leaderboard.FetchAsync().ContinueWith(t =>
|
||||
{
|
||||
if (_dev) return;
|
||||
_all = t.Result;
|
||||
_offline = _all == null;
|
||||
_loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
/// Testläufe: Beispieleinträge statt der Datenbank (sendet und lädt nichts).
|
||||
public void DevSample(GameState? game)
|
||||
{
|
||||
_dev = true;
|
||||
var rnd = new Random(5);
|
||||
string[] names = { "Spiculus", "Flamma", "Priscus", "Verus", "Carpophorus", "Tetraites", "Crixus", "Oenomaus", "Gannicus", "Varro", "Hilarus", "Celadus" };
|
||||
_all = names.Select((n, i) => new LeaderEntry("dev" + i, n, ((GladiatorClass)(i % 4)).ToString(), 70 - i * 4, Math.Round(4e9 / Math.Pow(1.9, i)),
|
||||
Math.Max(0, 6 - i / 2), 7200 + rnd.Next(9000), 7, "")).ToList();
|
||||
if (game != null) _all.Add(Leaderboard.FromGame(game) with { Id = _me });
|
||||
_loading = false; _offline = false;
|
||||
}
|
||||
|
||||
public void Update(float dt, Input input, Matrix ui)
|
||||
{
|
||||
_t += dt;
|
||||
_ui.Begin(input, ui);
|
||||
_fx.Motes(AppSettings.ReduceMotion ? 0 : 40, Camera.W, Camera.H);
|
||||
_fx.Update(dt);
|
||||
if (input.Pressed(Keys.Escape)) Done = true;
|
||||
}
|
||||
|
||||
List<LeaderEntry> Ranked() => _all == null ? new() : _tab == Tab.Power
|
||||
? _all.Where(e => e.Power > 0).OrderByDescending(e => e.Power).ThenBy(e => e.Name).ToList()
|
||||
: _all.Where(e => e.FastestFreedom > 0).OrderBy(e => e.FastestFreedom).ThenBy(e => e.Name).ToList();
|
||||
|
||||
string Value(LeaderEntry e) => _tab == Tab.Power ? NumberFormat.Format(e.Power) : NumberFormat.Duration(e.FastestFreedom);
|
||||
|
||||
string ClassName(LeaderEntry e) => Enum.TryParse<GladiatorClass>(e.Class, out var c) ? L.t(ClassDef.Of(c).Key) : e.Class;
|
||||
|
||||
// ── Zeichnen ────────────────────────────────────────────────
|
||||
|
||||
public void Draw(SpriteBatch sb, float scale, Vector2 offset)
|
||||
{
|
||||
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 (_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);
|
||||
}
|
||||
sb.End();
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);
|
||||
_fx.DrawAdd(sb);
|
||||
D.Glow(sb, new Vector2(Camera.W / 2, 120), new Vector2(1600, 400), D.Gold * 0.1f);
|
||||
sb.End();
|
||||
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
||||
D.Text(sb, Assets.Serif, 72, L.t("lb.title").ToUpperInvariant(), new Vector2(Camera.W / 2, 80), D.Gold, Align.Center);
|
||||
float tw = 360;
|
||||
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - tw - 10, 140, tw, 56), L.t("lb.tab.power"), selected: _tab == Tab.Power, size: 22)) _tab = Tab.Power;
|
||||
if (_ui.Button(sb, new RectangleF(Camera.W / 2 + 10, 140, tw, 56), L.t("lb.tab.fastest"), selected: _tab == Tab.Fastest, size: 22)) _tab = Tab.Fastest;
|
||||
|
||||
if (_loading) D.Text(sb, Assets.Serif, 30, L.t("lb.loading"), new Vector2(Camera.W / 2, 520), D.Sand, Align.Center);
|
||||
else if (_offline)
|
||||
{
|
||||
D.Text(sb, Assets.Serif, 30, L.t("lb.offline"), new Vector2(Camera.W / 2, 500), D.Red, Align.Center);
|
||||
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - 160, 560, 320, 56), L.t("lb.retry"), size: 22)) Reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
var list = Ranked();
|
||||
if (list.Count == 0) D.Text(sb, Assets.Serif, 28, L.t(_tab == Tab.Power ? "lb.empty" : "lb.empty.fastest"), new Vector2(Camera.W / 2, 520), D.Sand, Align.Center);
|
||||
else DrawRanking(sb, list);
|
||||
}
|
||||
|
||||
if (_ui.Button(sb, new RectangleF(60, Camera.H - 100, 260, 60), L.t("lb.back"), size: 22)) Done = true;
|
||||
sb.End();
|
||||
}
|
||||
|
||||
void DrawRanking(SpriteBatch sb, List<LeaderEntry> list)
|
||||
{
|
||||
// Siegertreppchen: 2 – 1 – 3
|
||||
Color[] medal = { D.Gold, new Color(205, 212, 225), new Color(205, 140, 90) };
|
||||
int[] order = { 1, 0, 2 };
|
||||
float[] heights = { 175, 215, 150 };
|
||||
for (int s = 0; s < 3; s++)
|
||||
{
|
||||
int i = order[s];
|
||||
if (i >= list.Count) continue;
|
||||
var e = list[i];
|
||||
float w = 360, x = Camera.W / 2 - 1.5f * w - 20 + s * (w + 20), h = heights[s], baseY = 480;
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
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);
|
||||
if (mine >= 15) { y += 10; Row(sb, list[mine], mine, x0, y, wAll, rowH); }
|
||||
if (mine >= 0)
|
||||
D.Text(sb, Assets.Sans, 17, string.Format(L.t("lb.yourrank"), mine + 1, list.Count), new Vector2(Camera.W - 60, Camera.H - 70), D.Purple, Align.Right);
|
||||
}
|
||||
|
||||
void Row(SpriteBatch sb, LeaderEntry e, int i, float x0, float y, float w, float h)
|
||||
{
|
||||
bool me = e.Id == _me;
|
||||
var r = new RectangleF(x0, y, w, h - 4);
|
||||
D.Rect(sb, r, (me ? new Color(60, 40, 80) : new Color(30, 22, 15)) * 0.9f);
|
||||
if (me) D.Frame(sb, r, D.Purple, 2);
|
||||
float cy = r.Center.Y;
|
||||
D.Text(sb, Assets.SansBold, 19, (i + 1).ToString(NumberFormat.Culture), new Vector2(x0 + 20, cy), D.Sand);
|
||||
D.Text(sb, Assets.SansBold, 19, me ? $"{e.Name} ({L.t("lb.you")})" : e.Name, new Vector2(x0 + 90, cy), me ? D.Purple : Color.White); // i18n-ok
|
||||
D.Text(sb, Assets.Sans, 17, $"{ClassName(e)} · {string.Format(L.t("ludus.level"), e.Level)}", new Vector2(x0 + 470, cy), D.Sand); // i18n-ok
|
||||
D.Text(sb, Assets.Sans, 17, e.Freedoms.ToString(NumberFormat.Culture), new Vector2(x0 + 760, cy), D.Sand, Align.Center);
|
||||
D.Text(sb, Assets.SansBold, 19, Value(e), new Vector2(x0 + w - 20, cy), D.Gold, Align.Right);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ namespace GladiatorIdle.Arena
|
||||
/// </summary>
|
||||
internal sealed class MenuScene
|
||||
{
|
||||
public enum Choice { None, Continue, New, Intro, Settings, Quit }
|
||||
public enum Choice { None, Continue, New, Intro, Leaderboard, Settings, Quit }
|
||||
|
||||
readonly Ui _ui = new();
|
||||
readonly Particles _fx = new();
|
||||
@@ -67,24 +67,26 @@ namespace GladiatorIdle.Arena
|
||||
D.Text(sb, Assets.Serif, 120, L.t("app.title").ToUpperInvariant(), new Vector2(Camera.W / 2, 220), D.Gold * appear, Align.Center, 1.06f - 0.06f * appear);
|
||||
D.Text(sb, Assets.Serif, 32, L.t("start.subtitle"), new Vector2(Camera.W / 2, 320), D.Sand * appear, Align.Center);
|
||||
|
||||
float w = 520, h = 74, x = (Camera.W - w) / 2, y = 430;
|
||||
float w = 520, h = 66, x = (Camera.W - w) / 2, y = 410;
|
||||
if (_hasSave && _ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.continue"), selected: true, size: 30)) Picked = Choice.Continue;
|
||||
if (_hasSave) y += h + 18;
|
||||
if (_hasSave) y += h + 14;
|
||||
string newText = _armNew > 0 ? L.t("menu.new.confirm") : L.t("menu.new");
|
||||
if (_ui.Button(sb, new RectangleF(x, y, w, h), newText, selected: !_hasSave, size: _armNew > 0 ? 18 : 28, accent: _armNew > 0 ? D.Red : null))
|
||||
{
|
||||
if (!_hasSave || _armNew > 0) Picked = Choice.New;
|
||||
else _armNew = 4; // zweiter Klick innerhalb von 4 s
|
||||
}
|
||||
y += h + 18;
|
||||
y += h + 14;
|
||||
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.intro"), size: 26)) Picked = Choice.Intro;
|
||||
y += h + 18;
|
||||
y += h + 14;
|
||||
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.leaderboard"), size: 26, accent: D.Gold)) Picked = Choice.Leaderboard;
|
||||
y += h + 14;
|
||||
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("main.settings"), size: 26)) Picked = Choice.Settings;
|
||||
y += h + 18;
|
||||
y += h + 14;
|
||||
if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("main.quit"), size: 26)) Picked = Choice.Quit;
|
||||
|
||||
if (_freedoms > 0)
|
||||
D.Text(sb, Assets.Serif, 22, string.Format(L.t("menu.freedoms"), _freedoms), new Vector2(Camera.W / 2, y + h + 50), D.Gold, Align.Center);
|
||||
D.Text(sb, Assets.Serif, 22, string.Format(L.t("menu.freedoms"), _freedoms), new Vector2(Camera.W / 2, y + h + 36), D.Gold, Align.Center);
|
||||
D.Text(sb, Assets.Sans, 16, $"{Credits.COPYRIGHT} · {Credits.DISCORD}", new Vector2(Camera.W / 2, Camera.H - 30), D.Dim, Align.Center); // i18n-ok
|
||||
sb.End();
|
||||
}
|
||||
|
||||
@@ -33,8 +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?.AddSword();
|
||||
Model?.AddShield();
|
||||
Model?.Arm(name);
|
||||
_backdrop = Assets.Sprite("arena_colosseum", "jpg");
|
||||
_fx = new BasicEffect(gd) { VertexColorEnabled = true, LightingEnabled = true, PreferPerPixelLighting = true };
|
||||
_fx.AmbientLightColor = new Vector3(0.42f, 0.38f, 0.36f);
|
||||
|
||||
Reference in New Issue
Block a user