add Game autoload scene
This commit is contained in:
parent
3f9c21c5b4
commit
d0c685a2b2
@ -17,7 +17,8 @@ config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
||||
Event="*res://scenes/Event.cs"
|
||||
Event="*res://scripts/Event.cs"
|
||||
Game="*res://scenes/game/Game.tscn"
|
||||
|
||||
[display]
|
||||
|
||||
|
31
scenes/game/Game.cs
Normal file
31
scenes/game/Game.cs
Normal file
@ -0,0 +1,31 @@
|
||||
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 {
|
||||
Player = 1,
|
||||
Platform = 2,
|
||||
Enemy = 3,
|
||||
Collectable = 4
|
||||
}
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
var eventBus = GetNode<Event>("/root/Event");
|
||||
eventBus.Connect("EnergyCollected", this, "OnEnergyCollected");
|
||||
}
|
||||
|
||||
private void OnEnergyCollected(int energy)
|
||||
{
|
||||
_energy += energy;
|
||||
if (OS.IsDebugBuild())
|
||||
{
|
||||
GD.Print("Energy: " + _energy);
|
||||
}
|
||||
}
|
||||
}
|
6
scenes/game/Game.tscn
Normal file
6
scenes/game/Game.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://scenes/game/Game.cs" type="Script" id=1]
|
||||
|
||||
[node name="Game" type="Node"]
|
||||
script = ExtResource( 1 )
|
Loading…
Reference in New Issue
Block a user