Level runners

This commit is contained in:
Rendo 2025-07-16 20:17:58 +05:00
commit 5010c61309
11 changed files with 398 additions and 110 deletions

View file

@ -18,17 +18,25 @@ public partial class RuntimeLevelData : Node
public float SunCount { get; private set; } = 0;
[Export]
public AdventureLevelResource levelResource;
public event Action<LevelStates> OnLevelStateChanged;
[Export]
private LevelRunner levelRunner;
[Export]
private AnimationPlayer player;
[Signal]
public delegate void OnLevelStateChangedEventHandler(LevelStates state);
public static RuntimeLevelData Instance { get; private set; }
private LevelStates _currentState = LevelStates.ChooseYourSeeds;
public override void _Ready()
{
Instance = this;
GetTree().Paused = true;
Engine.TimeScale = 1.0;
SetLevelState(LevelStates.ChooseYourSeeds);
}
#region Sun
@ -52,8 +60,31 @@ public partial class RuntimeLevelData : Node
public void SetLevelState(LevelStates state)
{
OnLevelStateChanged(state);
EmitSignal(SignalName.OnLevelStateChanged, (int)state);
_currentState = state;
switch (_currentState)
{
case LevelStates.ChooseYourSeeds:
player.Play("CYS_Sequence");
break;
case LevelStates.Pregame:
player.Play("PG_Sequence");
break;
case LevelStates.Game:
GetTree().Paused = false;
levelRunner.SetLevelResource(levelResource);
break;
case LevelStates.Win:
break;
case LevelStates.Loose:
break;
}
}
public LevelStates GetLevelState()
{
return _currentState;
}
//private Array<PlantResource> _selectedPlants;