droppable items and win
This commit is contained in:
parent
0f6445d677
commit
5bdbfa4d82
47 changed files with 820 additions and 85 deletions
|
|
@ -9,7 +9,10 @@ namespace Newlon;
|
|||
|
||||
public partial class LevelController : Node
|
||||
{
|
||||
const string REWARD_SCENE_UID = "uid://cwck7e1tt057k";
|
||||
public static LevelController Instance { get; private set; }
|
||||
public RewardResource Reward { get; private set; }
|
||||
private string pathToInitiator;
|
||||
|
||||
private bool _isLevelRunning = false;
|
||||
|
||||
|
|
@ -17,7 +20,7 @@ public partial class LevelController : Node
|
|||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
Instance = null;
|
||||
|
|
@ -31,12 +34,13 @@ public partial class LevelController : Node
|
|||
{
|
||||
if (_isLevelRunning)
|
||||
return;
|
||||
|
||||
|
||||
pathToInitiator = GetTree().CurrentScene.SceneFilePath;
|
||||
RuntimeLevelData.LevelResource = levelResource;
|
||||
|
||||
GetTree().ChangeSceneToPacked(levelTileset);
|
||||
|
||||
|
||||
|
||||
|
||||
_isLevelRunning = true;
|
||||
}
|
||||
public void RestartLevel()
|
||||
|
|
@ -49,8 +53,32 @@ public partial class LevelController : Node
|
|||
{
|
||||
if (_isLevelRunning == false)
|
||||
return;
|
||||
|
||||
|
||||
RuntimeLevelData.LevelResource = null;
|
||||
|
||||
_isLevelRunning = false;
|
||||
|
||||
if (Reward != null)
|
||||
{
|
||||
GetTree().ChangeSceneToFile(REWARD_SCENE_UID);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReturnToInitiator();
|
||||
}
|
||||
}
|
||||
public void ReturnToInitiator()
|
||||
{
|
||||
if (pathToInitiator == null) return;
|
||||
|
||||
GetTree().ChangeSceneToFile(pathToInitiator);
|
||||
|
||||
pathToInitiator = null;
|
||||
}
|
||||
|
||||
public void SetReward(RewardResource reward)
|
||||
{
|
||||
Reward = reward;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue