This commit is contained in:
Фёдор Веселов 2024-10-07 18:18:59 +05:00
commit 2e3226b5c1
14 changed files with 200 additions and 10 deletions

View file

@ -14,13 +14,13 @@ public class Utility
//
#region Enums
public enum EffectSlots {FREEZE, STUN, POISON, BEBRA};
public enum EffectSlots {FREEZE, STUN, POISON, GARLIC};
public enum DamageTypes {PHYSICAL, ICE};
#endregion
public const int EffectSlotCount = 3;
public const int EffectSlotCount = 4;
public const int LineCount = 5;
public const int TileWidth = 50;
public const int TileHeight = 60;

View file

@ -0,0 +1,19 @@
using Godot;
using Newlon.Components.Zombies;
using Newlon.Systems.Effects;
namespace Newlon.Components.Plants;
public partial class ReturnEffect : Node
{
[Export]
private Effect _effectToReturn;
public void OnDamageRecieved(int delta,Node origin)
{
if (origin is RuntimeZombieData zombie)
{
zombie.GiveEffect(_effectToReturn);
}
}
}

View file

@ -15,7 +15,8 @@ public partial class EatBox : Area2D
public void Bite()
{
plant?.TakeDamage(_damage,GetParent());
if (GetParent<RuntimeZombieData>().AbleToEat)
plant?.TakeDamage(_damage,GetParent());
}
public void OnAreaEntered(Area2D area)

View file

@ -25,6 +25,8 @@ public partial class RuntimeZombieData : Node2D, IEntity, ILocalTimescale, IEffe
public int Line => _line;
public bool AbleToEat = true;
public float LocalTimescale
{
get => _localTimescale;

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