Player-field manipulations

This commit is contained in:
Фёдор Веселов 2024-09-15 19:19:59 +05:00
commit 74759e9e16
21 changed files with 270 additions and 54 deletions

View file

@ -1,12 +1,19 @@
using Godot;
using System;
public partial class PlantSlot : Node
public partial class PlantSlot : TextureButton
{
[Export] private PlantResource _resource;
[Export] private Label _cost;
[Export] private TextureRect _icon;
[Export] private Timer _timer;
public override void _Ready()
{
if (_resource != null)
UpdateContents();
}
public void SetPlantResource( PlantResource resource )
{
_resource = resource;
@ -18,5 +25,35 @@ public partial class PlantSlot : Node
{
_cost.Text = _resource.Cost.ToString();
_icon.Texture = _resource.Preview;
_timer.WaitTime = _resource.ReloadTime;
}
private void OnPressed()
{
if (_timer.TimeLeft == 0)
{
LevelController.Instance.PlantField.SetPlant(this, _resource);
}
}
private void OnFocusExited()
{
LevelController.Instance.PlantField.SetPlant(null, null);
}
public void Recharge()
{
Disabled = true;
FocusMode = FocusModeEnum.None;
ReleaseFocus();
_timer.Start();
}
private void Timeout()
{
Disabled = false;
FocusMode = FocusModeEnum.All;
}
}

View file

@ -0,0 +1,12 @@
using Godot;
using System;
public partial class VeilResizer : TextureProgressBar
{
[Export] private Timer _referenceTimer;
public override void _Process(double delta)
{
Value = (_referenceTimer.TimeLeft/_referenceTimer.WaitTime);
}
}