Player-field manipulations
This commit is contained in:
parent
9ced321538
commit
74759e9e16
21 changed files with 270 additions and 54 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
scripts/components/gui/VeilResizer.cs
Normal file
12
scripts/components/gui/VeilResizer.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue