25 lines
596 B
C#
25 lines
596 B
C#
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");
|
|
}
|
|
}
|
|
}
|