oldie/scenes/game/Game.cs

44 lines
917 B
C#
Raw Normal View History

2022-11-10 00:05:28 -03:00
using Godot;
public sealed class Game : Node
{
[Export]
private int _energy { get; set; } = 3;
[Export]
private int _bolts { get; set; } = 0;
public enum PhysicsLayer : ushort
{
2022-11-10 00:05:28 -03:00
Player = 1,
Platform = 2,
Enemy = 3,
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");
eventBus.Connect("BoltCollected", this, "OnBoltCollected");
2022-11-10 00:05:28 -03:00
}
public void OnEnergyCollected(int energy)
2022-11-10 00:05:28 -03:00
{
_energy += energy;
if (OS.IsDebugBuild())
{
GD.Print("Energy: " + _energy);
}
}
public void OnBoltCollected(int bolts)
{
_bolts += bolts;
if (OS.IsDebugBuild())
{
GD.Print("Bolts: " + _bolts);
}
}
2022-11-10 00:05:28 -03:00
}