oldie/scenes/collectables/Energy.cs

26 lines
574 B
C#
Raw Normal View History

2022-11-10 00:17:42 -03:00
using Godot;
using System;
public class Energy : Area2D
{
2022-11-14 08:31:16 -03:00
private Event _eventBus;
2022-11-10 00:17:42 -03:00
public override void _Ready()
{
2022-11-14 08:31:16 -03:00
_eventBus = GetNode<Event>("/root/Event");
2022-11-10 00:17:42 -03:00
GetNode<AnimatedSprite>("AnimatedSprite").Play();
}
public void OnEnergyBodyEntered(Node body)
{
Disconnect("body_entered", this, "OnEnergyBodyEntered");
SetCollisionMaskBit((int) Game.PhysicsLayer.Player, false);
SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false);
if (String.Equals(body.Name, "Player"))
{
2022-11-14 08:31:16 -03:00
_eventBus.EmitSignal("EnergyCollected", 1);
2022-11-10 00:17:42 -03:00
}
QueueFree();
}
}