oldie/scenes/collectables/Bolt.cs

33 lines
654 B
C#
Raw Permalink Normal View History

2022-11-19 23:07:33 -03:00
using Godot;
using System;
public class Bolt : Area2D
{
[Export]
private int _value = 1;
2022-11-21 02:15:26 -03:00
private Event _event;
2022-11-19 23:07:33 -03:00
public override void _Ready()
{
2022-11-21 02:15:26 -03:00
_event = GetNode<Event>("/root/Event");
2022-11-19 23:07:33 -03:00
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);
2022-11-21 02:20:18 -03:00
if (body.Name.Equals("Player"))
2022-11-19 23:07:33 -03:00
{
Collected();
2022-11-19 23:07:33 -03:00
}
}
public void Collected()
{
2022-11-21 02:15:26 -03:00
_event.EmitSignal("BoltCollected", _value);
2022-11-19 23:07:33 -03:00
QueueFree();
}
}