Nerdus
This commit is contained in:
parent
f37c5fb87c
commit
2156c6a166
16 changed files with 490 additions and 5 deletions
48
scripts/plants/NerdusReturnAttack.cs
Normal file
48
scripts/plants/NerdusReturnAttack.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using Godot;
|
||||
using Newlon.Systems.Effects;
|
||||
using System.Collections.Generic;
|
||||
namespace Newlon.Components.Plants;
|
||||
|
||||
public partial class NerdusReturnAttack : Area2D
|
||||
{
|
||||
private float returnAmount;
|
||||
[Export] private Effect returnEffect;
|
||||
[Export] private float bitesToPeas = 1;
|
||||
public bool triggered = false;
|
||||
private List<Entity> entities = new();
|
||||
public override void _Ready()
|
||||
{
|
||||
AreaEntered += OnAreaEntered;
|
||||
AreaExited += OnAreaExited;
|
||||
}
|
||||
private void OnAreaEntered(Area2D area)
|
||||
{
|
||||
if (area.GetParent() is Entity entity)
|
||||
{
|
||||
entities.Add(entity);
|
||||
}
|
||||
}
|
||||
private void OnAreaExited(Area2D area)
|
||||
{
|
||||
if (area.GetParent() is Entity entity && entities.Contains(entity))
|
||||
{
|
||||
entities.Remove(entity);
|
||||
}
|
||||
}
|
||||
private void OnHPChanged(float delta, Node source)
|
||||
{
|
||||
if (delta >= 0) return;
|
||||
returnAmount -= delta;
|
||||
triggered = true;
|
||||
}
|
||||
public void ReturnAllDamage()
|
||||
{
|
||||
foreach (var entity in entities)
|
||||
{
|
||||
entity.TakeDamage(returnAmount * bitesToPeas, GetParent<Entity>());
|
||||
entity.GiveEffect(returnEffect);
|
||||
}
|
||||
returnAmount = 0;
|
||||
triggered = false;
|
||||
}
|
||||
}
|
||||
1
scripts/plants/NerdusReturnAttack.cs.uid
Normal file
1
scripts/plants/NerdusReturnAttack.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://dcokqes5wwo3k
|
||||
|
|
@ -1,18 +1,25 @@
|
|||
using Godot;
|
||||
using Godot.Collections;
|
||||
|
||||
namespace Newlon.Components.Plants.Behaviours;
|
||||
|
||||
public partial class HpBasedBehaviour : BaseBehaviour
|
||||
{
|
||||
private RuntimePlantData _data;
|
||||
[Export] private Array<string> parameters;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
_data = GetParent<RuntimePlantData>();
|
||||
}
|
||||
|
||||
public void OnHPChanged(int amount,Node origin)
|
||||
public void OnHPChanged(int amount, Node origin)
|
||||
{
|
||||
_tree.Set("parameters/Tree/blend_position",(float)_data.HP/_data.MaxHP);
|
||||
var calc = (float)_data.HP / _data.MaxHP;
|
||||
foreach (var par in parameters)
|
||||
{
|
||||
_tree.Set(par, calc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue