Freiheit, Ehrenhalle, Götter, Champion-Auftritte; Waffen weichen dem Körper aus
Stand von main 0abffe17. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,7 @@ namespace GladiatorIdle.Arena
|
||||
/// </summary>
|
||||
internal sealed class DuelScene
|
||||
{
|
||||
enum Phase { Countdown, Fight, End }
|
||||
enum Phase { Intro, Countdown, Fight, End }
|
||||
|
||||
const float COUNTDOWN = 2.2f, SPREAD = 1.3f;
|
||||
|
||||
@@ -49,6 +49,9 @@ namespace GladiatorIdle.Arena
|
||||
};
|
||||
|
||||
Phase _phase = Phase.Countdown;
|
||||
readonly string? _introClip; // Auftritt des Champions (Wan-Clip), sonst gleich der Countdown
|
||||
const float INTRO = 6f;
|
||||
public bool InIntro => _phase == Phase.Intro;
|
||||
float _phaseTime, _hitstop, _slowmo, _screenFlash;
|
||||
float _furyDark, _emberIn; // Raserei: Abdunkeln der Arena, Takt der Funken
|
||||
Color _flashColor = Color.White;
|
||||
@@ -94,6 +97,16 @@ namespace GladiatorIdle.Arena
|
||||
sl[1].Learned = Duel.Perks.HeavyStrike;
|
||||
sl[2].Learned = Duel.Perks.ShieldWall;
|
||||
SoundManager.StartAmbient(enemy.IsChampion ? "music_champion" : "music_arena");
|
||||
if (enemy.IsChampion && enemy.NameKey.StartsWith("champion.")) // Geschichte, kein Effekt: auch bei "Effekte reduzieren"
|
||||
{
|
||||
string clip = "champintro_" + enemy.NameKey["champion.".Length..];
|
||||
if (Assets.RootDir is string root && System.IO.File.Exists(System.IO.Path.Combine(root, "Video", clip + "_00.jpg")))
|
||||
{
|
||||
_introClip = clip;
|
||||
ClipCache.Video(clip); // lädt im Hintergrund
|
||||
_phase = Phase.Intro;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Takt ────────────────────────────────────────────────────
|
||||
@@ -110,6 +123,13 @@ namespace GladiatorIdle.Arena
|
||||
|
||||
switch (_phase)
|
||||
{
|
||||
case Phase.Intro:
|
||||
if (_phaseTime >= INTRO || input.LeftClick || input.Pressed(Keys.Space) || input.Pressed(Keys.Enter))
|
||||
{
|
||||
_phase = Phase.Countdown; _phaseTime = 0;
|
||||
SoundManager.PlayGong();
|
||||
}
|
||||
return;
|
||||
case Phase.Countdown:
|
||||
int n = 3 - (int)(_phaseTime / (COUNTDOWN / 3));
|
||||
if (n != _countShown) { _countShown = n; if (n >= 1) SoundManager.PlayTick(); }
|
||||
@@ -334,6 +354,31 @@ namespace GladiatorIdle.Arena
|
||||
Duel.Events.Clear();
|
||||
}
|
||||
|
||||
/// Auftritt des Champions: Clip bildschirmfüllend mit Kinobalken, Name und Titel.
|
||||
void DrawIntro(SpriteBatch sb, float scale, Vector2 offset)
|
||||
{
|
||||
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
||||
float p = Math.Clamp(_phaseTime / INTRO, 0, 1);
|
||||
var frames = _introClip != null ? ClipCache.Video(_introClip) : null;
|
||||
var tex = frames != null ? frames[Math.Min(frames.Length - 1, (int)(p * (frames.Length - 1)))] : _backdrop;
|
||||
if (tex != null)
|
||||
{
|
||||
float k = (1.04f + 0.05f * p) * MathF.Max(Camera.W / tex.Width, Camera.H / tex.Height);
|
||||
float fade = Math.Clamp(_phaseTime / 0.5f, 0, 1) * Math.Clamp((INTRO - _phaseTime) / 0.4f, 0, 1);
|
||||
sb.Draw(tex, new Vector2(Camera.W / 2, Camera.H / 2), null, Color.White * fade, 0, new Vector2(tex.Width / 2f, tex.Height / 2f), k, SpriteEffects.None, 0);
|
||||
}
|
||||
float bar = Camera.H * 0.11f;
|
||||
D.Rect(sb, new RectangleF(0, 0, Camera.W, bar), Color.Black);
|
||||
D.Rect(sb, new RectangleF(0, Camera.H - bar, Camera.W, bar), Color.Black);
|
||||
float ta = Math.Clamp((_phaseTime - 0.8f) / 0.6f, 0, 1);
|
||||
D.Glow(sb, new Vector2(Camera.W / 2, Camera.H * 0.78f), new Vector2(Camera.W * 1.4f, 380), Color.Black * (0.7f * ta));
|
||||
D.Text(sb, Assets.SansBold, 26, L.t("duel.champion").ToUpperInvariant(), new Vector2(Camera.W / 2, Camera.H * 0.72f), D.Sand * ta, Align.Center);
|
||||
D.Text(sb, Assets.Serif, 96, _enemy.Name, new Vector2(Camera.W / 2, Camera.H * 0.80f), D.Gold * ta, Align.Center, 1.15f - 0.15f * ta);
|
||||
D.Text(sb, Assets.Sans, 18, L.t("freedom.skip"), new Vector2(Camera.W - 40, Camera.H - bar / 2), D.Sand * 0.6f, Align.Right);
|
||||
sb.End();
|
||||
}
|
||||
|
||||
void Float(string text, Vector2 pos, Color c, float size) =>
|
||||
_floaters.Add(new Floater { Text = text, Pos = pos, Color = c, Size = size });
|
||||
|
||||
@@ -345,6 +390,7 @@ namespace GladiatorIdle.Arena
|
||||
public void Draw(GraphicsDevice gd, SpriteBatch sb, BasicEffect fx, float scale, Vector2 offset)
|
||||
{
|
||||
D.UiScale = scale;
|
||||
if (_phase == Phase.Intro) { DrawIntro(sb, scale, offset); return; }
|
||||
var view = _cam.View(scale, offset);
|
||||
fx.View = view;
|
||||
fx.Projection = Matrix.CreateOrthographicOffCenter(0, gd.Viewport.Width, gd.Viewport.Height, 0, 0, 1);
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace GladiatorIdle.Arena
|
||||
{
|
||||
if (art.StartsWith("hero_") && art.LastIndexOf('_') is int u && u > 5) yield return art[..u] + "_1"; // Vorlage 1 der Klasse
|
||||
if (art.StartsWith("champ_")) { yield return "champ_doctore"; yield break; }
|
||||
if (art.StartsWith("fig_")) yield return "hero_" + art[4..] + "_1"; // Legenden, Klassenbild
|
||||
switch (art)
|
||||
{
|
||||
case "foe_recruit": yield return "foe_slave"; break;
|
||||
|
||||
249
Mono/Arena/FreedomScene.cs
Normal file
249
Mono/Arena/FreedomScene.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using GladiatorIdle.Gfx;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using D = GladiatorIdle.Gfx.Draw;
|
||||
|
||||
namespace GladiatorIdle.Arena
|
||||
{
|
||||
/// <summary>
|
||||
/// Die Freiheit: der Kaiser überreicht die Rudis (Wan-Clip, Erzählstimme, Musik), danach die
|
||||
/// Bilanz des Lebens mit dem jubelnden Gladiator (3D) und die Opfer an die Götter. Am Ende
|
||||
/// <see cref="Done"/>: der nächste Gladiator wird erstellt (Profil, Legenden und Götter bleiben).
|
||||
/// </summary>
|
||||
internal sealed class FreedomScene
|
||||
{
|
||||
enum Phase { Clip, Summary, Gods }
|
||||
|
||||
const float CLIP_MIN = 9;
|
||||
|
||||
readonly GameState _game;
|
||||
readonly Legend _legend;
|
||||
readonly int _favor;
|
||||
readonly Ui _ui = new();
|
||||
readonly Particles _fx = new();
|
||||
readonly Texture2D? _still = Assets.Sprite("freedom_rudis", "jpg");
|
||||
readonly FighterView _hero;
|
||||
readonly DuelFighter _dummy = new() { IsPlayer = true, Facing = 1, MaxHp = 1, Hp = 1, State = DuelState.Victory };
|
||||
readonly float _line2At, _clipTime;
|
||||
Phase _phase;
|
||||
float _t, _phaseT;
|
||||
bool _line1, _line2;
|
||||
|
||||
static bool Voiced => SoundManager.Enabled && AppSettings.Narration;
|
||||
|
||||
public bool Done { get; private set; }
|
||||
|
||||
public FreedomScene(GameState game, Legend legend, int favor)
|
||||
{
|
||||
_game = game;
|
||||
_legend = legend;
|
||||
_favor = favor;
|
||||
string hero = Art.Hero(game.Class, game.Look.Preset);
|
||||
_hero = Assets.Has(hero) ? new FighterView(hero, 0, game.Look.Color) : new FighterView(Art.Fighter(game.Class), 0, -1, game.Look.Color);
|
||||
SoundManager.PreloadVoice(new[] { "freedom.line1", "freedom.line2" });
|
||||
float v1 = Voiced ? SoundManager.VoiceSeconds("freedom.line1") : 3.5f;
|
||||
float v2 = Voiced ? SoundManager.VoiceSeconds("freedom.line2") : 3.5f;
|
||||
_line2At = 0.8f + v1 + 0.6f;
|
||||
_clipTime = MathF.Max(CLIP_MIN, _line2At + v2 + 1.2f);
|
||||
ClipCache.Video("freedom_rudis"); // Geschichte, kein Effekt: auch bei "Effekte reduzieren"
|
||||
SoundManager.StopAll();
|
||||
SoundManager.PlayMusic("music_freedom", loop: true);
|
||||
_fx.Calm = AppSettings.ReduceMotion;
|
||||
}
|
||||
|
||||
void Next(Phase p)
|
||||
{
|
||||
if (p != Phase.Clip) SoundManager.StopVoice();
|
||||
_phase = p; _phaseT = 0;
|
||||
SoundManager.PlayClick();
|
||||
if (p == Phase.Summary && !AppSettings.ReduceMotion)
|
||||
{
|
||||
// Goldregen zum Auftakt der Bilanz
|
||||
for (int i = 0; i < 6; i++)
|
||||
_fx.Sparks(new Vector2(Camera.W * (0.15f + 0.14f * i), -20), 18, D.Gold, MathF.PI / 2, 0.5f, 500);
|
||||
}
|
||||
}
|
||||
|
||||
/// Testläufe: Phase direkt setzen (0 Clip, 1 Bilanz, 2 Götter) mit Zeit in der Phase.
|
||||
public void DevShow(int phase, float time) { _phase = (Phase)phase; _phaseT = time; }
|
||||
public void DevDone() { SoundManager.StopAll(); Done = true; }
|
||||
|
||||
public void Update(float dt, Input input, Matrix ui)
|
||||
{
|
||||
_t += dt; _phaseT += dt;
|
||||
_ui.Begin(input, ui);
|
||||
_dummy.StateTime += dt;
|
||||
_hero.Update(dt, dt, _dummy, 0, AppSettings.ReduceMotion);
|
||||
_fx.Motes(AppSettings.ReduceMotion ? 0 : 40, Camera.W, Camera.H);
|
||||
_fx.Update(dt);
|
||||
if (_phase == Phase.Clip)
|
||||
{
|
||||
if (!_line1 && _phaseT >= 0.8f) { _line1 = true; if (Voiced) SoundManager.PlayVoice("freedom.line1"); }
|
||||
if (!_line2 && _phaseT >= _line2At) { _line2 = true; if (Voiced) SoundManager.PlayVoice("freedom.line2"); }
|
||||
if (_phaseT >= _clipTime || input.Pressed(Keys.Space) || input.Pressed(Keys.Enter) || input.Pressed(Keys.Escape) || input.LeftClick)
|
||||
Next(Phase.Summary);
|
||||
}
|
||||
}
|
||||
|
||||
// ── Zeichnen ────────────────────────────────────────────────
|
||||
|
||||
public void Draw(GraphicsDevice gd, SpriteBatch sb, BasicEffect fx, float scale, Vector2 offset)
|
||||
{
|
||||
D.UiScale = scale;
|
||||
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
|
||||
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)
|
||||
{
|
||||
// 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.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);
|
||||
_hero.DrawBody(gd, fx, _dummy, AppSettings.ReduceMotion);
|
||||
}
|
||||
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.Additive, SamplerState.LinearClamp, null, null, null, ui);
|
||||
_fx.DrawAdd(sb);
|
||||
sb.End();
|
||||
sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui);
|
||||
if (_phase == Phase.Clip) DrawLines(sb);
|
||||
else if (_phase == Phase.Summary) DrawSummary(sb);
|
||||
else DrawGods(sb);
|
||||
sb.End();
|
||||
}
|
||||
|
||||
void DrawClip(SpriteBatch sb)
|
||||
{
|
||||
var frames = ClipCache.Video("freedom_rudis");
|
||||
float p = Math.Clamp(_phaseT / _clipTime, 0, 1);
|
||||
var tex = frames != null ? frames[Math.Min(frames.Length - 1, (int)(p * (frames.Length - 1)))] : _still;
|
||||
if (tex == null) return;
|
||||
float k = (1.04f + 0.06f * p) * MathF.Max(Camera.W / tex.Width, Camera.H / tex.Height); // langsam heran
|
||||
sb.Draw(tex, new Vector2(Camera.W / 2, Camera.H / 2), null, Color.White * Math.Clamp(_phaseT / 0.8f, 0, 1), 0,
|
||||
new Vector2(tex.Width / 2f, tex.Height / 2f), k, SpriteEffects.None, 0);
|
||||
float bar = Camera.H * 0.1f;
|
||||
D.Rect(sb, new RectangleF(0, 0, Camera.W, bar), Color.Black);
|
||||
D.Rect(sb, new RectangleF(0, Camera.H - bar, Camera.W, bar), Color.Black);
|
||||
}
|
||||
|
||||
void DrawBackdrop(SpriteBatch sb)
|
||||
{
|
||||
if (_still != null)
|
||||
{
|
||||
float k = 1.08f * MathF.Max(Camera.W / _still.Width, Camera.H / _still.Height);
|
||||
sb.Draw(_still, new Vector2(Camera.W / 2, Camera.H / 2), null, new Color(0.32f, 0.28f, 0.24f), 0,
|
||||
new Vector2(_still.Width / 2f, _still.Height / 2f), k, SpriteEffects.None, 0);
|
||||
}
|
||||
D.Glow(sb, new Vector2(Camera.W / 2, 160), new Vector2(1800, 500), D.Gold * 0.08f);
|
||||
}
|
||||
|
||||
/// Untertitel der Erzählstimme und Hinweis zum Fortfahren.
|
||||
void DrawLines(SpriteBatch sb)
|
||||
{
|
||||
bool second = _phaseT >= _line2At;
|
||||
float start = second ? _line2At - 0.2f : 0.6f;
|
||||
float a = Math.Clamp((_phaseT - start) / 0.6f, 0, 1);
|
||||
D.Glow(sb, new Vector2(Camera.W / 2, Camera.H - 170), new Vector2(Camera.W * 1.4f, 360), Color.Black * 0.8f);
|
||||
DrawCentered(sb, L.t(second ? "freedom.line2" : "freedom.line1"), Camera.H - 175, 40, new Color(240, 214, 150) * a);
|
||||
D.Text(sb, Assets.Sans, 18, L.t("freedom.skip"), new Vector2(Camera.W - 40, Camera.H - 40), D.Sand * 0.7f, Align.Right);
|
||||
}
|
||||
|
||||
static void DrawCentered(SpriteBatch sb, string text, float y, float px, Color c)
|
||||
{
|
||||
float max = Camera.W * 0.8f;
|
||||
if (D.Measure(Assets.Serif, px, text).X <= max) { D.Text(sb, Assets.Serif, px, text, new Vector2(Camera.W / 2, y), c, Align.Center); return; }
|
||||
var words = text.Split(' ');
|
||||
int split = words.Length / 2;
|
||||
for (int i = 1; i < words.Length; i++)
|
||||
if (D.Measure(Assets.Serif, px, string.Join(' ', words[..i])).X > max * 0.55f) { split = i; break; }
|
||||
D.Text(sb, Assets.Serif, px, string.Join(' ', words[..split]), new Vector2(Camera.W / 2, y - px * 0.6f), c, Align.Center);
|
||||
D.Text(sb, Assets.Serif, px, string.Join(' ', words[split..]), new Vector2(Camera.W / 2, y + px * 0.6f), c, Align.Center);
|
||||
}
|
||||
|
||||
void DrawSummary(SpriteBatch sb)
|
||||
{
|
||||
float a = Math.Clamp(_phaseT / 0.6f, 0, 1);
|
||||
D.Text(sb, Assets.Serif, 96, L.t("freedom.title").ToUpperInvariant(), new Vector2(Camera.W / 2, 120), D.Gold * a, Align.Center, 1.2f - 0.2f * a);
|
||||
D.Text(sb, Assets.Serif, 28, string.Format(L.t("freedom.subtitle"), _legend.Name, L.t(ClassDef.Of(_legend.Class).Key)),
|
||||
new Vector2(Camera.W / 2, 200), D.Sand * a, Align.Center);
|
||||
|
||||
var box = new RectangleF(900, 270, 860, 560);
|
||||
Ui.Panel(sb, box, D.Gold, 0.92f);
|
||||
float x = box.X + 50, w = box.Width - 100, y = box.Y + 50;
|
||||
void Row(string label, string value)
|
||||
{
|
||||
D.Text(sb, Assets.Sans, 24, label, new Vector2(x, y), D.Sand);
|
||||
D.Text(sb, Assets.SansBold, 28, value, new Vector2(x + w, y), D.Gold, Align.Right);
|
||||
D.Rect(sb, new RectangleF(x, y + 26, w, 1), D.Border * 0.6f);
|
||||
y += 58;
|
||||
}
|
||||
Row(L.t("freedom.number"), "#" + _legend.Number.ToString(NumberFormat.Culture)); // i18n-ok
|
||||
Row(L.t("freedom.level"), _legend.Level.ToString(NumberFormat.Culture));
|
||||
Row(L.t("freedom.wins"), NumberFormat.Format(_legend.Wins));
|
||||
Row(L.t("freedom.fame"), NumberFormat.Format(_legend.Fame));
|
||||
Row(L.t("freedom.time"), NumberFormat.Duration(_legend.RunSeconds));
|
||||
Row(L.t("freedom.power"), NumberFormat.Format(_legend.Power));
|
||||
y += 20;
|
||||
D.Text(sb, Assets.Serif, 36, string.Format(L.t("freedom.favor"), _favor), new Vector2(x, y), D.Purple);
|
||||
D.TextWrap(sb, Assets.Sans, 19, L.t("freedom.hall"), new RectangleF(x, y + 50, w, 70), D.Dim);
|
||||
|
||||
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - 230, 900, 460, 80), L.t("freedom.togods"), size: 28, selected: true))
|
||||
Next(Phase.Gods);
|
||||
}
|
||||
|
||||
void DrawGods(SpriteBatch sb)
|
||||
{
|
||||
D.Text(sb, Assets.Serif, 60, L.t("freedom.gods").ToUpperInvariant(), new Vector2(Camera.W / 2, 90), D.Gold, Align.Center);
|
||||
D.Text(sb, Assets.Sans, 22, L.t("freedom.gods.intro"), new Vector2(Camera.W / 2, 150), D.Sand, Align.Center);
|
||||
D.Text(sb, Assets.SansBold, 30, string.Format(L.t("gods.favor"), _game.GodFavor), new Vector2(Camera.W / 2, 200), D.Purple, Align.Center);
|
||||
GodCards(sb, _ui, _game, new Vector2(Camera.W / 2, 260));
|
||||
if (_ui.Button(sb, new RectangleF(Camera.W / 2 - 260, 900, 520, 80), L.t("freedom.next"), size: 28, selected: true))
|
||||
{
|
||||
SoundManager.StopAll();
|
||||
Done = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// Götter-Karten (3 × 2) mit Stufe, Wirkung und Opfer-Knopf — auch in der Ehrenhalle genutzt.
|
||||
public static void GodCards(SpriteBatch sb, Ui ui, GameState game, Vector2 topCenter, float cw = 560, float ch = 250)
|
||||
{
|
||||
const float GX = 30, GY = 26;
|
||||
var gods = Enum.GetValues<God>();
|
||||
float x0 = topCenter.X - (3 * cw + 2 * GX) / 2, y0 = topCenter.Y;
|
||||
foreach (var god in gods)
|
||||
{
|
||||
int i = (int)god;
|
||||
var r = new RectangleF(x0 + i % 3 * (cw + GX), y0 + i / 3 * (ch + GY), cw, ch);
|
||||
Ui.Panel(sb, r, D.Border, 0.92f);
|
||||
float tx = r.X + 20, iconSize = MathF.Min(110, ch * 0.48f);
|
||||
if (Assets.Sprite(Art.God(god)) is Texture2D icon)
|
||||
{
|
||||
float s = iconSize / icon.Width;
|
||||
sb.Draw(icon, new Vector2(r.X + 16, r.Y + 16), null, Color.White, 0, Vector2.Zero, s, SpriteEffects.None, 0);
|
||||
tx = r.X + iconSize + 32;
|
||||
}
|
||||
D.Text(sb, Assets.Serif, 28, L.t(Gods.Key(god)), new Vector2(tx, r.Y + 34), D.Gold);
|
||||
D.Text(sb, Assets.SansBold, 20, string.Format(L.t("ludus.level"), game.GodLevel(god)), new Vector2(r.Right - 20, r.Y + 34), D.Sand, Align.Right);
|
||||
D.TextWrap(sb, Assets.Sans, ch < 200 ? 15 : 18, L.t(Gods.Key(god) + ".desc"), new RectangleF(tx, r.Y + 58, r.Right - 20 - tx, ch - 58 - 74), D.Dim);
|
||||
int cost = Gods.Cost(game.GodLevel(god));
|
||||
if (ui.Button(sb, new RectangleF(r.Right - 216, r.Bottom - 62, 196, 46), string.Format(L.t("gods.cost"), cost),
|
||||
game.GodFavor >= cost, size: 20, accent: D.Purple))
|
||||
if (game.BuyGod(god)) SoundManager.PlayLevelUp();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
73
Mono/Arena/HubScene.Hall.cs
Normal file
73
Mono/Arena/HubScene.Hall.cs
Normal file
@@ -0,0 +1,73 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace GladiatorIdle.Arena
|
||||
/// </summary>
|
||||
internal sealed partial class HubScene
|
||||
{
|
||||
enum Drawer { None, Gladiator, Ludus, Forum, Skills }
|
||||
enum Drawer { None, Gladiator, Ludus, Forum, Skills, Hall }
|
||||
|
||||
readonly GameState _game;
|
||||
readonly Ui _ui = new();
|
||||
@@ -295,6 +295,10 @@ namespace GladiatorIdle.Arena
|
||||
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;
|
||||
}
|
||||
|
||||
void DrawDrawer(SpriteBatch sb)
|
||||
@@ -306,6 +310,7 @@ namespace GladiatorIdle.Arena
|
||||
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);
|
||||
}
|
||||
|
||||
static float Ease(float k) => 1 - (1 - k) * (1 - k);
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace GladiatorIdle
|
||||
HubScene? _hub;
|
||||
DuelScene? _scene;
|
||||
ModelTestScene? _model; // --model3d: 3D-Test
|
||||
FreedomScene? _freedom; // Freiheit: Clip, Bilanz, Götter
|
||||
bool _nextLife; // nächste Erstellung behält das Profil (Legenden, Götter)
|
||||
Legend? _legend; // laufendes Duell gegen eine Legende
|
||||
static readonly bool DevFreedomRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--freedom") >= 0;
|
||||
static readonly bool DevChampionRun = Array.IndexOf(Environment.GetCommandLineArgs(), "--champion") >= 0;
|
||||
static readonly bool Model3DTest = Array.IndexOf(Environment.GetCommandLineArgs(), "--model3d") >= 0;
|
||||
SettingsOverlay _settings = null!;
|
||||
bool _paused;
|
||||
@@ -121,7 +126,7 @@ namespace GladiatorIdle
|
||||
|
||||
void ToMenu()
|
||||
{
|
||||
_hub = null; _scene = null; _creator = null; _intro = null; _paused = false;
|
||||
_hub = null; _scene = null; _creator = null; _intro = null; _freedom = null; _paused = false; _nextLife = false;
|
||||
_menu = new MenuScene(_game != null, _game?.Freedoms ?? 0);
|
||||
}
|
||||
|
||||
@@ -134,9 +139,17 @@ namespace GladiatorIdle
|
||||
/// Erstellung fertig: neues Leben mit dem eigenen Gladiator, dann in die Arena.
|
||||
void StartGame(CreatorScene c)
|
||||
{
|
||||
int freedoms = _game?.Freedoms ?? 0;
|
||||
_game = new GameState(seed: DevShot.Active ? 7 : Environment.TickCount);
|
||||
_game.Create(c.Name.Trim(), c.Class, c.Look, c.Bonus, c.StartSkill);
|
||||
if (_nextLife && _game != null)
|
||||
{
|
||||
// nach der Freiheit: neues Leben im selben Profil (Legenden, Götter, Freiheiten bleiben)
|
||||
_nextLife = false;
|
||||
_game.Create(c.Name.Trim(), c.Class, c.Look, c.Bonus, c.StartSkill);
|
||||
}
|
||||
else
|
||||
{
|
||||
_game = new GameState(seed: DevShot.Active ? 7 : Environment.TickCount);
|
||||
_game.Create(c.Name.Trim(), c.Class, c.Look, c.Bonus, c.StartSkill);
|
||||
}
|
||||
// --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;
|
||||
@@ -147,6 +160,30 @@ namespace GladiatorIdle
|
||||
DevShot.Log($"timing: hub created in {sw.ElapsedMilliseconds} ms");
|
||||
}
|
||||
|
||||
/// Letzter Champion besiegt: Freiheit annehmen (Legende, Gunst), dann der Freiheits-Bildschirm.
|
||||
void StartFreedom()
|
||||
{
|
||||
int favor = _game!.TakeFreedom();
|
||||
if (favor <= 0 && _game.Legends.Count == 0) return;
|
||||
_game.Save();
|
||||
_hub = null; _scene = null; _paused = false;
|
||||
_freedom = new FreedomScene(_game, _game.Legends[^1], favor);
|
||||
_devTime = 0;
|
||||
}
|
||||
|
||||
/// Duell gegen eine Legende aus der Ehrenhalle.
|
||||
void StartLegendDuel(Legend l)
|
||||
{
|
||||
_legend = l;
|
||||
_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}");
|
||||
}
|
||||
|
||||
/// Gegner gewählt: Duell beginnt.
|
||||
void StartDuel(Offer o)
|
||||
{
|
||||
@@ -165,8 +202,20 @@ namespace GladiatorIdle
|
||||
void EndDuel()
|
||||
{
|
||||
bool won = _scene!.Won;
|
||||
_game!.ResolveFight(_offer!, won);
|
||||
_hub!.ShowResult(_hub.ResultLines(_before, won), won ? Gfx.Draw.Gold : Gfx.Draw.Red);
|
||||
if (_legend is Legend l)
|
||||
{
|
||||
bool first = _game!.ResolveLegendDuel(l, won);
|
||||
_hub!.ShowResult(new[] { L.t(won ? "duel.win" : "duel.lose"),
|
||||
first ? string.Format(L.t("hall.reward"), l.Name, GameState.LEGEND_FAVOR) : l.Name },
|
||||
won ? Gfx.Draw.Gold : Gfx.Draw.Red);
|
||||
if (first) SoundManager.PlayAchievement();
|
||||
_legend = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_game!.ResolveFight(_offer!, won);
|
||||
_hub!.ShowResult(_hub.ResultLines(_before, won), won ? Gfx.Draw.Gold : Gfx.Draw.Red);
|
||||
}
|
||||
SoundManager.StartAmbient("music_ludus");
|
||||
_scene = null;
|
||||
_game.Save();
|
||||
@@ -204,6 +253,19 @@ namespace GladiatorIdle
|
||||
if (input.Pressed(Keys.Escape)) Exit();
|
||||
if (DevShot.Active) DevModel(dt);
|
||||
}
|
||||
else if (_freedom != null)
|
||||
{
|
||||
_freedom.Update(dt, input, ui);
|
||||
if (DevShot.Active) DevFreedom(dt);
|
||||
if (_freedom != null && _freedom.Done)
|
||||
{
|
||||
// der nächste Gladiator: Erstellung im selben Profil
|
||||
_freedom = null;
|
||||
_nextLife = true;
|
||||
_creator = new CreatorScene(DevShot.Active ? DevShot.Name : L.t("gladiator.defaultname"));
|
||||
_devTime = 0;
|
||||
}
|
||||
}
|
||||
else if (_intro != null)
|
||||
{
|
||||
_intro.Update(dt, input, ui);
|
||||
@@ -244,6 +306,8 @@ namespace GladiatorIdle
|
||||
if (_paused) _pauseUi.Begin(input, ui);
|
||||
if (DevShot.Active) DevHub(dt);
|
||||
if (_hub?.Chosen is Offer o) { _hub.Chosen = null; StartDuel(o); }
|
||||
else if (_hub?.ChosenLegend is Legend lg) { _hub.ChosenLegend = null; StartLegendDuel(lg); }
|
||||
else if (_hub != null && _game!.FreedomEarned && !_settings.Open) StartFreedom();
|
||||
}
|
||||
else if (_scene != null)
|
||||
{
|
||||
@@ -340,6 +404,19 @@ namespace GladiatorIdle
|
||||
{
|
||||
_devTime += dt;
|
||||
void Shot(string name) { if (_shots.Add(name)) _capture = name; }
|
||||
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 > 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; }
|
||||
return;
|
||||
}
|
||||
if (DevChampionRun && !_shots.Contains("m_end"))
|
||||
{
|
||||
if (_devTime > 0.5 && _capture == null) { _hub!.Chosen = new Offer(_game!.ChampionEnemy, 1, OfferKind.Champion); _devTime = 0; }
|
||||
return;
|
||||
}
|
||||
if (!_shots.Contains("m_end"))
|
||||
{
|
||||
if (_devTime > 1.0) Shot("h_hub");
|
||||
@@ -369,6 +446,19 @@ namespace GladiatorIdle
|
||||
}
|
||||
}
|
||||
|
||||
/// Testlauf --freedom: Clip, Bilanz und Götter aufnehmen, dann weiter zum nächsten Leben.
|
||||
void DevFreedom(float dt)
|
||||
{
|
||||
_devTime += dt;
|
||||
void Shot(string name) { if (_shots.Add(name)) _capture = name; }
|
||||
if (_devTime > 2.5) Shot("f_clip");
|
||||
if (_devTime > 2.7 && !_shots.Contains("f_sum_open")) { _shots.Add("f_sum_open"); _freedom!.DevShow(1, 0.2f); }
|
||||
if (_devTime > 4.2) Shot("f_summary");
|
||||
if (_devTime > 4.4 && !_shots.Contains("f_gods_open")) { _shots.Add("f_gods_open"); _freedom!.DevShow(2, 0.5f); }
|
||||
if (_devTime > 5.0) Shot("f_gods");
|
||||
if (_devTime > 5.3 && _capture == null && _shots.Contains("f_gods")) _freedom!.DevDone();
|
||||
}
|
||||
|
||||
/// Testlauf: Bot kämpft; Aufnahmen an markanten Stellen.
|
||||
void DevSteps(float dt)
|
||||
{
|
||||
@@ -376,6 +466,7 @@ namespace GladiatorIdle
|
||||
var d = _scene!.Duel;
|
||||
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 (_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");
|
||||
@@ -441,6 +532,7 @@ namespace GladiatorIdle
|
||||
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
|
||||
Gfx.Draw.UiScale = scale;
|
||||
if (_model != null) _model.Draw(gd, _sb, scale, offset);
|
||||
else if (_freedom != null) _freedom.Draw(gd, _sb, _fx, scale, offset);
|
||||
else if (_intro != null) _intro.Draw(_sb, scale, offset);
|
||||
else if (_menu != null) _menu.Draw(_sb, scale, offset);
|
||||
else if (_creator != null) _creator.Draw(gd, _sb, _fx, scale, offset);
|
||||
|
||||
@@ -53,6 +53,25 @@ namespace GladiatorIdle.Gfx
|
||||
font.DrawText(sb, text, p, c, scale: s);
|
||||
}
|
||||
|
||||
/// Text mit Zeilenumbruch an Wortgrenzen innerhalb von <paramref name="r"/> (oben links beginnend).
|
||||
public static void TextWrap(SpriteBatch sb, FontSystem fs, float px, string text, RectangleF r, Color c)
|
||||
{
|
||||
float y = r.Y + px * 0.6f, lineH = px * 1.3f;
|
||||
string line = "";
|
||||
foreach (var word in text.Split(' '))
|
||||
{
|
||||
string next = line.Length == 0 ? word : line + " " + word;
|
||||
if (line.Length > 0 && Measure(fs, px, next).X > r.Width)
|
||||
{
|
||||
if (y > r.Bottom) return;
|
||||
Text(sb, fs, px, line, new Vector2(r.X, y), c);
|
||||
y += lineH; line = word;
|
||||
}
|
||||
else line = next;
|
||||
}
|
||||
if (line.Length > 0 && y <= r.Bottom + lineH) Text(sb, fs, px, line, new Vector2(r.X, y), c);
|
||||
}
|
||||
|
||||
/// Balken mit verzögertem Rest (weißer Abschnitt zeigt den gerade verlorenen Teil).
|
||||
public static void Bar(SpriteBatch sb, RectangleF r, float value, float lag, Color c, bool fromRight = false)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user