newlon/scripts/level/RuntimeLevelData.cs
2025-07-12 07:32:31 +05:00

62 lines
1.3 KiB
C#

using System;
using Godot;
namespace Newlon.Components.Level;
public partial class RuntimeLevelData : Node
{
public enum LevelStates
{
ChooseYourSeeds,
Pregame,
Game,
Win,
Loose
}
[Export]
public float SunCount { get; private set; } = 0;
public event Action<LevelStates> OnLevelStateChanged;
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;
}
#region Sun
public void AddSun(float amount)
{
SunCount += amount;
}
public void SpendSun(float amount)
{
SunCount -= amount;
}
public bool CheckSpendSun(float amount)
{
if (SunCount - amount < 0) return false;
return true;
}
#endregion
public void SetLevelState(LevelStates state)
{
OnLevelStateChanged(state);
_currentState = state;
}
//private Array<PlantResource> _selectedPlants;
//private bool _selected;
//public Array<PlantResource> GetSelectedPlants();
//public bool TrySelectPlants(Array<PlantResource>);
//public void ResetSelection();
}