Zondre
This commit is contained in:
parent
c266d22f58
commit
2eb65c3092
24 changed files with 566 additions and 49 deletions
41
scripts/components/zombies/EatBox.cs
Normal file
41
scripts/components/zombies/EatBox.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class EatBox : Area2D
|
||||
{
|
||||
// Rewrite this class completely when field system will be introduced.
|
||||
|
||||
[Export] private int _damage;
|
||||
[Export] private AnimationTree _animationTree;
|
||||
private RuntimePlantData plant;
|
||||
|
||||
|
||||
public void Bite()
|
||||
{
|
||||
plant.TakeDamage(_damage);
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
|
||||
if (parent != null && parent is RuntimePlantData plantData)
|
||||
{
|
||||
plant = plantData;
|
||||
_animationTree.Set("parameters/conditions/eat", true);
|
||||
_animationTree.Set("parameters/conditions/end_eat", false);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnAreaExited(Area2D area)
|
||||
{
|
||||
var parent = area.GetParent();
|
||||
|
||||
if (parent == plant)
|
||||
{
|
||||
plant = null;
|
||||
_animationTree.Set("parameters/conditions/eat", false);
|
||||
_animationTree.Set("parameters/conditions/end_eat", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue