add bolt and checkpoint logic to the main game logic
This commit is contained in:
parent
1be2ce548a
commit
8625181b1a
@ -7,20 +7,23 @@ public sealed class Game : Node
|
||||
[Export]
|
||||
private int _bolts { get; set; } = 0;
|
||||
|
||||
public enum PhysicsLayer : ushort {
|
||||
public enum PhysicsLayer : ushort
|
||||
{
|
||||
Player = 1,
|
||||
Platform = 2,
|
||||
Enemy = 3,
|
||||
Collectable = 4
|
||||
Collectable = 4,
|
||||
Checkpoint = 5
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var eventBus = GetNode<Event>("/root/Event");
|
||||
eventBus.Connect("EnergyCollected", this, "OnEnergyCollected");
|
||||
eventBus.Connect("BoltCollected", this, "OnBoltCollected");
|
||||
}
|
||||
|
||||
private void OnEnergyCollected(int energy)
|
||||
public void OnEnergyCollected(int energy)
|
||||
{
|
||||
_energy += energy;
|
||||
if (OS.IsDebugBuild())
|
||||
@ -28,4 +31,13 @@ public sealed class Game : Node
|
||||
GD.Print("Energy: " + _energy);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnBoltCollected(int bolts)
|
||||
{
|
||||
_bolts += bolts;
|
||||
if (OS.IsDebugBuild())
|
||||
{
|
||||
GD.Print("Bolts: " + _bolts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user