25 lines
573 B
C#
25 lines
573 B
C#
using Godot;
|
|
using Newlon.Components.Level;
|
|
using Newlon.Components.Zombies;
|
|
|
|
namespace Newlon.Components.Plants;
|
|
|
|
public partial class ExplosionComponent : Area2D
|
|
{
|
|
[Export] private int damage;
|
|
[Export] private PackedScene particles;
|
|
|
|
public void Explode()
|
|
{
|
|
foreach (var zombie in GetOverlappingAreas())
|
|
{
|
|
var zombieData = zombie.GetParent<RuntimeZombieData>();
|
|
zombieData?.TakeDamage(damage, GetParent());
|
|
}
|
|
|
|
PoolContainer.Instance.SpawnParticles(particles, GetParent<RuntimePlantData>().GlobalPosition);
|
|
|
|
GetParent<RuntimePlantData>().Kill();
|
|
|
|
}
|
|
}
|