2022-11-19 23:07:33 -03:00
|
|
|
using Godot;
|
|
|
|
using System;
|
|
|
|
|
|
|
|
public class Bolt : Area2D
|
|
|
|
{
|
2022-11-20 17:06:31 -03:00
|
|
|
[Export]
|
|
|
|
private int _value = 1;
|
2022-11-19 23:07:33 -03:00
|
|
|
private Event _eventBus;
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
_eventBus = GetNode<Event>("/root/Event");
|
|
|
|
GetNode<AnimatedSprite>("AnimatedSprite").Play();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnBoltBodyEntered(Node body)
|
|
|
|
{
|
|
|
|
Disconnect("body_entered", this, "OnBoltBodyEntered");
|
|
|
|
SetCollisionMaskBit((int) Game.PhysicsLayer.Player, false);
|
|
|
|
SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false);
|
|
|
|
if (String.Equals(body.Name, "Player"))
|
|
|
|
{
|
2022-11-20 17:06:31 -03:00
|
|
|
Collected();
|
2022-11-19 23:07:33 -03:00
|
|
|
}
|
2022-11-20 17:06:31 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Collected()
|
|
|
|
{
|
|
|
|
_eventBus.EmitSignal("BoltCollected", _value);
|
2022-11-19 23:07:33 -03:00
|
|
|
QueueFree();
|
|
|
|
}
|
|
|
|
}
|