cirnogodot/Scenes/Barrel.cs
2024-06-09 00:34:36 +02:00

48 lines
782 B
C#

using Godot;
using System;
using System.Diagnostics;
public partial class Barrel : Area2D, IDestructible
{
[Export]
public float Health = 1f;
[Export]
public float ExplosionRadius = 1;
private float _currentHealth;
private bool _isDestroyed = false;
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
_currentHealth = Health;
}
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}
public void Explode() {
Debug.WriteLine("Boom");
QueueFree();
}
public void Hit(float damage)
{
if (_isDestroyed) return;
_isDestroyed = true;
Explode();
// TODO: Change sprite
}
public bool IsDestroyed()
{
return _isDestroyed;
}
}