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

@ -1,8 +1,9 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://dsg1vjx76ifgu"] [gd_resource type="Resource" load_steps=2 format=3 uid="uid://dsg1vjx76ifgu"]
[ext_resource type="Script" uid="uid://bb6lv1djnqjaw" path="res://scripts/systems/effects/GarlicEffect.cs" id="1_rfumy"] [ext_resource type="Script" uid="uid://bb6lv1djnqjaw" path="res://scripts/systems/effects/RandomRedirectEffect.cs" id="1_rfumy"]
[resource] [resource]
script = ExtResource("1_rfumy") script = ExtResource("1_rfumy")
tilesWalked = 0.2
Duration = 1.0 Duration = 1.0
Slot = "garlic" Slot = "garlic"

View file

@ -1,8 +1,9 @@
[gd_resource type="Resource" load_steps=2 format=3 uid="uid://dme4nvp28otq6"] [gd_resource type="Resource" load_steps=2 format=3 uid="uid://dme4nvp28otq6"]
[ext_resource type="Script" uid="uid://bb6lv1djnqjaw" path="res://scripts/systems/effects/GarlicEffect.cs" id="1_bd12u"] [ext_resource type="Script" uid="uid://bb6lv1djnqjaw" path="res://scripts/systems/effects/RandomRedirectEffect.cs" id="1_bd12u"]
[resource] [resource]
script = ExtResource("1_bd12u") script = ExtResource("1_bd12u")
tilesWalked = 0.2
Duration = 0.25 Duration = 0.25
Slot = "garlic" Slot = "garlic"

View file

@ -131,8 +131,8 @@ wavePercentage = 0.5
standardWaveDelay = 30.0 standardWaveDelay = 30.0
initialWaveDelay = 20.0 initialWaveDelay = 20.0
reward = ExtResource("1_pd3l1") reward = ExtResource("1_pd3l1")
forbiddenPlants = Array[String]([]) forbiddenPlants = Array[String](["peashooter", "threepeater"])
forbiddenTags = Array[String]([]) forbiddenTags = Array[String]([])
prepickedPlants = Array[String]([]) prepickedPlants = Array[String](["nerdus"])
waves = Array[ExtResource("3_cugtx")]([SubResource("Resource_qsvr4"), SubResource("Resource_otfbt"), SubResource("Resource_nv3y4"), SubResource("Resource_mt5r8"), SubResource("Resource_kugcf"), SubResource("Resource_oyvhx"), SubResource("Resource_k4k25"), SubResource("Resource_oxbea"), SubResource("Resource_5cdj6")]) waves = Array[ExtResource("3_cugtx")]([SubResource("Resource_qsvr4"), SubResource("Resource_otfbt"), SubResource("Resource_nv3y4"), SubResource("Resource_mt5r8"), SubResource("Resource_kugcf"), SubResource("Resource_oyvhx"), SubResource("Resource_k4k25"), SubResource("Resource_oxbea"), SubResource("Resource_5cdj6")])
initialScenes = Array[PackedScene]([null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null]) initialScenes = Array[PackedScene]([null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null])

View file

