Chessistics/Scripts/Board/CellView.cs
Samuel Bouchet 450c069854 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

135 lines
4.6 KiB
C#

using Godot;
using Chessistics.Engine.Model;
namespace Chessistics.Scripts.Board;
public partial class CellView : Node2D
{
private ColorRect _background = null!;
private ColorRect _highlight = null!;
private ColorRect _innerShadow = null!;
private Label _label = null!;
// Hover outline (4 thin rects forming a border)
private ColorRect _hoverTop = null!;
private ColorRect _hoverBottom = null!;
private ColorRect _hoverLeft = null!;
private ColorRect _hoverRight = null!;
public Coords Coords { get; private set; }
// Warmer, more grounded palette
private static readonly Color LightColor = new("#E8D5A8"); // warm parchment
private static readonly Color DarkColor = new("#A07850"); // warm walnut
private static readonly Color WallColor = new("#3A3A3A"); // charcoal
private static readonly Color ProductionColor = new("#4A6E3A"); // deep forest
private static readonly Color DemandColor = new("#B8942A"); // aged gold
private static readonly Color HighlightColor = new("#44FF4444");
private static readonly Color HoverOutlineColor = new("#FFFFFF88");
private const int OutlineWidth = 2;
public void Setup(Coords coords, CellType cellType, int cellSize)
{
Coords = coords;
Position = new Vector2(coords.Col * cellSize, -coords.Row * cellSize);
_background = new ColorRect
{
Size = new Vector2(cellSize, cellSize),
Position = Vector2.Zero,
MouseFilter = Control.MouseFilterEnum.Ignore
};
var baseColor = coords.IsLight ? LightColor : DarkColor;
_background.Color = cellType switch
{
CellType.Wall => WallColor,
CellType.Production => ProductionColor,
CellType.Demand => DemandColor,
_ => baseColor
};
AddChild(_background);
// Subtle inner shadow for depth (top-left lit, bottom-right dark)
_innerShadow = new ColorRect
{
Size = new Vector2(cellSize, cellSize),
Position = Vector2.Zero,
Color = new Color(0, 0, 0, 0.06f),
Visible = cellType == CellType.Empty,
MouseFilter = Control.MouseFilterEnum.Ignore
};
AddChild(_innerShadow);
_highlight = new ColorRect
{
Size = new Vector2(cellSize, cellSize),
Position = Vector2.Zero,
Color = HighlightColor,
Visible = false,
MouseFilter = Control.MouseFilterEnum.Ignore
};
AddChild(_highlight);
// Hover outline (4 border rects)
_hoverTop = CreateBorderRect(new Vector2(cellSize, OutlineWidth), Vector2.Zero);
_hoverBottom = CreateBorderRect(new Vector2(cellSize, OutlineWidth), new Vector2(0, cellSize - OutlineWidth));
_hoverLeft = CreateBorderRect(new Vector2(OutlineWidth, cellSize), Vector2.Zero);
_hoverRight = CreateBorderRect(new Vector2(OutlineWidth, cellSize), new Vector2(cellSize - OutlineWidth, 0));
_label = new Label
{
Position = new Vector2(4, 3),
Text = "",
MouseFilter = Control.MouseFilterEnum.Ignore
};
_label.AddThemeFontSizeOverride("font_size", 9);
_label.AddThemeColorOverride("font_color", new Color(1, 1, 1, 0.7f));
AddChild(_label);
}
private ColorRect CreateBorderRect(Vector2 size, Vector2 pos)
{
var rect = new ColorRect
{
Size = size,
Position = pos,
Color = HoverOutlineColor,
Visible = false,
MouseFilter = Control.MouseFilterEnum.Ignore
};
AddChild(rect);
return rect;
}
public void SetLabel(string text) => _label.Text = text;
public void SetHighlight(bool on) => _highlight.Visible = on;
public void SetHover(bool on)
{
_hoverTop.Visible = on;
_hoverBottom.Visible = on;
_hoverLeft.Visible = on;
_hoverRight.Visible = on;
}
public void SetHighlightColor(Color color)
{
_highlight.Color = color;
_highlight.Visible = true;
}
/// <summary>
/// Production pulse: warm glow that radiates outward.
/// </summary>
public void FlashProduce(float duration = 0.3f)
{
_highlight.Color = new Color(0.9f, 0.85f, 0.5f, 0.55f); // warm golden
_highlight.Visible = true;
var tween = CreateTween();
tween.TweenProperty(_highlight, "color", new Color(0.9f, 0.85f, 0.5f, 0f), duration)
.SetEase(Tween.EaseType.Out).SetTrans(Tween.TransitionType.Cubic);
tween.TweenCallback(Callable.From(() => _highlight.Visible = false));
}
}