give bolts a value and a callable function

This commit is contained in:
Chris Cromer 2022-11-20 17:06:31 -03:00
parent 19ad48328a
commit d517be7b43

View File

@ -3,6 +3,8 @@ using System;
public class Bolt : Area2D public class Bolt : Area2D
{ {
[Export]
private int _value = 1;
private Event _eventBus; private Event _eventBus;
public override void _Ready() public override void _Ready()
@ -18,8 +20,13 @@ public class Bolt : Area2D
SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false); SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false);
if (String.Equals(body.Name, "Player")) if (String.Equals(body.Name, "Player"))
{ {
_eventBus.EmitSignal("BoltCollected", 1); Collected();
} }
}
public void Collected()
{
_eventBus.EmitSignal("BoltCollected", _value);
QueueFree(); QueueFree();
} }
} }