@ -0,0 +1,53 @@
[gd_resource type="Resource" script_class="AdventureLevelResource" load_steps=18 format=3 uid="uid://b6txurjc3j8n8"]
[ext_resource type="PackedScene" uid="uid://cp8oadhwu51i7" path="res://scenes/entities/tiles/redirect_down_tile.tscn" id="1_8ahni"]
[ext_resource type="Script" uid="uid://bximdujbkj2n4" path="res://addons/pvzadventure/AdventureLevelResource.cs" id="1_nvwhw"]
[ext_resource type="PackedScene" uid="uid://c5lplejgx7mex" path="res://scenes/entities/tiles/speed_tile.tscn" id="2_4or4b"]
[ext_resource type="Script" uid="uid://7rptlb5qr3b6" path="res://addons/pvzadventure/WaveData.cs" id="2_8ahni"]
[ext_resource type="PackedScene" uid="uid://d4kee4ipw1k1q" path="res://scenes/entities/tiles/redirect_up_tile.tscn" id="2_w7xe8"]
[ext_resource type="PackedScene" uid="uid://cy0puq5mtnxq7" path="res://scenes/entities/tiles/slow_tile.tscn" id="3_1dd05"]
[ext_resource type="Resource" uid="uid://bhy1gc3vi8le1" path="res://assets/rewards/GarlicReward.tres" id="5_gern8"]
[ext_resource type="Script" uid="uid://cw7yc3i2lgcja" path="res://addons/pvzadventure/WaveEvent.cs" id="7_nm8hx"]
[ext_resource type="Script" uid="uid://dl12rj75tk2qi" path="res://addons/pvzadventure/RowSpawn.cs" id="8_x4xyo"]
[ext_resource type="Script" uid="uid://cqxj7o8hdm82n" path="res://scripts/resources/entities/ZombieResource.cs" id="9_2qvjb"]
[ext_resource type="Resource" uid="uid://buvacn56kyy2p" path="res://assets/zombies/basic.tres" id="10_gern8"]
[sub_resource type="Resource" id="Resource_u4615"]
script = ExtResource("8_x4xyo")
zombies = Array[ExtResource("9_2qvjb")]([null, ExtResource("10_gern8"), null, null, ExtResource("10_gern8")])
[sub_resource type="Resource" id="Resource_gern8"]
script = ExtResource("8_x4xyo")
zombies = Array[ExtResource("9_2qvjb")]([null, ExtResource("10_gern8"), null, null, ExtResource("10_gern8")])
[sub_resource type="Resource" id="Resource_u7b14"]
script = ExtResource("8_x4xyo")
zombies = Array[ExtResource("9_2qvjb")]([null, ExtResource("10_gern8"), null, null, ExtResource("10_gern8")])
[sub_resource type="Resource" id="Resource_gmxhq"]
script = ExtResource("8_x4xyo")
zombies = Array[ExtResource("9_2qvjb")]([null, ExtResource("10_gern8"), null, null, ExtResource("10_gern8")])
[sub_resource type="Resource" id="Resource_gjnpd"]
script = ExtResource("8_x4xyo")
zombies = Array[ExtResource("9_2qvjb")]([null, ExtResource("10_gern8"), null, null, ExtResource("10_gern8")])
[sub_resource type="Resource" id="Resource_2qvjb"]
script = ExtResource("2_8ahni")
zombiesOrdered = Array[ExtResource("8_x4xyo")]([SubResource("Resource_u4615"), SubResource("Resource_gern8"), SubResource("Resource_u7b14"), SubResource("Resource_gmxhq"), SubResource("Resource_gjnpd")])
events = Array[ExtResource("7_nm8hx")]([])
customWaveDelay = 0.0
isHugeWave = false
[resource]
script = ExtResource("1_nvwhw")
startSun = 50
wavePercentage = 0.0
standardWaveDelay = 10.0
initialWaveDelay = 10.0
reward = ExtResource("5_gern8")
forbiddenPlants = Array[String]([])
forbiddenTags = Array[String]([])
prepickedPlants = Array[String]([])
waves = Array[ExtResource("2_8ahni")]([SubResource("Resource_2qvjb")])
initialScenes = Array[PackedScene]([null, null, null, null, null, null, null, null, null, null, null, ExtResource("2_4or4b"), null, null, ExtResource("1_8ahni"), null, null, null, null, null, ExtResource("2_w7xe8"), null, null, ExtResource("2_4or4b"), null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, ExtResource("3_1dd05"), ExtResource("3_1dd05"), null, null, null])

View file

@ -200,7 +200,7 @@ locale/test="en"
[layer_names] [layer_names]
2d_physics/layer_1="Reserved" 2d_physics/layer_1="Structures"
2d_physics/layer_2="Plants Dummy" 2d_physics/layer_2="Plants Dummy"
2d_physics/layer_3="Plants True" 2d_physics/layer_3="Plants True"
2d_physics/layer_4="Zombies Dummy" 2d_physics/layer_4="Zombies Dummy"
@ -208,6 +208,7 @@ locale/test="en"
2d_physics/layer_6="Projectiles" 2d_physics/layer_6="Projectiles"
2d_physics/layer_7="FallLine" 2d_physics/layer_7="FallLine"
2d_physics/layer_8="FallParticles" 2d_physics/layer_8="FallParticles"
2d_physics/layer_9="Tiles"
[rendering] [rendering]

View file

