Garlic
This commit is contained in:
parent
34638272aa
commit
2e3226b5c1
14 changed files with 200 additions and 10 deletions
57
scripts/systems/effects/GarlicEffect.cs
Normal file
57
scripts/systems/effects/GarlicEffect.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Zombies;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
public partial class GarlicEffect : Effect
|
||||
{
|
||||
RandomNumberGenerator RandomNumberGenerator;
|
||||
|
||||
public override void Enter(Node target)
|
||||
{
|
||||
if(RandomNumberGenerator == null)
|
||||
{
|
||||
RandomNumberGenerator = new RandomNumberGenerator();
|
||||
RandomNumberGenerator.Randomize();
|
||||
}
|
||||
if(target is RuntimeZombieData zombieData)
|
||||
zombieData.AbleToEat = false;
|
||||
//Animation call
|
||||
}
|
||||
|
||||
public override void Exit(Node target)
|
||||
{
|
||||
if(target is RuntimeZombieData zombieData)
|
||||
{
|
||||
int mult;
|
||||
if((int)zombieData.GlobalPosition.Y/Utility.TileHeight <= 2)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else if((int)zombieData.GlobalPosition.Y/Utility.TileHeight >= 6)
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RandomNumberGenerator.RandiRange(0,1) == 0)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
}
|
||||
var tween = zombieData.CreateTween();
|
||||
tween.TweenProperty(zombieData,"position:y",zombieData.GlobalPosition.Y + Utility.TileHeight * mult, 1.0);
|
||||
tween.TweenCallback(Callable.From(() => {zombieData.AbleToEat = true;}));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue