Simplified level load and Utitility.Seedpackets

This commit is contained in:
Rendo 2025-07-17 11:19:09 +05:00
commit 3a5154f051
7 changed files with 15 additions and 31 deletions

View file

@ -31,12 +31,8 @@ public partial class LevelController : Node
{
if (_isLevelRunning)
return;
GetTree().CreateTimer(0.001).Timeout += ()=>
{
RuntimeLevelData.Instance.levelResource = levelResource;
RuntimeLevelData.Instance.StartLevel();
};
RuntimeLevelData.LevelResource = levelResource;
GetTree().ChangeSceneToPacked(levelTileset);
@ -48,7 +44,8 @@ public partial class LevelController : Node
{
if (_isLevelRunning == false)
return;
RuntimeLevelData.LevelResource = null;
_isLevelRunning = false;
}
}

View file

@ -9,16 +9,6 @@ namespace Newlon;
public class Utility
{
//
// Code-accessed enumenators
//
#region Enums
public enum EffectSlots { FREEZE, STUN, POISON, GARLIC };
public enum DamageTypes { PHYSICAL, ICE };
#endregion
public const int EffectSlotCount = 4;
public const int LineCount = 5;
@ -32,6 +22,6 @@ public class Utility
public static double SFX = 1.0f;
public static double Music = 1.0f;
public static bool Splash = false;
public static int MaxSeedpackets = 9;
}

View file

@ -39,7 +39,7 @@ public partial class ZombieLevelPreviewer : Node2D
{
List<ZombieResource> zombies = new();
foreach (var wave in RuntimeLevelData.Instance.levelResource.waves)
foreach (var wave in RuntimeLevelData.LevelResource.waves)
{
foreach (var spawn in wave.zombiesOrdered)
{

View file

@ -8,7 +8,7 @@ public class ChoosableHandler : SeedpacketHandler, ISeedpacketPress
public void Pressed()
{
if (LevelGUIElements.Instance.SeedpacketsHotbar.GetChildCount() > 9) return;
if (LevelGUIElements.Instance.SeedpacketsHotbar.GetChildCount() >= Utility.MaxSeedpackets) return;
_owner.disablePacket = true;
var hotbarSeedpacket = Seedpacket.Prefab.Instantiate<Seedpacket>();

View file

@ -17,8 +17,6 @@ public partial class RuntimeLevelData : Node
[Export]
public float SunCount { get; private set; } = 0;
[Export]
public AdventureLevelResource levelResource;
[Export]
private LevelRunner levelRunner;
[Export]
private AnimationPlayer player;
@ -26,6 +24,7 @@ public partial class RuntimeLevelData : Node
public delegate void OnLevelStateChangedEventHandler(LevelStates state);
public static RuntimeLevelData Instance { get; private set; }
public static AdventureLevelResource LevelResource { get; set; }
private LevelStates _currentState = LevelStates.ChooseYourSeeds;
@ -36,9 +35,6 @@ public partial class RuntimeLevelData : Node
Instance = this;
GetTree().Paused = true;
Engine.TimeScale = 1.0;
}
public void StartLevel()
{
SetLevelState(LevelStates.ChooseYourSeeds);
}
#region Sun
@ -76,7 +72,7 @@ public partial class RuntimeLevelData : Node
break;
case LevelStates.Game:
GetTree().Paused = false;
levelRunner.SetLevelResource(levelResource);
levelRunner.SetLevelResource(LevelResource);
break;
case LevelStates.Win:
break;
@ -88,6 +84,11 @@ public partial class RuntimeLevelData : Node
{
return _currentState;
}
public override void _ExitTree()
{
LevelController.Instance.EndLevel();
}
//private Array<PlantResource> _selectedPlants;
//private bool _selected;