Potato mine
This commit is contained in:
parent
e2cc168b72
commit
c428bf219d
6 changed files with 245 additions and 0 deletions
21
scripts/components/plants/ExplosionComponent.cs
Normal file
21
scripts/components/plants/ExplosionComponent.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using Godot;
|
||||
|
||||
public partial class ExplosionComponent : Node
|
||||
{
|
||||
[Export] private int damage;
|
||||
[Export] private Area2D explosionArea;
|
||||
|
||||
public void Explode()
|
||||
{
|
||||
foreach(var zombie in explosionArea.GetOverlappingAreas())
|
||||
{
|
||||
var zombieData = zombie.GetParent<RuntimeZombieData>();
|
||||
if (zombieData != null)
|
||||
{
|
||||
zombieData.TakeDamage(damage);
|
||||
}
|
||||
}
|
||||
|
||||
GetParent<RuntimePlantData>().Kill();
|
||||
}
|
||||
}
|
||||
28
scripts/components/plants/behaviours/PotatomineBehaviour.cs
Normal file
28
scripts/components/plants/behaviours/PotatomineBehaviour.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Godot;
|
||||
|
||||
public partial class PotatomineBehaviour : Node
|
||||
{
|
||||
[Export] private AnimationPlayer _player;
|
||||
[Export] private Area2D _hitbox;
|
||||
[Export] private CollisionShape2D _unprimedShape;
|
||||
[Export] private CollisionShape2D _primedShape;
|
||||
|
||||
private bool _primed = false;
|
||||
public void Prime()
|
||||
{
|
||||
_player.Play("prime");
|
||||
_player.Queue("idle_primed");
|
||||
|
||||
_hitbox.Monitorable = false;
|
||||
|
||||
_primed = true;
|
||||
_unprimedShape.Disabled = true;
|
||||
_primedShape.Disabled = false;
|
||||
}
|
||||
|
||||
public void OnAreaEntered(Area2D area)
|
||||
{
|
||||
if (_primed == false) return;
|
||||
GetNode<Timer>("ExplosionTimer").Start();
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue