Wall-nut
This commit is contained in:
parent
f4caadad99
commit
2c8bb1d652
6 changed files with 199 additions and 15 deletions
25
scripts/components/plants/behaviours/WallnutBehaviour.cs
Normal file
25
scripts/components/plants/behaviours/WallnutBehaviour.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue