Debug zombie spawner
This commit is contained in:
parent
116ebff0c2
commit
0fff33d196
69 changed files with 564 additions and 100 deletions
|
|
@ -12,19 +12,13 @@ public partial class GridLoader : GridContainer
|
|||
{
|
||||
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
||||
|
||||
string[] files = DirAccess.GetFilesAt(PLANT_RESOURCE_PATH);
|
||||
|
||||
foreach(var file in files)
|
||||
foreach(var resource in GameRegistry.GetPlants())
|
||||
{
|
||||
if(ResourceLoader.Exists(PLANT_RESOURCE_PATH+file))
|
||||
{
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetPlantResource(ResourceLoader.Load<PlantResource>(PLANT_RESOURCE_PATH+file));
|
||||
slot.SetHandler(new ChoosableHandler(slot));
|
||||
}
|
||||
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetPlantResource(resource);
|
||||
slot.SetHandler(new ChoosableHandler(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ namespace Newlon.Components.Level;
|
|||
// Is not pool in traditional sense, but named like that to prevent repetition
|
||||
//
|
||||
|
||||
public partial class PoolContainer : Node
|
||||
public partial class PoolContainer : Node2D
|
||||
{
|
||||
[Export]
|
||||
public Node2D Zombies { get; private set; }
|
||||
|
|
|
|||
63
scripts/components/level/zombe_spawners/ZombieSequencer.cs
Normal file
63
scripts/components/level/zombe_spawners/ZombieSequencer.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
using Newlon;
|
||||
using Newlon.Components.Level;
|
||||
using Newlon.Components.Zombies;
|
||||
|
||||
public partial class ZombieSequencer : Node2D
|
||||
{
|
||||
public static ZombieSequencer Instance { get; private set; }
|
||||
private Queue<string> queue = [];
|
||||
private RandomNumberGenerator rng = new();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
rng.Randomize();
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
|
||||
private void FormSquad()
|
||||
{
|
||||
if (queue.Count == 0) return;
|
||||
int count = rng.RandiRange(1, queue.Count > 5 ? 5 : queue.Count);
|
||||
|
||||
if (count == 5)
|
||||
{
|
||||
Spawn(queue.Dequeue(), 1);
|
||||
Spawn(queue.Dequeue(), 2);
|
||||
Spawn(queue.Dequeue(), 3);
|
||||
Spawn(queue.Dequeue(), 4);
|
||||
Spawn(queue.Dequeue(), 5);
|
||||
}
|
||||
|
||||
List<int> list = [];
|
||||
while (list.Count < count)
|
||||
{
|
||||
int lane = rng.RandiRange(1, 5);
|
||||
if (list.Contains(lane) == true)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(lane);
|
||||
}
|
||||
|
||||
foreach (int lane in list)
|
||||
{
|
||||
Spawn(queue.Dequeue(), lane);
|
||||
}
|
||||
}
|
||||
|
||||
private void Spawn(string id, int lane)
|
||||
{
|
||||
RuntimeZombieData zombie = GameRegistry.GetZombieByName(id).scene.Instantiate<RuntimeZombieData>();
|
||||
PoolContainer.Instance.Zombies.AddChild(zombie);
|
||||
|
||||
zombie.GlobalPosition = new Vector2(GlobalPosition.X, Utility.RightFieldBoundary.Y - (lane-1) * Utility.TileHeight);
|
||||
}
|
||||
|
||||
public void Add(string id)
|
||||
{
|
||||
queue.Enqueue(id);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://bsuw5lvnr3kol
|
||||
|
|
@ -4,7 +4,7 @@ namespace Newlon.Components.Plants;
|
|||
|
||||
public partial class PlantEyesightLimiter : CollisionShape2D
|
||||
{
|
||||
public override void _Ready()
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (Shape is SegmentShape2D segment)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ public partial class AloeBehaviour : BaseBehaviour
|
|||
if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
|
||||
{
|
||||
plantData.Heal(3000 + 25 * plantData.MaxHp, GetParent());
|
||||
GD.Print("IM TRYING");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,6 @@ public partial class EatBox : Area2D
|
|||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
GD.Print(parent.Name);
|
||||
|
||||
if (parent != null && parent is RuntimePlantData plantData)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ public partial class ZombieMover : Node
|
|||
* Utility.TileWidth
|
||||
* GetParent<RuntimeZombieData>().LocalTimescale
|
||||
* _speed.GetValue();
|
||||
GD.Print(_speed.GetMult());
|
||||
}
|
||||
|
||||
public void SetSpeedFlat(float speed)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue