AceField/Scripts/Brick.cs

32 lines
663 B
C#
Raw Permalink Normal View History

2024-08-08 16:42:22 +00:00
using Godot;
namespace AceField.Scripts;
public partial class Brick : StaticBody2D
{
[Export] public int MaxDecayProgress = 50;
[Export] public int DecayProgress;
2024-08-08 18:20:56 +00:00
[Export] public int PlayerId;
2024-08-08 16:42:22 +00:00
public override void _Ready()
{
DecayProgress = MaxDecayProgress;
GetNode<Timer>("DecayTimer").Timeout += () =>
{
DecayProgress--;
if (DecayProgress > 0) return;
GetNode<Timer>("DecayTimer").Stop();
};
}
public override void _Process(double delta)
{
2024-08-08 18:20:56 +00:00
if(DecayProgress <= 0) QueueFree();
2024-08-08 16:42:22 +00:00
var sprite = GetNode<Sprite2D>("Sprite2D");
sprite.SelfModulate = new Color(sprite.SelfModulate, (float)DecayProgress / MaxDecayProgress);
}
}