Spikeweed
This commit is contained in:
parent
8f66b9e565
commit
b543631c86
5 changed files with 151 additions and 1 deletions
16
scripts/components/plants/AreaAttack.cs
Normal file
16
scripts/components/plants/AreaAttack.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
20
scripts/components/plants/behaviours/SpikeweedBehaviour.cs
Normal file
20
scripts/components/plants/behaviours/SpikeweedBehaviour.cs
Normal 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");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue