Initial commit
This commit is contained in:
commit
c266d22f58
85 changed files with 1649 additions and 0 deletions
50
scripts/LevelController.cs
Normal file
50
scripts/LevelController.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
//
|
||||
// Class that gives access to level data, pools and etc.
|
||||
//
|
||||
|
||||
public partial class LevelController : Node
|
||||
{
|
||||
public static LevelController Instance { get; private set; }
|
||||
|
||||
private bool _isLevelRunning = false;
|
||||
|
||||
public RuntimeLevelData LevelData { get; set; }
|
||||
public PoolContainer Pools { get; set; }
|
||||
|
||||
public override void _EnterTree()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
Instance = null;
|
||||
}
|
||||
|
||||
public void StartLevel(PackedScene levelTileset, Script levelScript = null)
|
||||
{
|
||||
if (_isLevelRunning)
|
||||
return;
|
||||
|
||||
GetTree().ChangeSceneToPacked(levelTileset);
|
||||
|
||||
if (levelScript != null)
|
||||
GetTree().CurrentScene.SetScript(levelScript);
|
||||
|
||||
_isLevelRunning = true;
|
||||
}
|
||||
|
||||
public void EndLevel()
|
||||
{
|
||||
if (_isLevelRunning == false)
|
||||
return;
|
||||
|
||||
LevelData = null;
|
||||
Pools = null;
|
||||
|
||||
_isLevelRunning = false;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue