46 lines
959 B
C#
46 lines
959 B
C#
using Godot;
|
|
using Newlon.Components.GUI.Seedpackets;
|
|
|
|
public partial class AlmanachGrid : GridContainer
|
|
{
|
|
private PackedScene _plantCard;
|
|
[Export]
|
|
private bool _zombies;
|
|
public override void _Ready()
|
|
{
|
|
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
|
|
|
if (_zombies)
|
|
{
|
|
var list = GameRegistry.GetZombies();
|
|
list.Sort((a, b) =>
|
|
{
|
|
return a.Order - b.Order;
|
|
});
|
|
foreach (var resource in list)
|
|
{
|
|
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
|
AddChild(slot);
|
|
|
|
slot.SetResource(resource);
|
|
slot.SetHandler(new AlmanachHandler(slot));
|
|
}
|
|
}
|
|
else
|
|
{
|
|
var list = GameRegistry.GetPlants();
|
|
list.Sort((a, b) =>
|
|
{
|
|
return a.Order - b.Order;
|
|
});
|
|
foreach (var resource in list)
|
|
{
|
|
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
|
AddChild(slot);
|
|
|
|
slot.SetResource(resource);
|
|
slot.SetHandler(new AlmanachHandler(slot));
|
|
}
|
|
}
|
|
}
|
|
}
|