Gladiator Idle (MonoGame) – Spiel mit 3D-Gladiatoren

Nur was zum Bauen und Starten nötig ist: Mono/ (Spiel), Game/, Core/,
Languages/, Assets/ (Bilder, Clips, 3D-Figuren, Ton), build-release.bat.
Bauen: build-release.bat → Spiel\GladiatorIdle.exe

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-08 12:57:20 +01:00
commit a7134b2753
1112 changed files with 10806 additions and 0 deletions

169
Mono/Arena/HubScene.Gear.cs Normal file
View File

@@ -0,0 +1,169 @@
using System;
using System.Collections.Generic;
using System.Linq;
using GladiatorIdle.Gfx;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using D = GladiatorIdle.Gfx.Draw;
namespace GladiatorIdle.Arena
{
/// Ausrüstung: Inventar mit Detailkarte (anlegen, verkaufen), Händler und Schmied.
internal sealed partial class HubScene
{
long? _sel; // gewähltes Stück (Inventar oder angelegt)
double _sellAllArmed; // "Alle verkaufen": zweiter Klick innerhalb von 4 s
Item? Selected => _sel is long id ? _game.Inventory.FirstOrDefault(i => i.Id == id) ?? _game.Equipped.FirstOrDefault(i => i?.Id == id) : null;
bool SelectedEquipped => _sel is long id && _game.Equipped.Any(i => i?.Id == id);
// ── Kachel und Texte ────────────────────────────────────────
void ItemTile(SpriteBatch sb, RectangleF r, Item? it, bool selected)
{
D.Rect(sb, r, new Color(24, 18, 12) * (it == null ? 0.6f : 0.95f));
var col = it == null ? D.Border : RarityColor(it.Rarity);
if (it != null && Assets.Sprite(it.Def.Icon) is Texture2D icon)
sb.Draw(icon, r.Center, null, Color.White, 0, new Vector2(icon.Width / 2f, icon.Height / 2f), r.Width * 0.82f / icon.Width, SpriteEffects.None, 0);
if (it != null && it.Level > 0)
D.Text(sb, Assets.SansBold, 14, it.Level.ToString(NumberFormat.Culture), new Vector2(r.Right - 6, r.Bottom - 12), Color.White, Align.Right);
D.Frame(sb, r, selected ? Color.White : col, selected ? 3 : 2);
}
/// Hauptwirkung in einer Zeile (Schaden ×…, Leben ×…, Block …), so wie im Slot.
string ItemMain(Item it)
{
var d = it.Def;
double lv = it.EffLevel(_game.SlotLevels[(int)it.Slot]);
var parts = new List<string>();
if (d.Slot == ItemSlot.Shield) parts.Add(string.Format(L.t("item.stat.block"), NumberFormat.Percent(0.5 * lv / (lv + 8))));
if (d.DmgK > 0) parts.Add(string.Format(L.t("item.stat.damage"), NumberFormat.Mult(Math.Pow(Items.LEVEL_GROWTH, lv * d.DmgK))));
if (d.HpK > 0) parts.Add(string.Format(L.t("item.stat.health"), NumberFormat.Mult(Math.Pow(Items.LEVEL_GROWTH, lv * d.HpK))));
return string.Join(" · ", parts); // i18n-ok
}
static IEnumerable<string> ItemAffixes(Item it) => it.Affixes.Select(a => a.Kind == Affix.Agility
? string.Format(L.t("affix.agility"), a.Value.ToString("0.#", NumberFormat.Culture))
: string.Format(L.t("affix." + a.Kind.ToString().ToLowerInvariant()), NumberFormat.Percent(a.Value)));
/// Unterschied in der Kampfkraft, wenn das Stück angelegt würde.
(string, Color) PowerDelta(Item it)
{
double now = _game.Power(), with = _game.PowerWith(it), d = with / now - 1;
if (Math.Abs(d) < 0.005) return (L.t("item.same"), D.Dim);
string pct = (d > 0 ? "+" : "−") + NumberFormat.Percent(Math.Abs(d)); // i18n-ok
return (string.Format(L.t("item.power"), pct), d > 0 ? D.Green : D.Red);
}
// ── Inventar und Detailkarte (Gladiator-Schublade, rechts) ──
void DrawInventory(SpriteBatch sb, RectangleF area)
{
const int COLS = 5;
const float CELL = 76, GAP = 8;
D.Text(sb, Assets.SansBold, 20, string.Format(L.t("char.inventory"), _game.Inventory.Count, Items.INVENTORY),
new Vector2(area.X, area.Y), D.Sand);
// Alle verkaufen (mit Sicherheits-Klick)
_sellAllArmed = Math.Max(0, _sellAllArmed - 1 / 60.0);
bool armed = _sellAllArmed > 0;
string sellText = armed ? string.Format(L.t("char.sellall.confirm"), _game.Inventory.Count)
: string.Format(L.t("char.sellall"), NumberFormat.Format(_game.InventoryValue));
if (_ui.Button(sb, new RectangleF(area.X + 170, area.Y - 18, 250, 36), sellText, _game.Inventory.Count > 0,
selected: armed, size: armed ? 13 : 15, accent: armed ? D.Red : null))
{
if (!armed) _sellAllArmed = 4;
else
{
double got = _game.SellAll();
_sellAllArmed = 0;
if (_sel is long id && !_game.Equipped.Any(i => i?.Id == id)) _sel = null;
if (got > 0) SoundManager.PlayCoins();
}
}
for (int i = 0; i < Items.INVENTORY; i++)
{
var r = new RectangleF(area.X + i % COLS * (CELL + GAP), area.Y + 26 + i / COLS * (CELL + GAP), CELL, CELL);
var it = i < _game.Inventory.Count ? _game.Inventory[i] : null;
ItemTile(sb, r, it, it != null && _sel == it.Id);
if (it != null && (_ui.Hover(r) || false) && _ui.Hit(r)) _sel = it.Id;
}
// Detailkarte
var card = new RectangleF(area.X, area.Y + 26 + 6 * (CELL + GAP) + 10, COLS * (CELL + GAP) - GAP, area.Bottom - (area.Y + 26 + 6 * (CELL + GAP) + 10));
Ui.Panel(sb, card, D.Border, 0.9f);
var sel = Selected;
if (sel == null)
{
D.Text(sb, Assets.Sans, 18, L.t("char.pick"), card.Center, D.Dim, Align.Center);
return;
}
float x = card.X + 16, y = card.Y + 22;
D.Text(sb, Assets.SansBold, 22, ItemName(sel), new Vector2(x, y), RarityColor(sel.Rarity));
D.Text(sb, Assets.Sans, 16, L.t("rarity." + sel.Rarity.ToString().ToLowerInvariant()) + " · " + L.t("slot." + sel.Slot.ToString().ToLowerInvariant()),
new Vector2(x, y + 26), D.Dim); // i18n-ok
D.Text(sb, Assets.Sans, 17, ItemMain(sel), new Vector2(x, y + 54), D.Sand);
float ay = y + 80;
foreach (var a in ItemAffixes(sel)) { D.Text(sb, Assets.Sans, 16, a, new Vector2(x, ay), D.Blue); ay += 22; }
if (SelectedEquipped)
{
D.Text(sb, Assets.SansBold, 17, L.t("char.equipped"), new Vector2(card.Right - 16, y), D.Green, Align.Right);
return;
}
var (delta, dc) = PowerDelta(sel);
D.Text(sb, Assets.SansBold, 17, delta, new Vector2(card.Right - 16, y), dc, Align.Right);
float by = card.Bottom - 54, bw = (card.Width - 44) / 2;
if (_ui.Button(sb, new RectangleF(card.X + 16, by, bw, 42), L.t("char.equip"), size: 18, accent: D.Green))
if (_game.Equip(sel.Id)) SoundManager.PlayBlock();
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), 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 - 180, row.Y + 24, 166, 48), NumberFormat.Format(cost), _game.Gold >= cost, size: 19))
if (_game.UpgradeSlot(slot)) SoundManager.PlayLevelUp();
}
}
}
}