aloe
This commit is contained in:
parent
435ca455f0
commit
8fdc2a3ed9
7 changed files with 127 additions and 1 deletions
|
|
@ -11,7 +11,7 @@ public partial class RuntimePlantData : Node2D, IEntity
|
|||
{
|
||||
[Export]
|
||||
private int _maxHP;
|
||||
private int _hp;
|
||||
[Export]private int _hp;
|
||||
public int Hp => _hp;
|
||||
public int MaxHp => _maxHP;
|
||||
public int Line {get; set;}
|
||||
|
|
|
|||
42
scripts/components/plants/behaviours/AloeBehaviour.cs
Normal file
42
scripts/components/plants/behaviours/AloeBehaviour.cs
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
namespace Newlon.Components.Plants.Behaviours;
|
||||
|
||||
public partial class AloeBehaviour : Node
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
[Export] private float _hpTreshold = 0.25f;
|
||||
private Timer _timer;
|
||||
private bool _charge = true;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_timer = GetNode<Timer>("Timer");
|
||||
}
|
||||
|
||||
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
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((float)plantData.Hp / (float)plantData.MaxHp < _hpTreshold)
|
||||
{
|
||||
plantData.Heal(3000 + 25 * plantData.MaxHp);
|
||||
_charge = false;
|
||||
_player.Play("aloe/heal");
|
||||
_player.Queue("aloe/idle_used");
|
||||
_timer.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTimeout()
|
||||
{
|
||||
_charge = true;
|
||||
_player.Play("aloe/recharge");
|
||||
_player.Queue("aloe/idle");
|
||||
}
|
||||
}
|
||||
|
|
@ -14,6 +14,7 @@ public partial class WallnutBehaviour : Node
|
|||
|
||||
public void OnHPChanged(int amount)
|
||||
{
|
||||
|
||||
if(_data.Hp <= _data.MaxHp*2.0/3.0 && _data.Hp > _data.MaxHp/3.0)
|
||||
{
|
||||
_player.Play("idle_mid");
|
||||
|
|
@ -22,5 +23,9 @@ public partial class WallnutBehaviour : Node
|
|||
{
|
||||
_player.Play("idle_low");
|
||||
}
|
||||
else
|
||||
{
|
||||
_player.Play("idle_full");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue