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; [Export] private LevelRunner levelRunner; [Export] private AnimationPlayer player; [Signal] public delegate void OnLevelStateChangedEventHandler(LevelStates state); public static RuntimeLevelData Instance { get; private set; } public static AdventureLevelResource LevelResource { get; set; } private LevelStates _currentState = LevelStates.ChooseYourSeeds; public override void _Ready() { Instance = this; Engine.TimeScale = 1.0; SetLevelState(LevelStates.ChooseYourSeeds); } #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) { 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; } public override void _ExitTree() { LevelController.Instance.EndLevel(); } //private Array _selectedPlants; //private bool _selected; //public Array GetSelectedPlants(); //public bool TrySelectPlants(Array); //public void ResetSelection(); }