Spikeweed

This commit is contained in:
Фёдор Веселов 2024-09-25 15:14:00 +05:00
commit b543631c86
5 changed files with 151 additions and 1 deletions

View file

@ -0,0 +1,16 @@
using Godot;
using System;
public partial class AreaAttack : Area2D
{
[Export] private int _damage;
public void Attack()
{
foreach (var zombie in GetOverlappingAreas())
{
var zombieData = zombie.GetParent<RuntimeZombieData>();
zombieData?.TakeDamage(_damage);
}
}
}

View file

@ -0,0 +1,20 @@
using Godot;
using System;
public partial class SpikeweedBehaviour : Node
{
[Export] private AnimationPlayer _player;
private int _inCount = 0;
public void OnHitboxEntered(Area2D _area)
{
if (_inCount++ == 0)
_player.Play("attack");
}
public void OnHitboxExited(Area2D _area)
{
if (--_inCount == 0)
_player.Play("idle");
}
}