redirection tiles
This commit is contained in:
parent
3fe903f2b8
commit
f3a6f7a05a
27 changed files with 369 additions and 70 deletions
|
|
@ -2,6 +2,7 @@ using Godot;
|
|||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public abstract partial class Effect : Resource
|
||||
{
|
||||
[Export] public float Duration;
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Zombies;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
public partial class GarlicEffect : Effect
|
||||
{
|
||||
[Export] private float tilesWalked = 0.2f;
|
||||
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/FieldParams.TileHeight <= 2)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else if((int)zombieData.GlobalPosition.Y/FieldParams.TileHeight >= 6)
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(RandomNumberGenerator.RandiRange(0,1) == 0)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
}
|
||||
zombieData.AbleToEat = false;
|
||||
var tween = zombieData.CreateTween();
|
||||
tween.TweenProperty(zombieData,"position:y",zombieData.GlobalPosition.Y + FieldParams.TileHeight * mult, Duration);
|
||||
tween.Parallel().TweenProperty(zombieData, "position:x", zombieData.GlobalPosition.X - FieldParams.TileHeight * tilesWalked, Duration);
|
||||
tween.TweenCallback(Callable.From(() => {zombieData.AbleToEat = true;}));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
27
scripts/systems/effects/PermanentSpeedEffect.cs
Normal file
27
scripts/systems/effects/PermanentSpeedEffect.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
using Godot;
|
||||
using Newlon.Components;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class PermanentSpeedEffect : Effect
|
||||
{
|
||||
[Export] public float Multiplier;
|
||||
|
||||
public override void Enter(Node target)
|
||||
{
|
||||
if (target is Entity entity)
|
||||
{
|
||||
entity.LocalTimescale *= Multiplier;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Exit(Node target)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
1
scripts/systems/effects/PermanentSpeedEffect.cs.uid
Normal file
1
scripts/systems/effects/PermanentSpeedEffect.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://3q40oeb4cabf
|
||||
60
scripts/systems/effects/RandomRedirectEffect.cs
Normal file
60
scripts/systems/effects/RandomRedirectEffect.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Zombies;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RandomRedirectEffect : Effect
|
||||
{
|
||||
[Export] private float tilesWalked = 0.2f;
|
||||
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 / FieldParams.TileHeight <= 2)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else if ((int)zombieData.GlobalPosition.Y / FieldParams.TileHeight >= 6)
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RandomNumberGenerator.RandiRange(0, 1) == 0)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
}
|
||||
zombieData.AbleToEat = false;
|
||||
var tween = zombieData.CreateTween();
|
||||
tween.TweenProperty(zombieData, "position:y", zombieData.GlobalPosition.Y + FieldParams.TileHeight * mult, Duration);
|
||||
tween.Parallel().TweenProperty(zombieData, "position:x", zombieData.GlobalPosition.X - FieldParams.TileHeight * tilesWalked, Duration);
|
||||
tween.TweenCallback(Callable.From(() => { zombieData.AbleToEat = true; }));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
55
scripts/systems/effects/RedirectEffect.cs
Normal file
55
scripts/systems/effects/RedirectEffect.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Zombies;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class RedirectEffect : Effect
|
||||
{
|
||||
[Export] private float tilesWalked = 0.2f;
|
||||
[Export] private bool down = false;
|
||||
|
||||
public override void Enter(Node target)
|
||||
{
|
||||
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 / FieldParams.TileHeight <= 2)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else if ((int)zombieData.GlobalPosition.Y / FieldParams.TileHeight >= 6)
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (down)
|
||||
{
|
||||
mult = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
mult = -1;
|
||||
}
|
||||
}
|
||||
zombieData.AbleToEat = false;
|
||||
var tween = zombieData.CreateTween();
|
||||
tween.TweenProperty(zombieData, "position:y", zombieData.GlobalPosition.Y + FieldParams.TileHeight * mult, Duration);
|
||||
tween.Parallel().TweenProperty(zombieData, "position:x", zombieData.GlobalPosition.X - FieldParams.TileHeight * tilesWalked, Duration);
|
||||
tween.TweenCallback(Callable.From(() => { zombieData.AbleToEat = true; }));
|
||||
}
|
||||
}
|
||||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
1
scripts/systems/effects/RedirectEffect.cs.uid
Normal file
1
scripts/systems/effects/RedirectEffect.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://blky82wwkqirx
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
using Godot;
|
||||
using Newlon.Components;
|
||||
using System;
|
||||
|
||||
namespace Newlon.Systems.Effects;
|
||||
|
||||
[GlobalClass]
|
||||
public partial class SlownessEffect : Effect
|
||||
{
|
||||
[Export] public Color ColorOverride;
|
||||
|
|
@ -29,6 +29,6 @@ public partial class SlownessEffect : Effect
|
|||
|
||||
public override void Process(Node target)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue