Almanach
This commit is contained in:
parent
008fa31dd4
commit
b932e82555
39 changed files with 575 additions and 78 deletions
36
scripts/components/gui/almanach/AlmanachGrid.cs
Normal file
36
scripts/components/gui/almanach/AlmanachGrid.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
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)
|
||||
{
|
||||
foreach (var resource in GameRegistry.GetZombies())
|
||||
{
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetResource(resource);
|
||||
slot.SetHandler(new AlmanachHandler(slot));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var resource in GameRegistry.GetPlants())
|
||||
{
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetResource(resource);
|
||||
slot.SetHandler(new AlmanachHandler(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/components/gui/almanach/AlmanachGrid.cs.uid
Normal file
1
scripts/components/gui/almanach/AlmanachGrid.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0mvmfvwe1bc7
|
||||
|
|
@ -17,7 +17,7 @@ public partial class GridLoader : GridContainer
|
|||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetPlantResource(resource);
|
||||
slot.SetResource(resource);
|
||||
slot.SetHandler(new ChoosableHandler(slot));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
using Godot;
|
||||
using Newlon;
|
||||
using Newlon.Components;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
using Newlon.Components.Plants;
|
||||
|
||||
public partial class Previewport : SubViewport
|
||||
{
|
||||
private RuntimePlantData current_display;
|
||||
private Node current_display;
|
||||
private Texture2D start_Field;
|
||||
|
||||
[Export] private Label title;
|
||||
|
|
@ -19,13 +20,14 @@ public partial class Previewport : SubViewport
|
|||
|
||||
public void OnFocusChanged(Control node)
|
||||
{
|
||||
if (GetParent<Control>().IsVisibleInTree() == false) return;
|
||||
if (node is Seedpacket packet)
|
||||
{
|
||||
ChangeDisplay(packet.GetPlantResource());
|
||||
ChangeDisplay(packet.GetResource());
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeDisplay(PlantResource resource)
|
||||
private void ChangeDisplay(DisplayResource resource)
|
||||
{
|
||||
// Expand with updates
|
||||
if (current_display != null)
|
||||
|
|
@ -38,11 +40,12 @@ public partial class Previewport : SubViewport
|
|||
}
|
||||
else
|
||||
GetNode<Sprite2D>("FrameField").Texture = start_Field;
|
||||
current_display = resource.Scene.Instantiate<RuntimePlantData>();
|
||||
current_display = resource.Scene.Instantiate();
|
||||
title.Text = resource.display_name;
|
||||
description.Text = resource.display_description;
|
||||
AddChild(current_display);
|
||||
current_display.DisableBrain();
|
||||
if (current_display is IEntity entity)
|
||||
entity.DisableBrain();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
10
scripts/components/gui/seedpackets/AlmanachHandler.cs
Normal file
10
scripts/components/gui/seedpackets/AlmanachHandler.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using Godot;
|
||||
|
||||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public class AlmanachHandler : SeedpacketHandler
|
||||
{
|
||||
public AlmanachHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
uid://pse018r220mt
|
||||
|
|
@ -13,7 +13,7 @@ public class ChoosableHandler : SeedpacketHandler, ISeedpacketPress
|
|||
|
||||
var hotbarSeedpacket = Seedpacket.Prefab.Instantiate<Seedpacket>();
|
||||
LevelGUIElements.Instance.SeedpacketsHotbar.AddChild(hotbarSeedpacket);
|
||||
hotbarSeedpacket.SetPlantResource(_owner.GetPlantResource());
|
||||
hotbarSeedpacket.SetResource(_owner.GetResource());
|
||||
|
||||
var pregameHandler = new HotbarPregameHandler(hotbarSeedpacket);
|
||||
hotbarSeedpacket.SetHandler(pregameHandler);
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ public class HotbarHandler : SeedpacketHandler, ISeedpacketPress, ISeedpacketPro
|
|||
|
||||
public void Pressed()
|
||||
{
|
||||
PlantField.Instance.SetPlant(_owner, _owner.GetPlantResource());
|
||||
PlantField.Instance.SetPlant(_owner, _owner.GetResource());
|
||||
AudioSequencer.Play("lift_seed", Seedpacket.LiftStream);
|
||||
}
|
||||
|
||||
public void Process()
|
||||
{
|
||||
_owner.disablePacket = RuntimeLevelData.Instance.SunCount < _owner.GetPlantResource().Cost;
|
||||
_owner.disablePacket = RuntimeLevelData.Instance.SunCount < _owner.GetResource().Cost;
|
||||
}
|
||||
public void OnUnfocused()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ public partial class Seedpacket : TextureButton
|
|||
public static AudioStream UntapStream;
|
||||
public static AudioStream LiftStream;
|
||||
private const string PATH_TO_PACKED_SCENE = "res://scenes/gui/seedpacket.tscn";
|
||||
private PlantResource _resource;
|
||||
private DisplayResource _resource;
|
||||
private Label _cost;
|
||||
private TextureRect _icon;
|
||||
private Timer _timer;
|
||||
|
|
@ -50,14 +50,14 @@ public partial class Seedpacket : TextureButton
|
|||
}
|
||||
if (_handler is ISeedpacketProcess processHandler) processHandler.Process();
|
||||
}
|
||||
public void SetPlantResource( PlantResource resource )
|
||||
public void SetResource(DisplayResource resource )
|
||||
{
|
||||
_resource = resource;
|
||||
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
public PlantResource GetPlantResource()
|
||||
public DisplayResource GetResource()
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue