oldie/scenes/collectables/Energy.cs

26 lines
557 B
C#
Raw Normal View History

2022-11-10 00:17:42 -03:00
using Godot;
using System;
public class Energy : Area2D
{
2022-11-21 02:15:26 -03:00
private Event _event;
2022-11-10 00:17:42 -03:00
public override void _Ready()
{
2022-11-21 02:15:26 -03:00
_event = GetNode<Event>("/root/Event");
2022-11-21 02:20:18 -03:00
GetNode<AnimatedSprite>("AnimatedSprite").Play();
2022-11-10 00:17:42 -03:00
}
public void OnEnergyBodyEntered(Node body)
{
Disconnect("body_entered", this, "OnEnergyBodyEntered");
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-10 00:17:42 -03:00
{
2022-11-21 02:15:26 -03:00
_event.EmitSignal("EnergyCollected", 1);
2022-11-10 00:17:42 -03:00
}
QueueFree();
}
}