mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-18 11:13:47 +00:00
Exploding barrels
This commit is contained in:
parent
6a62fe2871
commit
71eeb3f1d1
12 changed files with 132 additions and 20 deletions
48
Scenes/Barrel.cs
Normal file
48
Scenes/Barrel.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
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;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue