redirection tiles

This commit is contained in:
Rendo 2025-07-29 05:11:50 +05:00
commit f3a6f7a05a
27 changed files with 369 additions and 70 deletions

View file

@ -2,6 +2,7 @@ using Godot;
namespace Newlon.Systems.Effects;
[GlobalClass]
public abstract partial class Effect : Resource
{
[Export] public float Duration;

View file

@ -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)
{
}
}

View 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)
{
}
}

View file

@ -0,0 +1 @@
uid://3q40oeb4cabf

View 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)
{
}
}

View 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)
{
}
}

View file

@ -0,0 +1 @@
uid://blky82wwkqirx

View file

@ -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)
{
}
}