Lockable seeds

This commit is contained in:
Rendo 2025-07-22 03:23:46 +05:00
commit a4c58bb245
19 changed files with 405 additions and 61 deletions

View file

@ -28,7 +28,7 @@ public partial class AlmanachGrid : GridContainer
}
else
{
var list = PlayerProgress.Instance.PlayerPlants;
var list = GameRegistry.GetPlants();
list.Sort((a, b) =>
{
return a.Order - b.Order;
@ -39,6 +39,7 @@ public partial class AlmanachGrid : GridContainer
AddChild(slot);
slot.SetResource(resource);
slot.SetLocked(PlayerProgress.Instance.PlayerPlants.Contains(resource) == false);
slot.SetHandler(new AlmanachHandler(slot));
}
}

View file

@ -1,5 +1,6 @@
using Godot;
using Newlon.Components.GUI.Seedpackets;
using Newlon.Components.Level;
namespace Newlon.Components.GUI;
@ -11,7 +12,7 @@ public partial class GridLoader : GridContainer
{
_plantCard = ResourceLoader.Load<PackedScene>(SEEDPACKED_UID);
var list = PlayerProgress.Instance.PlayerPlants;
var list = GameRegistry.GetPlants();
list.Sort((a, b) =>
{
return a.Order - b.Order;
@ -22,7 +23,10 @@ public partial class GridLoader : GridContainer
AddChild(slot);
slot.SetResource(resource);
slot.SetHandler(new ChoosableHandler(slot));
slot.SetForbidden(RuntimeLevelData.LevelResource.forbiddenPlants.Contains(resource.internal_id));
slot.SetLocked(PlayerProgress.Instance.PlayerPlants.Contains(resource) == false);
var handler = new ChoosableHandler(slot);
slot.SetHandler(handler);
}
}
}

View file

@ -2,7 +2,7 @@ extends Node
func _on_play_button_pressed() -> void:
LevelController.call("StartLevel",preload("uid://dd3yegl1xo44m"),preload("uid://ds2js2vylygvy"))
LevelController.call("StartLevel",preload("uid://dd3yegl1xo44m"),preload("uid://dwd5oqr0tuvhv"))
$ChannelPlayer.call("Play")

View file

@ -18,7 +18,6 @@ public class ChoosableHandler : SeedpacketHandler, ISeedpacketPress
var pregameHandler = new HotbarPregameHandler(hotbarSeedpacket);
hotbarSeedpacket.SetHandler(pregameHandler);
pregameHandler.Clicked += OnHotbarClicked;
AudioSequencer.Play("tap", Seedpacket.TapStream);
}

View file

@ -16,6 +16,6 @@ public partial class CostVeil : ColorRect
{
//Visible = RuntimeLevelData.Instance.SunCount < packet.GetResource().Cost;
Visible = packet.disablePacket;
Visible = packet.disablePacket || packet._forbidden;
}
}

View file

@ -13,6 +13,8 @@ public partial class Seedpacket : TextureButton
private TextureRect _icon;
private Timer _timer;
private SeedpacketHandler _handler;
public bool _forbidden;
public bool _locked;
public bool disablePacket = false;
@ -22,7 +24,7 @@ public partial class Seedpacket : TextureButton
public override void _Ready()
{
if (_resource != null)
UpdateContents();
UpdateContents();
if (Prefab == null)
{
Prefab = ResourceLoader.Load<PackedScene>(PATH_TO_PACKED_SCENE);
@ -44,10 +46,10 @@ public partial class Seedpacket : TextureButton
}
if (_handler is ISeedpacketProcess processHandler) processHandler.Process();
}
public void SetResource(DisplayResource resource )
public void SetResource(DisplayResource resource)
{
_resource = resource;
UpdateContents();
}
@ -77,6 +79,7 @@ public partial class Seedpacket : TextureButton
public override void _Pressed()
{
GrabFocus();
if (_forbidden || _locked) return;
if (_handler is ISeedpacketPress pressHandler)
pressHandler.Pressed();
}
@ -91,4 +94,14 @@ public partial class Seedpacket : TextureButton
{
if (_handler is ISeedpacketUnfocus unfocusHandler) unfocusHandler.OnUnfocused();
}
public void SetForbidden(bool value)
{
_forbidden = value;
GetNode<TextureRect>("ForbiddenTexture").Visible = value;
}
public void SetLocked(bool value)
{
_locked = value;
GetNode<TextureRect>("LockedTexture").Visible = value;
}
}