mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 08:55:35 +00:00
48 lines
782 B
C#
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;
|
|
}
|
|
|
|
}
|