Level Data decentralization

This commit is contained in:
Фёдор Веселов 2024-09-22 20:36:13 +05:00
commit e3613b132e
12 changed files with 52 additions and 28 deletions

View file

@ -1,17 +1,33 @@
using System;
using Godot;
//using Godot.Collections;
using System;
public partial class RuntimeLevelData : Node
{
public enum LevelStates
{
ChooseYourSeeds,
Pregame,
Game,
Win,
Loose
}
[Export]
public int 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()
{
LevelController.Instance.LevelData = this;
Instance = this;
GetTree().Paused = true;
}
#region Sun
public void AddSun(int amount)
{
SunCount += amount;
@ -27,6 +43,13 @@ public partial class RuntimeLevelData : Node
return true;
}
#endregion
public void SetLevelState(LevelStates state)
{
OnLevelStateChanged(state);
_currentState = state;
}
//private Array<PlantResource> _selectedPlants;
//private bool _selected;