@ -1,7 +1,7 @@
[gd_scene load_steps=65 format=3 uid="uid://bgqmwsb6ynm81"] [gd_scene load_steps=65 format=3 uid="uid://bgqmwsb6ynm81"]
[ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="1_fnu7s"] [ext_resource type="PackedScene" uid="uid://co11v3w8hbwgf" path="res://scenes/entities/Zombies/zombie.tscn" id="1_fnu7s"]
[ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/GarlicEffect.tres" id="3_b583s"] [ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/RandomRedirectEffect.tres" id="3_b583s"]
[ext_resource type="Script" uid="uid://dt5uj25u0g6y3" path="res://scripts/particles/FallParticle.cs" id="3_tu6af"] [ext_resource type="Script" uid="uid://dt5uj25u0g6y3" path="res://scripts/particles/FallParticle.cs" id="3_tu6af"]
[ext_resource type="Script" uid="uid://c5v2og85t7s6j" path="res://scripts/entities/zombies/behaviours/HoboBehaviour.cs" id="4_5selg"] [ext_resource type="Script" uid="uid://c5v2og85t7s6j" path="res://scripts/entities/zombies/behaviours/HoboBehaviour.cs" id="4_5selg"]
[ext_resource type="Script" uid="uid://c3cfnrmnnuqms" path="res://addons/floatmodifiers/FloatModifiers.cs" id="4_c1y3b"] [ext_resource type="Script" uid="uid://c3cfnrmnnuqms" path="res://addons/floatmodifiers/FloatModifiers.cs" id="4_c1y3b"]

View file

