using System; using GladiatorIdle.Gfx; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using D = GladiatorIdle.Gfx.Draw; namespace GladiatorIdle.Arena { /// /// Startmenü: Kolosseum im Morgenlicht, Titel, Weiterspielen / Neuer Gladiator (mit zweitem /// Klick zur Sicherheit, wenn ein Spielstand da ist) / Intro / Einstellungen / Beenden. /// internal sealed class MenuScene { public enum Choice { None, Continue, New, Intro, Leaderboard, Settings, Quit } readonly Ui _ui = new(); readonly Particles _fx = new(); readonly Texture2D? _backdrop = Assets.Sprite("intro_colosseum", "jpg"); readonly bool _hasSave; readonly int _freedoms; double _t, _armNew; public Choice Picked { get; set; } public MenuScene(bool hasSave, int freedoms) { _hasSave = hasSave; _freedoms = freedoms; SoundManager.StartAmbient("music_menu"); // Intro-Clips schon jetzt im Hintergrund laden foreach (var s in IntroScene.Scenes) ClipCache.Video(s); } public void Update(float dt, Input input, Matrix ui, bool overlay) { _t += dt; _armNew = Math.Max(0, _armNew - dt); if (!overlay) _ui.Begin(input, ui); else _ui.Click = false; _fx.Motes(AppSettings.ReduceMotion ? 0 : 70, Camera.W, Camera.H); _fx.Update(dt); } 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) { // 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); D.Glow(sb, new Vector2(-200, Camera.H / 2), new Vector2(900, 2000), Color.Black * 0.8f); D.Glow(sb, new Vector2(Camera.W + 200, Camera.H / 2), new Vector2(900, 2000), Color.Black * 0.8f); 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, 230), new Vector2(1500, 420), D.Gold * 0.10f); sb.End(); sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, ui); float appear = MathHelper.Clamp((float)_t / 0.8f, 0, 1); 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 = 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 + 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 + 14; if (_ui.Button(sb, new RectangleF(x, y, w, h), L.t("menu.intro"), size: 26)) Picked = Choice.Intro; 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 + 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 + 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(); } } }