This commit is contained in:
Фёдор Веселов 2024-09-17 21:52:44 +05:00
commit 2c8bb1d652
6 changed files with 199 additions and 15 deletions

View file

@ -0,0 +1,25 @@
using Godot;
using System;
public partial class WallnutBehaviour : Node
{
private AnimationPlayer _player;
private RuntimePlantData _data;
public override void _Ready()
{
_player = GetNode<AnimationPlayer>("../AnimationPlayer");
_data = GetParent<RuntimePlantData>();
}
public void OnHPChanged(int amount)
{
if(_data.Hp <= _data.MaxHp*2.0/3.0 && _data.Hp > _data.MaxHp/3.0)
{
_player.Play("idle_mid");
}
else if(_data.Hp < _data.MaxHp/3.0)
{
_player.Play("idle_low");
}
}
}