file refactor
This commit is contained in:
parent
da5a3e874b
commit
bffb012a26
175 changed files with 1086 additions and 1107 deletions
47
scripts/zombies/EatBox.cs
Normal file
47
scripts/zombies/EatBox.cs
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Plants;
|
||||
|
||||
|
||||
namespace Newlon.Components.Zombies;
|
||||
|
||||
public partial class EatBox : Area2D
|
||||
{
|
||||
// Rewrite this class completely when field system will be introduced.
|
||||
|
||||
[Export] public FloatModifiers _damage;
|
||||
private RuntimePlantData plant;
|
||||
|
||||
public bool isEating = false;
|
||||
|
||||
public void Bite()
|
||||
{
|
||||
if (GetParent<RuntimeZombieData>().AbleToEat)
|
||||
{
|
||||
plant?.TakeDamage((int)_damage.GetValue(), GetParent());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
|
||||
if (parent != null && parent is RuntimePlantData plantData)
|
||||
{
|
||||
plant = plantData;
|
||||
isEating = true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAreaExited(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
|
||||
if (parent == plant)
|
||||
{
|
||||
plant = null;
|
||||
isEating = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue