2022-11-10 00:05:28 -03:00
|
|
|
using Godot;
|
|
|
|
|
|
|
|
public sealed class Game : Node
|
|
|
|
{
|
|
|
|
[Export]
|
2022-11-20 17:08:32 -03:00
|
|
|
private int _energy = 3;
|
2022-11-10 00:05:28 -03:00
|
|
|
[Export]
|
2022-11-20 17:08:32 -03:00
|
|
|
private int _bolts = 0;
|
|
|
|
public int Energy { get { return _energy; } set { _energy = value; } }
|
|
|
|
public int Bolts { get { return _bolts; } set { _bolts = value; } }
|
2022-11-10 00:05:28 -03:00
|
|
|
|
2022-11-19 23:21:06 -03:00
|
|
|
public enum PhysicsLayer : ushort
|
|
|
|
{
|
2022-11-10 00:05:28 -03:00
|
|
|
Player = 1,
|
|
|
|
Platform = 2,
|
|
|
|
Enemy = 3,
|
2022-11-19 23:21:06 -03:00
|
|
|
Collectable = 4,
|
|
|
|
Checkpoint = 5
|
2022-11-10 00:05:28 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
public override void _Ready()
|
|
|
|
{
|
|
|
|
var eventBus = GetNode<Event>("/root/Event");
|
|
|
|
eventBus.Connect("EnergyCollected", this, "OnEnergyCollected");
|
2022-11-19 23:21:06 -03:00
|
|
|
eventBus.Connect("BoltCollected", this, "OnBoltCollected");
|
2022-11-10 00:05:28 -03:00
|
|
|
}
|
|
|
|
|
2022-11-19 23:21:06 -03:00
|
|
|
public void OnEnergyCollected(int energy)
|
2022-11-10 00:05:28 -03:00
|
|
|
{
|
|
|
|
_energy += energy;
|
|
|
|
}
|
2022-11-19 23:21:06 -03:00
|
|
|
|
|
|
|
public void OnBoltCollected(int bolts)
|
|
|
|
{
|
|
|
|
_bolts += bolts;
|
|
|
|
}
|
2022-11-10 00:05:28 -03:00
|
|
|
}
|