Files
GladiatorIdle/Mono/Arena/HubScene.Guide.cs

102 lines
5.5 KiB
C#
Raw Permalink Normal View History

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
{
/// Anleitung rechts neben jeder Schublade: wofür der Reiter da ist, drei bis vier Schritte, und ein
/// Tipp, der zum aktuellen Spielstand passt (was jetzt sinnvoll ist).
internal sealed partial class HubScene
{
string GuideId => _drawer switch
{
Drawer.Gladiator => _page == Page.Skills ? "skills" : "gladiator", Drawer.Ludus => "ludus",
Drawer.Hall => "hall", _ => "expedition"
};
void DrawGuide(SpriteBatch sb, RectangleF r)
{
string id = GuideId;
Ui.Panel(sb, r, D.Border, 0.94f);
float x = r.X + 26, w = r.Width - 52, y = r.Y + 34;
D.Text(sb, Assets.Serif, 28, L.t("guide.title"), new Vector2(x, y), D.Gold);
D.TextWrap(sb, Assets.Serif, 19, L.t($"guide.{id}.what"), new RectangleF(x, y + 30, w, 90), D.Sand);
y += 128;
for (int i = 1; i <= 4; i++)
{
string key = $"guide.{id}.{i}";
string text = L.t(key);
if (text == key || text.Length == 0) break; // weniger als vier Schritte
var c = new Vector2(x + 16, y + 12);
D.Glow(sb, c, new Vector2(40), D.Gold * 0.25f);
D.Text(sb, Assets.SansBold, 19, i.ToString(NumberFormat.Culture), c, D.Gold, Align.Center);
D.TextWrap(sb, Assets.Sans, 17, text, new RectangleF(x + 44, y, w - 44, 90), Color.White);
y += 96;
}
// Tipp zum Spielstand
var (tip, accent) = Tip();
var tr = new RectangleF(r.X + 16, r.Bottom - 190, r.Width - 32, 172);
D.Rect(sb, tr, new Color(46, 34, 18) * 0.95f);
D.Frame(sb, tr, accent, 2);
D.Text(sb, Assets.SansBold, 18, L.t("guide.tip"), new Vector2(tr.X + 18, tr.Y + 22), accent);
D.TextWrap(sb, Assets.Sans, 18, tip, new RectangleF(tr.X + 18, tr.Y + 44, tr.Width - 36, 120), Color.White);
}
/// Der wichtigste nächste Schritt in diesem Reiter.
(string, Color) Tip(Drawer? which = null)
{
var g = _game;
switch (which ?? _drawer)
{
case Drawer.Gladiator when _page == Page.Skills:
return g.LearnablePoints > 0
? (string.Format(L.t("tip.skills.points"), g.LearnablePoints), D.Gold)
: (string.Format(L.t("tip.skills.next"), g.CharLevel / 2 * 2 + 2), D.Sand);
case Drawer.Gladiator:
{
if (g.AttrPoints > 0) return (string.Format(L.t("tip.gladiator.points"), g.AttrPoints), D.Gold);
double now = g.Power();
var better = g.Inventory.Where(it => g.PowerWith(it) > now * 1.005).OrderByDescending(g.PowerWith).FirstOrDefault();
if (better != null) return (string.Format(L.t("tip.gladiator.better"), ItemName(better)), D.Green);
if (g.Inventory.Count >= Items.INVENTORY - 4) return (L.t("tip.gladiator.full"), D.Red);
var slot = Enumerable.Range(0, 5).Select(i => (ItemSlot)i).Where(s => g.Equipped[(int)s] != null)
.OrderBy(g.UpgradeSlotCost).FirstOrDefault();
if (g.Equipped[(int)slot] != null && g.Gold >= g.UpgradeSlotCost(slot))
return (string.Format(L.t("tip.gladiator.forge"), L.t("slot." + slot.ToString().ToLowerInvariant())), D.Green);
return (L.t("tip.gladiator.none"), D.Sand);
}
case Drawer.Ludus:
{
var cheapest = UpgradeDef.All.OrderBy(u => g.UpgradeCost(u.Id)).First();
double cost = g.UpgradeCost(cheapest.Id);
return g.Gold >= cost
? (string.Format(L.t("tip.ludus.afford"), L.t(cheapest.Key)), D.Green)
: (string.Format(L.t("tip.ludus.save"), L.t(cheapest.Key), NumberFormat.Format(cost - g.Gold)), D.Sand);
}
case Drawer.Hall:
{
if (g.Legends.Count == 0) return (L.t("tip.hall.none"), D.Sand);
var target = g.Legends.Where(l => !g.LegendsBeaten.Contains(l.Number))
.OrderByDescending(l => g.DuelRatio(GameState.LegendEnemy(l))).FirstOrDefault();
if (target != null && g.DuelRatio(GameState.LegendEnemy(target)) >= 1)
return (string.Format(L.t("tip.hall.beatable"), target.Name, GameState.LEGEND_FAVOR), D.Green);
int cheapest = Enum.GetValues<God>().Min(god => Gods.Cost(g.GodLevel(god)));
if (g.GodFavor >= cheapest) return (string.Format(L.t("tip.hall.favor"), g.GodFavor), D.Purple);
return (L.t(target != null ? "tip.hall.later" : "tip.hall.done"), D.Sand);
}
default:
{
if (g.Away is { } a) return (string.Format(L.t("tip.exp.away"), NumberFormat.Duration(a.Left)), D.Gold);
var safe = RegionDef.All.Where(g.RegionOpen).Where(r => g.ExpeditionChance(r) >= 0.75).LastOrDefault();
if (safe != null) return (string.Format(L.t("tip.exp.safe"), L.t(safe.Key)), D.Green);
return (L.t("tip.exp.risky"), D.Red);
}
}
}
}
}