aloe effect

This commit is contained in:
Rendo 2025-07-30 03:52:34 +05:00
commit 5a6eb151ae
7 changed files with 212 additions and 70 deletions

View file

@ -8,12 +8,13 @@ public partial class AloeBehaviour : BaseBehaviour
[Export] private float _hpTreshold = 0.25f;
private Timer _timer;
private bool _charge = true;
private PackedScene particlesPacked = ResourceLoader.Load<PackedScene>("uid://b3na62o5pu1gt");
public override void _Ready()
{
{
base._Ready();
_timer = GetNode<Timer>("Timer");
}
_timer = GetNode<Timer>("Timer");
}
public override void _Process(double delta)
{
@ -34,9 +35,12 @@ public partial class AloeBehaviour : BaseBehaviour
public void Heal()
{
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * FieldParams.TileWidth;
if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
{
plantData.Heal(300, GetParent());
if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
{
plantData.Heal(300, GetParent());
var particles = particlesPacked.Instantiate<Node2D>();
PoolContainer.Instance.Particles.AddChild(particles);
particles.GlobalPosition = plantData.GlobalPosition;
}
}

View file

@ -15,48 +15,18 @@ public partial class CYSFocusSetup : Node
Control control = grid.GetChild<Control>(i);
// If it isn't leftmost element
if (x != 0)
{
control.FocusNeighborLeft = control.GetPathTo(grid.GetChild(PositionToIndex(x - 1, y)));
}
// If it isn't upmost element
if (y != 0)
{
control.FocusNeighborTop = control.GetPathTo(grid.GetChild(PositionToIndex(x, y - 1)));
}
else
if (y == 0)
{
control.FocusNeighborTop = control.GetPathTo(textContainer);
}
// If it isn't rightmost element
if (x != grid.Columns - 1 && i != grid.GetChildCount())
if (x == grid.Columns - 1)
{
control.FocusNeighborRight = control.GetPathTo(grid.GetChild(PositionToIndex(x + 1, y)));
}
else
{
if (y != 0)
{
control.FocusNeighborRight = control.GetPathTo(grid.GetChild(PositionToIndex(x + 1, y - 1)));
}
else
{
control.FocusNeighborRight = control.GetPathTo(button);
}
}
if (PositionToIndex(x, y + 1) < grid.GetChildCount())
{
control.FocusNeighborBottom = control.GetPathTo(grid.GetChild(PositionToIndex(x, y + 1)));
control.FocusNeighborRight = control.GetPathTo(button);
}
}
QueueFree();
}
private int PositionToIndex(int x, int y)
{
return y * grid.Columns + x;
}
}

View file

@ -0,0 +1,12 @@
using Godot;
namespace Newlon.Particles;
public partial class MixedParticles : Node2D
{
[Export] private GpuParticles2D emitter;
public override void _Ready()
{
emitter.Finished += ()=> { QueueFree(); };
}
}

View file

@ -0,0 +1 @@
uid://5ve2i0iu5oxr