Neue Töne, Reiter mit Anleitung, Klingen geeicht, Sprung, Vorschaubilder aus 3D
Stand von main 262a2009. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -28,6 +28,13 @@ namespace GladiatorIdle.Arena
|
||||
readonly Particles _fx = new();
|
||||
readonly Texture2D? _backdrop = Assets.Sprite("arena_ludus", "jpg");
|
||||
FighterView _preview = null!;
|
||||
// Vorschaubilder der Vorlagen: aus den 3D-Figuren gerendert (je Klasse einmal geladen)
|
||||
const int THUMB_W = 296, THUMB_H = 340;
|
||||
readonly System.Collections.Generic.Dictionary<GladiatorClass, FighterView[]> _thumbFigs = new();
|
||||
readonly RenderTarget2D?[] _thumbs = new RenderTarget2D?[Appearance.PRESETS];
|
||||
bool _thumbsDirty = true;
|
||||
int _thumbTint = -1;
|
||||
GladiatorClass _thumbClass = (GladiatorClass)(-1);
|
||||
readonly DuelFighter _dummy = new() { IsPlayer = true, X = 0, Facing = 1, MaxHp = 1, Hp = 1 };
|
||||
double _t, _showAt = 2.5;
|
||||
int _show;
|
||||
@@ -97,6 +104,7 @@ namespace GladiatorIdle.Arena
|
||||
|
||||
public void Draw(GraphicsDevice gd, SpriteBatch sb, BasicEffect fx, float scale, Vector2 offset)
|
||||
{
|
||||
RenderThumbs(gd, fx);
|
||||
D.UiScale = scale;
|
||||
var ui = Matrix.CreateScale(scale) * Matrix.CreateTranslation(offset.X, offset.Y, 0);
|
||||
|
||||
@@ -136,6 +144,37 @@ namespace GladiatorIdle.Arena
|
||||
sb.End();
|
||||
}
|
||||
|
||||
/// Vorschaubilder neu rendern, wenn Klasse oder Farbe gewechselt hat (in eigene Bildflächen,
|
||||
/// danach zurück auf das bisherige Ziel; das wird dabei geleert, darum vor allem anderen).
|
||||
void RenderThumbs(GraphicsDevice gd, BasicEffect fx)
|
||||
{
|
||||
if (_thumbClass != Class || _thumbTint != Tint) _thumbsDirty = true;
|
||||
if (!_thumbsDirty) return;
|
||||
if (!_thumbFigs.TryGetValue(Class, out var figs))
|
||||
{
|
||||
figs = new FighterView[Appearance.PRESETS];
|
||||
for (int p = 1; p <= Appearance.PRESETS; p++) figs[p - 1] = new FighterView(Art.Hero(Class, p), 0, Tint);
|
||||
_thumbFigs[Class] = figs;
|
||||
}
|
||||
var idle = new DuelFighter { IsPlayer = true, Facing = 1, MaxHp = 1, Hp = 1 };
|
||||
var previous = gd.GetRenderTargets();
|
||||
for (int i = 0; i < figs.Length; i++)
|
||||
{
|
||||
if (!figs[i].Is3D) { _thumbs[i] = null; continue; }
|
||||
figs[i].SetModelColor(Tint);
|
||||
figs[i].Update(1 / 60f, 1 / 60f, idle, 0, true);
|
||||
_thumbs[i] ??= new RenderTarget2D(gd, THUMB_W, THUMB_H, false, SurfaceFormat.Color, DepthFormat.Depth24);
|
||||
gd.SetRenderTarget(_thumbs[i]);
|
||||
gd.Clear(Color.Transparent);
|
||||
fx.View = Matrix.CreateTranslation(0, -Stage.FloorY, 0) * Matrix.CreateScale(0.95f) * Matrix.CreateTranslation(THUMB_W / 2f, THUMB_H - 8, 0);
|
||||
fx.Projection = Matrix.CreateOrthographicOffCenter(0, THUMB_W, THUMB_H, 0, 0, 1);
|
||||
figs[i].DrawBody(gd, fx, idle, true);
|
||||
}
|
||||
gd.SetRenderTargets(previous);
|
||||
gd.Clear(Color.Black);
|
||||
_thumbClass = Class; _thumbTint = Tint; _thumbsDirty = false;
|
||||
}
|
||||
|
||||
void DrawNameField(SpriteBatch sb)
|
||||
{
|
||||
var r = new RectangleF(170, 968, 600, 68);
|
||||
@@ -172,7 +211,9 @@ namespace GladiatorIdle.Arena
|
||||
var r = new RectangleF(x0 + (p - 1) * 160, 214, 148, 170);
|
||||
bool sel = Preset == p, hover = _ui.Hover(r);
|
||||
D.Rect(sb, r, new Color(30, 22, 15) * 0.9f);
|
||||
if (Assets.Sprite(Art.Hero(Class, p)) is Texture2D t)
|
||||
if (_thumbs[p - 1] is RenderTarget2D th && !th.IsDisposed)
|
||||
sb.Draw(th, new Rectangle((int)r.X + 2, (int)r.Y + 2, (int)r.Width - 4, (int)r.Height - 4), Color.White);
|
||||
else if (Assets.Sprite(Art.Hero(Class, p)) is Texture2D t)
|
||||
{
|
||||
var painted = Assets.Paint(t, Tint);
|
||||
float k = r.Height * 1.02f / t.Height;
|
||||
|
||||
Reference in New Issue
Block a user