@ -20,7 +20,7 @@
[ext_resource type="Script" uid="uid://cnn0ymuhypdff" path="res://scripts/audio/ChannelPlaylist.cs" id="12_he8da"] [ext_resource type="Script" uid="uid://cnn0ymuhypdff" path="res://scripts/audio/ChannelPlaylist.cs" id="12_he8da"]
[ext_resource type="AudioStream" uid="uid://w0qfwds4o3ti" path="res://assets/audio/sfx/hit_generic.tres" id="12_vjrlo"] [ext_resource type="AudioStream" uid="uid://w0qfwds4o3ti" path="res://assets/audio/sfx/hit_generic.tres" id="12_vjrlo"]
[ext_resource type="Script" uid="uid://b8r6fxsfjdo3a" path="res://scripts/audio/EffectBasedPlayer.cs" id="17_ltj46"] [ext_resource type="Script" uid="uid://b8r6fxsfjdo3a" path="res://scripts/audio/EffectBasedPlayer.cs" id="17_ltj46"]
[ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/GarlicEffect.tres" id="18_2q05d"] [ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/RandomRedirectEffect.tres" id="18_2q05d"]
[ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://assets/effects/SnowSlow.tres" id="19_ccrjo"] [ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://assets/effects/SnowSlow.tres" id="19_ccrjo"]
[ext_resource type="Script" uid="uid://c1x4n4nqyq72f" path="res://scripts/audio/ChannelSettings.cs" id="21_xnora"] [ext_resource type="Script" uid="uid://c1x4n4nqyq72f" path="res://scripts/audio/ChannelSettings.cs" id="21_xnora"]
[ext_resource type="Script" uid="uid://dk32ln8c2574d" path="res://scripts/entities/zombies/ZombieKillHandler.cs" id="23_mc1kl"] [ext_resource type="Script" uid="uid://dk32ln8c2574d" path="res://scripts/entities/zombies/ZombieKillHandler.cs" id="23_mc1kl"]

View file

@ -5,7 +5,7 @@
[ext_resource type="AnimationLibrary" uid="uid://cjl81f61gdlvi" path="res://assets/animations/plants/garlic.res" id="3_jkb3q"] [ext_resource type="AnimationLibrary" uid="uid://cjl81f61gdlvi" path="res://assets/animations/plants/garlic.res" id="3_jkb3q"]
[ext_resource type="Script" uid="uid://btkmd86pn828y" path="res://scripts/entities/plants/behaviours/HpBasedBehaviour.cs" id="4_bv44h"] [ext_resource type="Script" uid="uid://btkmd86pn828y" path="res://scripts/entities/plants/behaviours/HpBasedBehaviour.cs" id="4_bv44h"]
[ext_resource type="Script" uid="uid://bmtukcq10m8wo" path="res://scripts/entities/plants/ReturnEffect.cs" id="5_oob20"] [ext_resource type="Script" uid="uid://bmtukcq10m8wo" path="res://scripts/entities/plants/ReturnEffect.cs" id="5_oob20"]
[ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/GarlicEffect.tres" id="6_gho1l"] [ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://assets/effects/RandomRedirectEffect.tres" id="6_gho1l"]
[sub_resource type="Animation" id="Animation_k0cex"] [sub_resource type="Animation" id="Animation_k0cex"]
length = 0.001 length = 0.001

View file

@ -0,0 +1,22 @@
[gd_scene load_steps=4 format=3 uid="uid://bfooovcq272ks"]
[ext_resource type="Script" uid="uid://cq1dl578rbvrj" path="res://scripts/entities/InvulnerableEntity.cs" id="1_5ykcf"]
[ext_resource type="Script" uid="uid://bd1f7x1nin0i0" path="res://scripts/entities/AreaOfEffect.cs" id="2_qq7uk"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5ykcf"]
size = Vector2(30, 40)
[node name="BaseTile" type="Node2D"]
script = ExtResource("1_5ykcf")
MaxHP = 10.0
completeInvulnerability = true
[node name="Sprite2D" type="Sprite2D" parent="."]
[node name="EffectCollider" type="Area2D" parent="."]
collision_layer = 256
collision_mask = 8
script = ExtResource("2_qq7uk")
[node name="CollisionShape2D" type="CollisionShape2D" parent="EffectCollider"]
shape = SubResource("RectangleShape2D_5ykcf")

View file

@ -0,0 +1,25 @@
[gd_scene load_steps=6 format=3 uid="uid://cp8oadhwu51i7"]
[ext_resource type="PackedScene" uid="uid://bfooovcq272ks" path="res://scenes/entities/tiles/base_tile.tscn" id="1_e3yor"]
[ext_resource type="Texture2D" uid="uid://c68mrfs4wb81x" path="res://assets/sprites/atlases/atlas2.png" id="2_xv011"]
[ext_resource type="Script" uid="uid://blky82wwkqirx" path="res://scripts/systems/effects/RedirectEffect.cs" id="3_q6o68"]
[sub_resource type="AtlasTexture" id="AtlasTexture_q6o68"]
atlas = ExtResource("2_xv011")
region = Rect2(160, 22, 41, 36)
[sub_resource type="Resource" id="Resource_4mqps"]
script = ExtResource("3_q6o68")
tilesWalked = 0.2
down = true
Duration = 1.0
Slot = "redirect"
metadata/_custom_type_script = "uid://blky82wwkqirx"
[node name="RedirectDownTile" instance=ExtResource("1_e3yor")]
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("AtlasTexture_q6o68")
[node name="EffectCollider" parent="." index="1"]
givenEffect = SubResource("Resource_4mqps")

View file

@ -0,0 +1,25 @@
[gd_scene load_steps=6 format=3 uid="uid://d4kee4ipw1k1q"]
[ext_resource type="PackedScene" uid="uid://bfooovcq272ks" path="res://scenes/entities/tiles/base_tile.tscn" id="1_wp3vm"]
[ext_resource type="Texture2D" uid="uid://c68mrfs4wb81x" path="res://assets/sprites/atlases/atlas2.png" id="2_8aumo"]
[ext_resource type="Script" uid="uid://blky82wwkqirx" path="res://scripts/systems/effects/RedirectEffect.cs" id="2_le24f"]
[sub_resource type="AtlasTexture" id="AtlasTexture_ry33t"]
atlas = ExtResource("2_8aumo")
region = Rect2(110, 22, 42, 36)
[sub_resource type="Resource" id="Resource_8aumo"]
script = ExtResource("2_le24f")
tilesWalked = 0.2
down = false
Duration = 1.0
Slot = "redirect"
metadata/_custom_type_script = "uid://blky82wwkqirx"
[node name="RedirectUpTile" instance=ExtResource("1_wp3vm")]
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("AtlasTexture_ry33t")
[node name="EffectCollider" parent="." index="1"]
givenEffect = SubResource("Resource_8aumo")

View file

@ -0,0 +1,24 @@
[gd_scene load_steps=6 format=3 uid="uid://cy0puq5mtnxq7"]
[ext_resource type="PackedScene" uid="uid://bfooovcq272ks" path="res://scenes/entities/tiles/base_tile.tscn" id="1_jktsj"]
[ext_resource type="Texture2D" uid="uid://c68mrfs4wb81x" path="res://assets/sprites/atlases/atlas2.png" id="2_b65si"]
[ext_resource type="Script" uid="uid://3q40oeb4cabf" path="res://scripts/systems/effects/PermanentSpeedEffect.cs" id="3_b65si"]
[sub_resource type="AtlasTexture" id="AtlasTexture_b8lvr"]
atlas = ExtResource("2_b65si")
region = Rect2(260, 22, 42, 36)
[sub_resource type="Resource" id="Resource_b8lvr"]
script = ExtResource("3_b65si")
Multiplier = 0.9
Duration = 0.5
Slot = "permanent_speed"
metadata/_custom_type_script = "uid://3q40oeb4cabf"
[node name="SlowTile" instance=ExtResource("1_jktsj")]
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("AtlasTexture_b8lvr")
[node name="EffectCollider" parent="." index="1"]
givenEffect = SubResource("Resource_b8lvr")

View file

@ -0,0 +1,24 @@
[gd_scene load_steps=6 format=3 uid="uid://c5lplejgx7mex"]
[ext_resource type="PackedScene" uid="uid://bfooovcq272ks" path="res://scenes/entities/tiles/base_tile.tscn" id="1_0mgu2"]
[ext_resource type="Texture2D" uid="uid://c68mrfs4wb81x" path="res://assets/sprites/atlases/atlas2.png" id="2_770cq"]
[ext_resource type="Script" uid="uid://3q40oeb4cabf" path="res://scripts/systems/effects/PermanentSpeedEffect.cs" id="3_770cq"]
[sub_resource type="AtlasTexture" id="AtlasTexture_p8mgt"]
atlas = ExtResource("2_770cq")
region = Rect2(206, 22, 50, 37)
[sub_resource type="Resource" id="Resource_p8mgt"]
script = ExtResource("3_770cq")
Multiplier = 1.2
Duration = 0.5
Slot = "permanent_speed"
metadata/_custom_type_script = "uid://3q40oeb4cabf"
[node name="SpeedTile" instance=ExtResource("1_0mgu2")]
[node name="Sprite2D" parent="." index="0"]
texture = SubResource("AtlasTexture_p8mgt")
[node name="EffectCollider" parent="." index="1"]
givenEffect = SubResource("Resource_p8mgt")

View file

@ -828,7 +828,7 @@ follow_viewport_enabled = true
script = ExtResource("13_0x4ji") script = ExtResource("13_0x4ji")
[node name="Hitbox" type="Area2D" parent="GameOverZombie/LoseZone"] [node name="Hitbox" type="Area2D" parent="GameOverZombie/LoseZone"]
collision_layer = 2 collision_layer = 6
[node name="CollisionShape2D" type="CollisionShape2D" parent="GameOverZombie/LoseZone/Hitbox"] [node name="CollisionShape2D" type="CollisionShape2D" parent="GameOverZombie/LoseZone/Hitbox"]
position = Vector2(122, 199.5) position = Vector2(122, 199.5)

View file

@ -0,0 +1,21 @@
using Godot;
using Newlon.Systems.Effects;
namespace Newlon.Components;
public partial class AreaOfEffect : Area2D
{
[Export] public Effect givenEffect;
public override void _Ready()
{
AreaEntered += OnAreaEntered;
}
public void OnAreaEntered(Area2D what)
{
if (what.GetParent() is Entity entity)
{
entity.GiveEffect(givenEffect);
}
}
}

View file

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

View file

@ -0,0 +1,14 @@
using Godot;
namespace Newlon.Components;
public partial class InvulnerableEntity : Entity
{
public override void TakeDamage(float amount, Node origin)
{
}
public override void Heal(float amount, Node origin)
{
}
}

View file

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

View file

@ -2,6 +2,7 @@ using Godot;
namespace Newlon.Systems.Effects; namespace Newlon.Systems.Effects;
[GlobalClass]
public abstract partial class Effect : Resource public abstract partial class Effect : Resource
{ {
[Export] public float Duration; [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 Godot;
using Newlon.Components; using Newlon.Components;
using System;
namespace Newlon.Systems.Effects; namespace Newlon.Systems.Effects;
[GlobalClass]
public partial class SlownessEffect : Effect public partial class SlownessEffect : Effect
{ {
[Export] public Color ColorOverride; [Export] public Color ColorOverride;
@ -29,6 +29,6 @@ public partial class SlownessEffect : Effect
public override void Process(Node target) public override void Process(Node target)
{ {
} }
} }