AceField/Scripts/Brick.cs
2024-08-09 02:20:56 +08:00

32 lines
663 B
C#

using Godot;
namespace AceField.Scripts;
public partial class Brick : StaticBody2D
{
[Export] public int MaxDecayProgress = 50;
[Export] public int DecayProgress;
[Export] public int PlayerId;
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)
{
if(DecayProgress <= 0) QueueFree();
var sprite = GetNode<Sprite2D>("Sprite2D");
sprite.SelfModulate = new Color(sprite.SelfModulate, (float)DecayProgress / MaxDecayProgress);
}
}