refactor bolt and energy
This commit is contained in:
parent
b6a5a1f829
commit
63e4527fce
@ -18,7 +18,7 @@ public class Bolt : Area2D
|
||||
Disconnect("body_entered", this, "OnBoltBodyEntered");
|
||||
SetCollisionMaskBit((int) Game.PhysicsLayer.Player, false);
|
||||
SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false);
|
||||
if (String.Equals(body.Name, "Player"))
|
||||
if (body.Name.Equals("Player"))
|
||||
{
|
||||
Collected();
|
||||
}
|
||||
|
@ -4,12 +4,11 @@ using System;
|
||||
public class Energy : Area2D
|
||||
{
|
||||
private Event _event;
|
||||
private AnimatedSprite _sprite;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_event = GetNode<Event>("/root/Event");
|
||||
_sprite = GetNode<AnimatedSprite>("AnimatedSprite");
|
||||
GetNode<AnimatedSprite>("AnimatedSprite").Play();
|
||||
}
|
||||
|
||||
public void OnEnergyBodyEntered(Node body)
|
||||
@ -17,20 +16,10 @@ public class Energy : Area2D
|
||||
Disconnect("body_entered", this, "OnEnergyBodyEntered");
|
||||
SetCollisionMaskBit((int) Game.PhysicsLayer.Player, false);
|
||||
SetCollisionLayerBit((int) Game.PhysicsLayer.Collectable, false);
|
||||
if (String.Equals(body.Name, "Player"))
|
||||
if (body.Name.Equals("Player"))
|
||||
{
|
||||
_event.EmitSignal("EnergyCollected", 1);
|
||||
}
|
||||
QueueFree();
|
||||
}
|
||||
|
||||
public void OnVisibilityNotifier2DScreenEntered()
|
||||
{
|
||||
_sprite.Play();
|
||||
}
|
||||
|
||||
public void OnVisibilityNotifier2DScreenExited()
|
||||
{
|
||||
_sprite.Stop();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user