file refactor
This commit is contained in:
parent
da5a3e874b
commit
bffb012a26
175 changed files with 1086 additions and 1107 deletions
9
scripts/gui/ExitButton.cs
Normal file
9
scripts/gui/ExitButton.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using Godot;
|
||||
|
||||
public partial class ExitButton : Button
|
||||
{
|
||||
public override void _Pressed()
|
||||
{
|
||||
GetTree().ChangeSceneToFile("uid://bfstrli64u23y");
|
||||
}
|
||||
}
|
||||
1
scripts/gui/ExitButton.cs.uid
Normal file
1
scripts/gui/ExitButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dpdpv2oyxdna7
|
||||
36
scripts/gui/FastForwardButton.cs
Normal file
36
scripts/gui/FastForwardButton.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using Godot;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class FastForwardButton : Button
|
||||
{
|
||||
[Export] private Texture2D firstSpeed;
|
||||
[Export] private Texture2D secondSpeed;
|
||||
[Export] private Texture2D thirdSpeed;
|
||||
|
||||
[Export] private AnimationPlayer flashAnimator;
|
||||
|
||||
private int speed = 1;
|
||||
|
||||
public void OnPressed()
|
||||
{
|
||||
speed = Mathf.Wrap(speed+1, 1, 4);
|
||||
|
||||
switch (speed)
|
||||
{
|
||||
case 1:
|
||||
Icon = firstSpeed;
|
||||
break;
|
||||
case 2:
|
||||
Icon = secondSpeed;
|
||||
break;
|
||||
case 3:
|
||||
Icon = thirdSpeed;
|
||||
break;
|
||||
}
|
||||
|
||||
flashAnimator.Play("flash");
|
||||
|
||||
Engine.TimeScale = speed;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/FastForwardButton.cs.uid
Normal file
1
scripts/gui/FastForwardButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cwn3bd2k7mdq6
|
||||
11
scripts/gui/PauseButton.cs
Normal file
11
scripts/gui/PauseButton.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PauseButton : Button
|
||||
{
|
||||
public override void _Pressed()
|
||||
{
|
||||
PauseMenu.Pause();
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/gui/PauseButton.cs.uid
Normal file
1
scripts/gui/PauseButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cmfhiun6yrlr6
|
||||
31
scripts/gui/PauseMenu.cs
Normal file
31
scripts/gui/PauseMenu.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class PauseMenu : Control
|
||||
{
|
||||
private static PauseMenu Instance;
|
||||
public override void _Ready()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void Continue()
|
||||
{
|
||||
GetParent<Control>().Visible = false;
|
||||
GetTree().Paused = false;
|
||||
}
|
||||
public void Restart()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
GetTree().ReloadCurrentScene();
|
||||
}
|
||||
public void Exit()
|
||||
{
|
||||
GetTree().ChangeSceneToFile("uid://bfstrli64u23y");
|
||||
}
|
||||
public static void Pause()
|
||||
{
|
||||
Instance.GetParent<Control>().Visible = true;
|
||||
Instance.GetTree().Paused = true;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/PauseMenu.cs.uid
Normal file
1
scripts/gui/PauseMenu.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://gvwhpjoame6m
|
||||
12
scripts/gui/RestartButton.cs
Normal file
12
scripts/gui/RestartButton.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class RestartButton : Button
|
||||
{
|
||||
public override void _Pressed()
|
||||
{
|
||||
GetTree().Paused = false;
|
||||
GetTree().ReloadCurrentScene();
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/gui/RestartButton.cs.uid
Normal file
1
scripts/gui/RestartButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://btqwxelqxheh3
|
||||
41
scripts/gui/ShovelButton.cs
Normal file
41
scripts/gui/ShovelButton.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Plants;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class ShovelButton : TextureButton
|
||||
{
|
||||
[Export] private PackedScene particles;
|
||||
private void OnFocusExited()
|
||||
{
|
||||
ButtonPressed = false;
|
||||
}
|
||||
public override void _Toggled(bool toggledOn)
|
||||
{
|
||||
Cursor.Instance.shovel = toggledOn;
|
||||
Cursor.Instance.UpdateCursor();
|
||||
}
|
||||
|
||||
public override void _Input(InputEvent @event)
|
||||
{
|
||||
|
||||
if (@event.IsActionPressed("primary_action") && ButtonPressed)
|
||||
{
|
||||
var checkedPosition = (PoolContainer.Instance.Plants.GetGlobalMousePosition() / Utility.Tile).Ceil() * Utility.Tile - new Vector2(20, 14);
|
||||
|
||||
for (int i = Utility.LayersCount-1; i >= 0; i--)
|
||||
{
|
||||
if (PoolContainer.Instance.EntityField[i].TryGetValue(checkedPosition, out var entity) && entity is RuntimePlantData plantData)
|
||||
{
|
||||
plantData.Kill();
|
||||
|
||||
PoolContainer.Instance.SpawnParticles(particles, plantData.GlobalPosition + Vector2.Down * Utility.TileHeight/2.0f);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
ButtonPressed = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/gui/ShovelButton.cs.uid
Normal file
1
scripts/gui/ShovelButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d4dbg0us5ngxy
|
||||
12
scripts/gui/SunCounter.cs
Normal file
12
scripts/gui/SunCounter.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class SunCounter : Label
|
||||
{
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Text = RuntimeLevelData.Instance.SunCount.ToString();
|
||||
}
|
||||
}
|
||||
1
scripts/gui/SunCounter.cs.uid
Normal file
1
scripts/gui/SunCounter.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dwxohya1exdkh
|
||||
11
scripts/gui/SunCounterImage.cs
Normal file
11
scripts/gui/SunCounterImage.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using Godot;
|
||||
using Newlon;
|
||||
using System;
|
||||
|
||||
public partial class SunCounterImage : Control
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Sun.Counter = this;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/SunCounterImage.cs.uid
Normal file
1
scripts/gui/SunCounterImage.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0ekxnoq6cyt4
|
||||
23
scripts/gui/VeilResizer.cs
Normal file
23
scripts/gui/VeilResizer.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
using Godot;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class VeilResizer : TextureProgressBar
|
||||
{
|
||||
[Export] private Timer _referenceTimer;
|
||||
private Seedpacket seedpacket;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
seedpacket = GetParent<Seedpacket>();
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if (seedpacket.Disabled && _referenceTimer.IsStopped())
|
||||
Value = 1.0;
|
||||
else
|
||||
Value = _referenceTimer.TimeLeft / _referenceTimer.WaitTime;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/VeilResizer.cs.uid
Normal file
1
scripts/gui/VeilResizer.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://ddi84kmmq1qla
|
||||
36
scripts/gui/almanach/AlmanachGrid.cs
Normal file
36
scripts/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/gui/almanach/AlmanachGrid.cs.uid
Normal file
1
scripts/gui/almanach/AlmanachGrid.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://0mvmfvwe1bc7
|
||||
24
scripts/gui/choose_your_seeds/GridLoader.cs
Normal file
24
scripts/gui/choose_your_seeds/GridLoader.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Godot;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class GridLoader : GridContainer
|
||||
{
|
||||
private const string PLANT_RESOURCE_PATH = "res://resources/plants/";
|
||||
private PackedScene _plantCard;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_plantCard = ResourceLoader.Load<PackedScene>("res://scenes/gui/seedpacket.tscn");
|
||||
|
||||
foreach(var resource in GameRegistry.GetPlants())
|
||||
{
|
||||
Seedpacket slot = _plantCard.Instantiate<Seedpacket>();
|
||||
AddChild(slot);
|
||||
|
||||
slot.SetResource(resource);
|
||||
slot.SetHandler(new ChoosableHandler(slot));
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/gui/choose_your_seeds/GridLoader.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/GridLoader.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://eq3ecja30mlj
|
||||
16
scripts/gui/choose_your_seeds/LevelRunButton.cs
Normal file
16
scripts/gui/choose_your_seeds/LevelRunButton.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI;
|
||||
|
||||
public partial class LevelRunButton : Button
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
public override void _Pressed()
|
||||
{
|
||||
RuntimeLevelData.Instance.SetLevelState(RuntimeLevelData.LevelStates.Game);
|
||||
GetTree().Paused = false;
|
||||
|
||||
_player.Play("Hide");
|
||||
}
|
||||
}
|
||||
1
scripts/gui/choose_your_seeds/LevelRunButton.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/LevelRunButton.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d26waisd3v488
|
||||
51
scripts/gui/choose_your_seeds/Previewport.cs
Normal file
51
scripts/gui/choose_your_seeds/Previewport.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using Godot;
|
||||
using Newlon;
|
||||
using Newlon.Components;
|
||||
using Newlon.Components.GUI.Seedpackets;
|
||||
using Newlon.Components.Plants;
|
||||
|
||||
public partial class Previewport : SubViewport
|
||||
{
|
||||
private Node current_display;
|
||||
private Texture2D start_Field;
|
||||
|
||||
[Export] private Label title;
|
||||
[Export] private RichTextLabel description;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
GetParent().GetViewport().GuiFocusChanged += OnFocusChanged;
|
||||
start_Field = GetNode<Sprite2D>("FrameField").Texture;
|
||||
}
|
||||
|
||||
public void OnFocusChanged(Control node)
|
||||
{
|
||||
if (GetParent<Control>().IsVisibleInTree() == false) return;
|
||||
if (node is Seedpacket packet)
|
||||
{
|
||||
ChangeDisplay(packet.GetResource());
|
||||
}
|
||||
}
|
||||
|
||||
private void ChangeDisplay(DisplayResource resource)
|
||||
{
|
||||
// Expand with updates
|
||||
if (current_display != null)
|
||||
{
|
||||
current_display.QueueFree();
|
||||
}
|
||||
if (resource.customFrame != null && resource.customFrame.almanachField != null)
|
||||
{
|
||||
GetNode<Sprite2D>("FrameField").Texture = resource.customFrame.almanachField;
|
||||
}
|
||||
else
|
||||
GetNode<Sprite2D>("FrameField").Texture = start_Field;
|
||||
current_display = resource.Scene.Instantiate();
|
||||
title.Text = Tr(resource.name_key);
|
||||
description.Text = Tr(resource.description_key);
|
||||
AddChild(current_display);
|
||||
if (current_display is Entity entity)
|
||||
entity.DisableBrain();
|
||||
}
|
||||
|
||||
}
|
||||
1
scripts/gui/choose_your_seeds/Previewport.cs.uid
Normal file
1
scripts/gui/choose_your_seeds/Previewport.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://covbig00p22di
|
||||
4
scripts/gui/main_menu_rich_text.gd
Normal file
4
scripts/gui/main_menu_rich_text.gd
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
extends RichTextLabel
|
||||
|
||||
func _on_meta_clicked(meta: Variant) -> void:
|
||||
OS.shell_open(meta)
|
||||
1
scripts/gui/main_menu_rich_text.gd.uid
Normal file
1
scripts/gui/main_menu_rich_text.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://drru785m4eep
|
||||
21
scripts/gui/menu_buttons.gd
Normal file
21
scripts/gui/menu_buttons.gd
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
extends Node
|
||||
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
get_tree().change_scene_to_file("res://scenes/prototype_survival.tscn")
|
||||
$ChannelPlayer.call("Play")
|
||||
|
||||
|
||||
func _on_exit_button_pressed() -> void:
|
||||
get_tree().quit()
|
||||
$ChannelPlayer.call("Play")
|
||||
|
||||
|
||||
func _on_button_pressed() -> void:
|
||||
$"../AboutWindow".popup_centered()
|
||||
$ChannelPlayer.call("Play")
|
||||
|
||||
|
||||
func _on_almanach_button_pressed() -> void:
|
||||
$"../Almanach".visible = true
|
||||
$ChannelPlayer.call("Play")
|
||||
1
scripts/gui/menu_buttons.gd.uid
Normal file
1
scripts/gui/menu_buttons.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c06k4k3ww48ev
|
||||
9
scripts/gui/prototype_window.gd
Normal file
9
scripts/gui/prototype_window.gd
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
extends AcceptDialog
|
||||
|
||||
static var seen = false
|
||||
|
||||
func _ready() -> void:
|
||||
if seen:
|
||||
return
|
||||
seen = true
|
||||
popup_centered()
|
||||
1
scripts/gui/prototype_window.gd.uid
Normal file
1
scripts/gui/prototype_window.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dgevhrbucpwrs
|
||||
10
scripts/gui/seedpackets/AlmanachHandler.cs
Normal file
10
scripts/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)
|
||||
{
|
||||
}
|
||||
}
|
||||
1
scripts/gui/seedpackets/AlmanachHandler.cs.uid
Normal file
1
scripts/gui/seedpackets/AlmanachHandler.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://pse018r220mt
|
||||
29
scripts/gui/seedpackets/ChoosableHandler.cs
Normal file
29
scripts/gui/seedpackets/ChoosableHandler.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public class ChoosableHandler : SeedpacketHandler, ISeedpacketPress
|
||||
{
|
||||
public ChoosableHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public void Pressed()
|
||||
{
|
||||
if (LevelGUIElements.Instance.SeedpacketsHotbar.GetChildCount() > 9) return;
|
||||
_owner.disablePacket = true;
|
||||
|
||||
var hotbarSeedpacket = Seedpacket.Prefab.Instantiate<Seedpacket>();
|
||||
LevelGUIElements.Instance.SeedpacketsHotbar.AddChild(hotbarSeedpacket);
|
||||
hotbarSeedpacket.SetResource(_owner.GetResource());
|
||||
|
||||
var pregameHandler = new HotbarPregameHandler(hotbarSeedpacket);
|
||||
hotbarSeedpacket.SetHandler(pregameHandler);
|
||||
pregameHandler.Clicked += OnHotbarClicked;
|
||||
|
||||
AudioSequencer.Play("tap", Seedpacket.TapStream);
|
||||
}
|
||||
|
||||
public void OnHotbarClicked()
|
||||
{
|
||||
_owner.disablePacket = false;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/seedpackets/ChoosableHandler.cs.uid
Normal file
1
scripts/gui/seedpackets/ChoosableHandler.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b3sut12n56w1y
|
||||
9
scripts/gui/seedpackets/CustomSeedpacketFrame.cs
Normal file
9
scripts/gui/seedpackets/CustomSeedpacketFrame.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
using Godot;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class CustomSeedpacketFrame : Resource
|
||||
{
|
||||
[Export] public Texture2D frame;
|
||||
[Export] public LabelSettings font;
|
||||
[Export] public Texture2D almanachField;
|
||||
}
|
||||
1
scripts/gui/seedpackets/CustomSeedpacketFrame.cs.uid
Normal file
1
scripts/gui/seedpackets/CustomSeedpacketFrame.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://3m7xks3xq3hl
|
||||
25
scripts/gui/seedpackets/HotbarHandler.cs
Normal file
25
scripts/gui/seedpackets/HotbarHandler.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public class HotbarHandler : SeedpacketHandler, ISeedpacketPress, ISeedpacketProcess, ISeedpacketUnfocus
|
||||
{
|
||||
public HotbarHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
}
|
||||
|
||||
public void Pressed()
|
||||
{
|
||||
PlantField.Instance.SetPlant(_owner, _owner.GetResource());
|
||||
AudioSequencer.Play("lift_seed", Seedpacket.LiftStream);
|
||||
}
|
||||
|
||||
public void Process()
|
||||
{
|
||||
_owner.disablePacket = RuntimeLevelData.Instance.SunCount < _owner.GetResource().Cost;
|
||||
}
|
||||
public void OnUnfocused()
|
||||
{
|
||||
PlantField.Instance.ResetPlant();
|
||||
}
|
||||
}
|
||||
1
scripts/gui/seedpackets/HotbarHandler.cs.uid
Normal file
1
scripts/gui/seedpackets/HotbarHandler.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://gvgt14v1hndn
|
||||
33
scripts/gui/seedpackets/HotbarPregameHandler.cs
Normal file
33
scripts/gui/seedpackets/HotbarPregameHandler.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
using System;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public class HotbarPregameHandler : SeedpacketHandler, ISeedpacketPress
|
||||
{
|
||||
public HotbarPregameHandler(Seedpacket owner) : base(owner)
|
||||
{
|
||||
RuntimeLevelData.Instance.OnLevelStateChanged += OnLevelStateChanged;
|
||||
|
||||
}
|
||||
|
||||
public event Action Clicked;
|
||||
public void Pressed()
|
||||
{
|
||||
if (Clicked != null) Clicked();
|
||||
_owner.QueueFree();
|
||||
AudioSequencer.Play("tap", Seedpacket.UntapStream);
|
||||
}
|
||||
|
||||
public void OnLevelStateChanged(RuntimeLevelData.LevelStates state)
|
||||
{
|
||||
if (state == RuntimeLevelData.LevelStates.Game)
|
||||
{
|
||||
_owner.SetHandler(new HotbarHandler(_owner));
|
||||
}
|
||||
else if (state != RuntimeLevelData.LevelStates.ChooseYourSeeds)
|
||||
{
|
||||
_owner.disablePacket = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/gui/seedpackets/HotbarPregameHandler.cs.uid
Normal file
1
scripts/gui/seedpackets/HotbarPregameHandler.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bnygd8pcmoewp
|
||||
6
scripts/gui/seedpackets/ISeedpacketPress.cs
Normal file
6
scripts/gui/seedpackets/ISeedpacketPress.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public interface ISeedpacketPress
|
||||
{
|
||||
public void Pressed();
|
||||
}
|
||||
1
scripts/gui/seedpackets/ISeedpacketPress.cs.uid
Normal file
1
scripts/gui/seedpackets/ISeedpacketPress.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://o0ly38oqcuwu
|
||||
6
scripts/gui/seedpackets/ISeedpacketProcess.cs
Normal file
6
scripts/gui/seedpackets/ISeedpacketProcess.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public interface ISeedpacketProcess
|
||||
{
|
||||
public void Process();
|
||||
}
|
||||
1
scripts/gui/seedpackets/ISeedpacketProcess.cs.uid
Normal file
1
scripts/gui/seedpackets/ISeedpacketProcess.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://q2r43hym7s82
|
||||
6
scripts/gui/seedpackets/ISeedpacketUnfocus.cs
Normal file
6
scripts/gui/seedpackets/ISeedpacketUnfocus.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public interface ISeedpacketUnfocus
|
||||
{
|
||||
public void OnUnfocused();
|
||||
}
|
||||
1
scripts/gui/seedpackets/ISeedpacketUnfocus.cs.uid
Normal file
1
scripts/gui/seedpackets/ISeedpacketUnfocus.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://mdm8cepvvo4t
|
||||
99
scripts/gui/seedpackets/Seedpacket.cs
Normal file
99
scripts/gui/seedpackets/Seedpacket.cs
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
using Godot;
|
||||
|
||||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public partial class Seedpacket : TextureButton
|
||||
{
|
||||
public static AudioStream TapStream;
|
||||
public static AudioStream UntapStream;
|
||||
public static AudioStream LiftStream;
|
||||
private const string PATH_TO_PACKED_SCENE = "res://scenes/gui/seedpacket.tscn";
|
||||
private DisplayResource _resource;
|
||||
private Label _cost;
|
||||
private TextureRect _icon;
|
||||
private Timer _timer;
|
||||
private SeedpacketHandler _handler;
|
||||
|
||||
public bool disablePacket = false;
|
||||
|
||||
public static PackedScene Prefab { get; private set; }
|
||||
|
||||
// Node overrides
|
||||
public override void _Ready()
|
||||
{
|
||||
if (TapStream == null)
|
||||
{
|
||||
TapStream = ResourceLoader.Load<AudioStream>("res://assets/audio/gui/tap.mp3");
|
||||
UntapStream = ResourceLoader.Load<AudioStream>("res://assets/audio/gui/tap2.mp3");
|
||||
LiftStream = ResourceLoader.Load<AudioStream>("res://assets/audio/gui/seedlift.mp3");
|
||||
}
|
||||
if (_resource != null)
|
||||
UpdateContents();
|
||||
if (Prefab == null)
|
||||
{
|
||||
Prefab = ResourceLoader.Load<PackedScene>(PATH_TO_PACKED_SCENE);
|
||||
}
|
||||
_cost = GetNode<Label>("Cost");
|
||||
_icon = GetNode<TextureRect>("PlantPreviewContainer/Preview");
|
||||
_timer = GetNode<Timer>("RechargeTimer");
|
||||
}
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
Disabled = disablePacket || _timer.TimeLeft > 0;
|
||||
if (Disabled)
|
||||
{
|
||||
FocusMode = FocusModeEnum.None;
|
||||
}
|
||||
else
|
||||
{
|
||||
FocusMode = FocusModeEnum.All;
|
||||
}
|
||||
if (_handler is ISeedpacketProcess processHandler) processHandler.Process();
|
||||
}
|
||||
public void SetResource(DisplayResource resource )
|
||||
{
|
||||
_resource = resource;
|
||||
|
||||
UpdateContents();
|
||||
}
|
||||
|
||||
public DisplayResource GetResource()
|
||||
{
|
||||
return _resource;
|
||||
}
|
||||
|
||||
public void SetHandler(SeedpacketHandler newHandler)
|
||||
{
|
||||
disablePacket = false;
|
||||
_handler = newHandler;
|
||||
}
|
||||
|
||||
protected virtual void UpdateContents()
|
||||
{
|
||||
_cost.Text = _resource.Cost.ToString();
|
||||
_icon.Texture = _resource.Preview;
|
||||
_timer.WaitTime = _resource.ReloadTime;
|
||||
if (_resource.customFrame != null)
|
||||
{
|
||||
TextureNormal = _resource.customFrame.frame;
|
||||
_cost.LabelSettings = _resource.customFrame.font;
|
||||
}
|
||||
}
|
||||
|
||||
public override void _Pressed()
|
||||
{
|
||||
if (_handler is ISeedpacketPress pressHandler)
|
||||
pressHandler.Pressed();
|
||||
}
|
||||
|
||||
public void Recharge()
|
||||
{
|
||||
_timer.Start();
|
||||
ReleaseFocus();
|
||||
}
|
||||
|
||||
public void OnUnfocused()
|
||||
{
|
||||
if (_handler is ISeedpacketUnfocus unfocusHandler) unfocusHandler.OnUnfocused();
|
||||
}
|
||||
}
|
||||
1
scripts/gui/seedpackets/Seedpacket.cs.uid
Normal file
1
scripts/gui/seedpackets/Seedpacket.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cn6ddajdtf4ep
|
||||
11
scripts/gui/seedpackets/SeedpacketHandler.cs
Normal file
11
scripts/gui/seedpackets/SeedpacketHandler.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
namespace Newlon.Components.GUI.Seedpackets;
|
||||
|
||||
public class SeedpacketHandler
|
||||
{
|
||||
protected Seedpacket _owner;
|
||||
|
||||
public SeedpacketHandler(Seedpacket owner)
|
||||
{
|
||||
_owner = owner;
|
||||
}
|
||||
}
|
||||
1
scripts/gui/seedpackets/SeedpacketHandler.cs.uid
Normal file
1
scripts/gui/seedpackets/SeedpacketHandler.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://cr774updc04fu
|
||||
Loading…
Add table
Add a link
Reference in a new issue