Animations improved
This commit is contained in:
parent
c89d93cf24
commit
ad18793543
35 changed files with 430 additions and 465 deletions
|
|
@ -3,40 +3,46 @@ using Newlon.Components.Level;
|
|||
|
||||
namespace Newlon.Components.Plants.Behaviours;
|
||||
|
||||
public partial class AloeBehaviour : Node
|
||||
public partial class AloeBehaviour : BaseBehaviour
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
[Export] private float _hpTreshold = 0.25f;
|
||||
private Timer _timer;
|
||||
private bool _charge = true;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_timer = GetNode<Timer>("Timer");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_tree.Set("parameters/conditions/charged",_charge);
|
||||
|
||||
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
|
||||
if(_charge && PoolContainer.Instance.EntityField[1].ContainsKey(checkPos) && PoolContainer.Instance.EntityField[1][checkPos] is RuntimePlantData plantData)
|
||||
if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
|
||||
{
|
||||
if((float)plantData.Hp / (float)plantData.MaxHp < _hpTreshold)
|
||||
{
|
||||
plantData.Heal(3000 + 25 * plantData.MaxHp,GetParent());
|
||||
_charge = false;
|
||||
_player.Play("aloe/heal");
|
||||
_player.Queue("aloe/idle_used");
|
||||
_timer.Start();
|
||||
_tree.Set("parameters/conditions/heal",true);
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Heal()
|
||||
{
|
||||
var checkPos = GetParent<Node2D>().GlobalPosition + Vector2.Right * Utility.TileWidth;
|
||||
if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData))
|
||||
{
|
||||
plantData.Heal(3000 + 25 * plantData.MaxHp, GetParent());
|
||||
GD.Print("IM TRYING");
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTimeout()
|
||||
{
|
||||
_charge = true;
|
||||
_player.Play("aloe/recharge");
|
||||
_player.Queue("aloe/idle");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue