Chessistics/Scripts/Pieces/TrajectView.cs

59 lines
1.7 KiB
C#
Raw Permalink Normal View History

using Godot;
namespace Chessistics.Scripts.Pieces;
public partial class TrajectView : Line2D
{
public int PieceId { get; private set; }
private Polygon2D? _arrowEnd;
private Polygon2D? _arrowStart;
private Tween? _pulseTween;
private Color _baseColor;
public void Setup(int pieceId, Vector2 from, Vector2 to, Color color)
{
PieceId = pieceId;
_baseColor = color;
Width = 3f;
DefaultColor = new Color(color, 0.4f);
Juice pass: procedural SFX, particles, polished visuals Sound (SfxManager.cs): - Procedural audio synthesis via AudioStreamWav — no external files - Distinct tones for place, produce, transfer, deliver, move, destroy, victory - Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes Pieces (PieceView.cs): - Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna - Drop shadow under each piece for depth - 3-stop radial gradient (bright center → main → dark rim) - Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing) - Cargo indicator pulses gently when carrying Trajectories (TrajectView.cs): - Arrowhead at endpoint showing movement direction - Antialiased lines with piece-matched colors Cells (CellView.cs): - Warmer palette: parchment/walnut board, deep forest production, aged gold demand - Production flash uses warm golden glow instead of white - Subtle inner shadow for visual depth Animations (EventAnimator.cs): - Production: golden particles burst from production cells - Transfer: cargo slides with 2-particle trail + back-out whip easing - Destruction: pieces shrink + spin + red particle explosion - Victory: 40 confetti particles rain across the screen - All phases trigger appropriate SFX UI polish: - ControlBar: styled buttons with rounded corners, disabled states - MetricsOverlay: fade-in + scale animation, sequential metric reveals - ObjectivePanel: animated progress bars, styled fills, green flash on completion - Main: fade-in/out transitions between level select and gameplay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
Antialiased = true;
ClearPoints();
AddPoint(from);
AddPoint(to);
ZIndex = -1;
Juice pass: procedural SFX, particles, polished visuals Sound (SfxManager.cs): - Procedural audio synthesis via AudioStreamWav — no external files - Distinct tones for place, produce, transfer, deliver, move, destroy, victory - Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes Pieces (PieceView.cs): - Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna - Drop shadow under each piece for depth - 3-stop radial gradient (bright center → main → dark rim) - Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing) - Cargo indicator pulses gently when carrying Trajectories (TrajectView.cs): - Arrowhead at endpoint showing movement direction - Antialiased lines with piece-matched colors Cells (CellView.cs): - Warmer palette: parchment/walnut board, deep forest production, aged gold demand - Production flash uses warm golden glow instead of white - Subtle inner shadow for visual depth Animations (EventAnimator.cs): - Production: golden particles burst from production cells - Transfer: cargo slides with 2-particle trail + back-out whip easing - Destruction: pieces shrink + spin + red particle explosion - Victory: 40 confetti particles rain across the screen - All phases trigger appropriate SFX UI polish: - ControlBar: styled buttons with rounded corners, disabled states - MetricsOverlay: fade-in + scale animation, sequential metric reveals - ObjectivePanel: animated progress bars, styled fills, green flash on completion - Main: fade-in/out transitions between level select and gameplay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
_arrowEnd = BuildArrow(from, to, color);
_arrowStart = BuildArrow(to, from, color);
AddChild(_arrowEnd);
AddChild(_arrowStart);
StartPulse();
}
private static Polygon2D BuildArrow(Vector2 from, Vector2 to, Color color)
{
Juice pass: procedural SFX, particles, polished visuals Sound (SfxManager.cs): - Procedural audio synthesis via AudioStreamWav — no external files - Distinct tones for place, produce, transfer, deliver, move, destroy, victory - Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes Pieces (PieceView.cs): - Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna - Drop shadow under each piece for depth - 3-stop radial gradient (bright center → main → dark rim) - Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing) - Cargo indicator pulses gently when carrying Trajectories (TrajectView.cs): - Arrowhead at endpoint showing movement direction - Antialiased lines with piece-matched colors Cells (CellView.cs): - Warmer palette: parchment/walnut board, deep forest production, aged gold demand - Production flash uses warm golden glow instead of white - Subtle inner shadow for visual depth Animations (EventAnimator.cs): - Production: golden particles burst from production cells - Transfer: cargo slides with 2-particle trail + back-out whip easing - Destruction: pieces shrink + spin + red particle explosion - Victory: 40 confetti particles rain across the screen - All phases trigger appropriate SFX UI polish: - ControlBar: styled buttons with rounded corners, disabled states - MetricsOverlay: fade-in + scale animation, sequential metric reveals - ObjectivePanel: animated progress bars, styled fills, green flash on completion - Main: fade-in/out transitions between level select and gameplay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
var dir = (to - from).Normalized();
var perp = new Vector2(-dir.Y, dir.X);
const float arrowSize = 9f;
var tip = to - dir * 4f;
Juice pass: procedural SFX, particles, polished visuals Sound (SfxManager.cs): - Procedural audio synthesis via AudioStreamWav — no external files - Distinct tones for place, produce, transfer, deliver, move, destroy, victory - Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes Pieces (PieceView.cs): - Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna - Drop shadow under each piece for depth - 3-stop radial gradient (bright center → main → dark rim) - Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing) - Cargo indicator pulses gently when carrying Trajectories (TrajectView.cs): - Arrowhead at endpoint showing movement direction - Antialiased lines with piece-matched colors Cells (CellView.cs): - Warmer palette: parchment/walnut board, deep forest production, aged gold demand - Production flash uses warm golden glow instead of white - Subtle inner shadow for visual depth Animations (EventAnimator.cs): - Production: golden particles burst from production cells - Transfer: cargo slides with 2-particle trail + back-out whip easing - Destruction: pieces shrink + spin + red particle explosion - Victory: 40 confetti particles rain across the screen - All phases trigger appropriate SFX UI polish: - ControlBar: styled buttons with rounded corners, disabled states - MetricsOverlay: fade-in + scale animation, sequential metric reveals - ObjectivePanel: animated progress bars, styled fills, green flash on completion - Main: fade-in/out transitions between level select and gameplay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
var baseL = tip - dir * arrowSize + perp * arrowSize * 0.5f;
var baseR = tip - dir * arrowSize - perp * arrowSize * 0.5f;
return new Polygon2D
Juice pass: procedural SFX, particles, polished visuals Sound (SfxManager.cs): - Procedural audio synthesis via AudioStreamWav — no external files - Distinct tones for place, produce, transfer, deliver, move, destroy, victory - Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes Pieces (PieceView.cs): - Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna - Drop shadow under each piece for depth - 3-stop radial gradient (bright center → main → dark rim) - Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing) - Cargo indicator pulses gently when carrying Trajectories (TrajectView.cs): - Arrowhead at endpoint showing movement direction - Antialiased lines with piece-matched colors Cells (CellView.cs): - Warmer palette: parchment/walnut board, deep forest production, aged gold demand - Production flash uses warm golden glow instead of white - Subtle inner shadow for visual depth Animations (EventAnimator.cs): - Production: golden particles burst from production cells - Transfer: cargo slides with 2-particle trail + back-out whip easing - Destruction: pieces shrink + spin + red particle explosion - Victory: 40 confetti particles rain across the screen - All phases trigger appropriate SFX UI polish: - ControlBar: styled buttons with rounded corners, disabled states - MetricsOverlay: fade-in + scale animation, sequential metric reveals - ObjectivePanel: animated progress bars, styled fills, green flash on completion - Main: fade-in/out transitions between level select and gameplay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
{
Polygon = [tip, baseL, baseR],
Color = new Color(color, 0.5f)
Juice pass: procedural SFX, particles, polished visuals Sound (SfxManager.cs): - Procedural audio synthesis via AudioStreamWav — no external files - Distinct tones for place, produce, transfer, deliver, move, destroy, victory - Simple ADSR envelope, sine/triangle waveforms, filtered noise for swooshes Pieces (PieceView.cs): - Warm earthy palette: sage green, deep teal, dusty rose, burnt sienna - Drop shadow under each piece for depth - 3-stop radial gradient (bright center → main → dark rim) - Scale bounce on placement (0 → 1.15 → 1.0 with back-out easing) - Cargo indicator pulses gently when carrying Trajectories (TrajectView.cs): - Arrowhead at endpoint showing movement direction - Antialiased lines with piece-matched colors Cells (CellView.cs): - Warmer palette: parchment/walnut board, deep forest production, aged gold demand - Production flash uses warm golden glow instead of white - Subtle inner shadow for visual depth Animations (EventAnimator.cs): - Production: golden particles burst from production cells - Transfer: cargo slides with 2-particle trail + back-out whip easing - Destruction: pieces shrink + spin + red particle explosion - Victory: 40 confetti particles rain across the screen - All phases trigger appropriate SFX UI polish: - ControlBar: styled buttons with rounded corners, disabled states - MetricsOverlay: fade-in + scale animation, sequential metric reveals - ObjectivePanel: animated progress bars, styled fills, green flash on completion - Main: fade-in/out transitions between level select and gameplay Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 23:05:55 +02:00
};
}
private void StartPulse()
{
_pulseTween?.Kill();
_pulseTween = CreateTween();
_pulseTween.SetLoops();
_pulseTween.TweenProperty(this, "default_color:a", 0.75f, 1.1f)
.SetEase(Tween.EaseType.InOut).SetTrans(Tween.TransitionType.Sine);
_pulseTween.TweenProperty(this, "default_color:a", 0.3f, 1.1f)
.SetEase(Tween.EaseType.InOut).SetTrans(Tween.TransitionType.Sine);
}
}