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

@ -995,7 +995,6 @@ metadata/_edit_lock_ = true
[node name="Right_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
position = Vector2(-16, -8)
scale = Vector2(1, 1)
texture = SubResource("AtlasTexture_vcc72")
centered = false
offset = Vector2(-2, -2)
@ -1003,7 +1002,6 @@ metadata/_edit_lock_ = true
[node name="Left_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"]
position = Vector2(-4, -9)
scale = Vector2(1, 1)
texture = SubResource("AtlasTexture_kto0i")
centered = false
offset = Vector2(-2, -2)

View file

@ -1,7 +1,6 @@
[gd_scene load_steps=16 format=3 uid="uid://bu0dh5ct387xu"]
[gd_scene load_steps=15 format=3 uid="uid://bu0dh5ct387xu"]
[ext_resource type="PackedScene" uid="uid://dd3yegl1xo44m" path="res://scenes/templates/level_template.tscn" id="1_vdv3d"]
[ext_resource type="Resource" uid="uid://br3364jty1j0i" path="res://resources/levels/test_level_for_execution.tres" id="2_bpfdr"]
[ext_resource type="Texture2D" uid="uid://b0tb2hjum40aw" path="res://assets/sprites/background_summer.png" id="3_lsqv3"]
[ext_resource type="Script" uid="uid://84gvlkflxdhk" path="res://scripts/level/zombe_spawners/RowSpawner.cs" id="4_kn7hc"]
[ext_resource type="Script" uid="uid://puqxp2xeg1r2" path="res://scripts/level/LevelRunner.cs" id="5_vbgdr"]
@ -270,7 +269,6 @@ libraries = {
}
[node name="Data" parent="." index="1" node_paths=PackedStringArray("levelRunner", "player")]
levelResource = ExtResource("2_bpfdr")
levelRunner = NodePath("../LevelRunner")
player = NodePath("../MainAnimationPlayer")

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;