✨ New sfx and vfx and features in building
This commit is contained in:
@@ -14,6 +14,7 @@ public partial class BaseTile : Node2D
|
||||
private Sprite2D _sprite;
|
||||
private ColorRect _progressOverlay;
|
||||
private Action _onConstructionComplete;
|
||||
private bool _isConstructing = false;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -26,6 +27,9 @@ public partial class BaseTile : Node2D
|
||||
|
||||
public void SetGhostMode(bool canPlace)
|
||||
{
|
||||
// Don't modify collision for constructing buildings
|
||||
if (_isConstructing) return;
|
||||
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = true;
|
||||
|
||||
@@ -46,8 +50,13 @@ public partial class BaseTile : Node2D
|
||||
// Building progress visualization
|
||||
public void StartConstruction(float buildTime, Action onComplete = null)
|
||||
{
|
||||
_isConstructing = true;
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = true;
|
||||
|
||||
if (_progressOverlay == null || _sprite?.Texture == null)
|
||||
{
|
||||
_isConstructing = false;
|
||||
onComplete?.Invoke();
|
||||
return;
|
||||
}
|
||||
@@ -55,6 +64,10 @@ public partial class BaseTile : Node2D
|
||||
_onConstructionComplete = onComplete;
|
||||
var texSize = new Vector2(GridUtils.TileSize, GridUtils.TileSize);
|
||||
|
||||
// Set initial transparency for construction
|
||||
if (_sprite != null)
|
||||
_sprite.Modulate = new Color(1, 1, 1, 0.8f);
|
||||
|
||||
_progressOverlay.Visible = true;
|
||||
_progressOverlay.Modulate = Colors.White;
|
||||
_progressOverlay.Color = new Color(0, 0, 1, 0.4f); // semi-transparent blue
|
||||
@@ -80,7 +93,14 @@ public partial class BaseTile : Node2D
|
||||
// Fade out the overlay
|
||||
await FadeOutOverlay(0.5f);
|
||||
|
||||
// Notify completion
|
||||
// Construction complete - restore full opacity and enable collision
|
||||
if (_sprite != null)
|
||||
_sprite.Modulate = Colors.White;
|
||||
|
||||
_isConstructing = false;
|
||||
if (_collisionShape != null)
|
||||
_collisionShape.Disabled = false;
|
||||
|
||||
_onConstructionComplete?.Invoke();
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user