mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-09 12:45:55 +00:00
Exploding barrels
This commit is contained in:
parent
6a62fe2871
commit
71eeb3f1d1
12 changed files with 132 additions and 20 deletions
|
|
@ -7,6 +7,9 @@ public partial class Bullet : Area2D
|
|||
[Export]
|
||||
public float Speed = 1900f;
|
||||
|
||||
[Export]
|
||||
public float Damage = 1f;
|
||||
|
||||
private Vector2 _direction = Vector2.Right;
|
||||
|
||||
//public delegate void BulletHitEventHandler(Node Body);
|
||||
|
|
@ -53,15 +56,28 @@ public partial class Bullet : Area2D
|
|||
{
|
||||
if (body.IsInGroup("Solid"))
|
||||
{
|
||||
Debug.WriteLine("Collision");
|
||||
//Debug.WriteLine("Collision");
|
||||
QueueFree();
|
||||
}
|
||||
else if (body.IsInGroup("Destroyable"))
|
||||
{
|
||||
Debug.WriteLine("Collision with destroyable object body");
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void _on_area_entered(Area2D area)
|
||||
{
|
||||
// Replace with function body.
|
||||
if (area.IsInGroup("Destroyable") && area is IDestructible destructible)
|
||||
{
|
||||
//Debug.WriteLine("Collision with destroyable object area");
|
||||
|
||||
destructible.Hit(Damage);
|
||||
|
||||
QueueFree();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
6
Scripts/IDestructible.cs
Normal file
6
Scripts/IDestructible.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
|
||||
public interface IDestructible
|
||||
{
|
||||
public void Hit(float damage);
|
||||
public bool IsDestroyed();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue