diff --git a/assets/sprites/atlases/plants/garlic.png b/assets/sprites/atlases/plants/garlic.png index 66cd4cc..97fb034 100644 Binary files a/assets/sprites/atlases/plants/garlic.png and b/assets/sprites/atlases/plants/garlic.png differ diff --git a/assets/sprites/plants/garlic.tres b/assets/sprites/plants/garlic.tres new file mode 100644 index 0000000..af97d2a --- /dev/null +++ b/assets/sprites/plants/garlic.tres @@ -0,0 +1,7 @@ +[gd_resource type="AtlasTexture" load_steps=2 format=3 uid="uid://m8e84blnx7yu"] + +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_el55x"] + +[resource] +atlas = ExtResource("1_el55x") +region = Rect2(356, 16, 39, 41) diff --git a/resources/animations/plants/garlic.res b/resources/animations/plants/garlic.res new file mode 100644 index 0000000..949d51c Binary files /dev/null and b/resources/animations/plants/garlic.res differ diff --git a/resources/effects/GarlicEffect.tres b/resources/effects/GarlicEffect.tres new file mode 100644 index 0000000..60edc9c --- /dev/null +++ b/resources/effects/GarlicEffect.tres @@ -0,0 +1,8 @@ +[gd_resource type="Resource" load_steps=2 format=3 uid="uid://dsg1vjx76ifgu"] + +[ext_resource type="Script" path="res://scripts/systems/effects/GarlicEffect.cs" id="1_rfumy"] + +[resource] +script = ExtResource("1_rfumy") +Duration = 0.25 +Slot = 3 diff --git a/resources/effects/SnowSlow.tres b/resources/effects/SnowSlow.tres index 59111f0..5851046 100644 --- a/resources/effects/SnowSlow.tres +++ b/resources/effects/SnowSlow.tres @@ -7,4 +7,4 @@ script = ExtResource("1_8md01") ColorOverride = Color(0, 1, 1, 1) Multiplier = 0.75 Duration = 3.25 -Slot = 2 +Slot = 0 diff --git a/resources/plants/Garlic.tres b/resources/plants/Garlic.tres new file mode 100644 index 0000000..87cee87 --- /dev/null +++ b/resources/plants/Garlic.tres @@ -0,0 +1,14 @@ +[gd_resource type="Resource" script_class="PlantResource" load_steps=4 format=3 uid="uid://btkkaow4tyw55"] + +[ext_resource type="Texture2D" uid="uid://m8e84blnx7yu" path="res://assets/sprites/plants/garlic.tres" id="1_datic"] +[ext_resource type="Script" path="res://scripts/resources/PlantResource.cs" id="1_e15gf"] +[ext_resource type="PackedScene" uid="uid://bes4e6sksax67" path="res://scenes/entities/plants/garlic.tscn" id="2_81n0p"] + +[resource] +script = ExtResource("1_e15gf") +Cost = 50 +Scene = ExtResource("2_81n0p") +ReloadTime = 7.5 +ReloadProgress = 0.67 +Preview = ExtResource("1_datic") +Layer = 1 diff --git a/scenes/debug_lvl.tscn b/scenes/debug_lvl.tscn index b600621..44f0aff 100644 --- a/scenes/debug_lvl.tscn +++ b/scenes/debug_lvl.tscn @@ -50,19 +50,19 @@ wait_time = 5.0 autostart = true [node name="Zombie" parent="." instance=ExtResource("9_vwrdf")] -position = Vector2(806, 254) +position = Vector2(806, 134) _line = 3 [node name="Zombie2" parent="." instance=ExtResource("9_vwrdf")] -position = Vector2(824, 254) +position = Vector2(824, 134) _line = 3 [node name="Zombie3" parent="." instance=ExtResource("9_vwrdf")] -position = Vector2(779, 254) +position = Vector2(779, 134) _line = 3 [node name="Zombie4" parent="." instance=ExtResource("9_vwrdf")] -position = Vector2(848, 254) +position = Vector2(848, 134) _line = 3 [node name="Zombie5" parent="." instance=ExtResource("9_vwrdf")] diff --git a/scenes/entities/plants/garlic.tscn b/scenes/entities/plants/garlic.tscn new file mode 100644 index 0000000..e8a2d5b --- /dev/null +++ b/scenes/entities/plants/garlic.tscn @@ -0,0 +1,82 @@ +[gd_scene load_steps=14 format=3 uid="uid://bes4e6sksax67"] + +[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_5i0e6"] +[ext_resource type="Texture2D" uid="uid://dff73m8ahamaa" path="res://assets/sprites/atlases/plants/garlic.png" id="2_w2jbi"] +[ext_resource type="AnimationLibrary" uid="uid://cjl81f61gdlvi" path="res://resources/animations/plants/garlic.res" id="3_jkb3q"] +[ext_resource type="Script" path="res://scripts/components/plants/behaviours/HpBasedBehaviour.cs" id="4_bv44h"] +[ext_resource type="Script" path="res://scripts/components/plants/ReturnEffect.cs" id="5_oob20"] +[ext_resource type="Resource" uid="uid://dsg1vjx76ifgu" path="res://resources/effects/GarlicEffect.tres" id="6_gho1l"] + +[sub_resource type="Animation" id="Animation_k0cex"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:frame") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_v4l78"] +_data = { +"RESET": SubResource("Animation_k0cex") +} + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_mdv0r"] +animation = &"garlic/full_hp" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j5xqj"] +animation = &"garlic/half_hp" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_tlgpl"] +animation = &"garlic/low_hp" + +[sub_resource type="AnimationNodeBlendSpace1D" id="AnimationNodeBlendSpace1D_8mvpm"] +blend_point_0/node = SubResource("AnimationNodeAnimation_mdv0r") +blend_point_0/pos = 1.0 +blend_point_1/node = SubResource("AnimationNodeAnimation_j5xqj") +blend_point_1/pos = 0.7 +blend_point_2/node = SubResource("AnimationNodeAnimation_tlgpl") +blend_point_2/pos = 0.3 +min_space = 0.0 +blend_mode = 1 + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_thlvs"] +size = Vector2(32, 29) + +[node name="Garlic" instance=ExtResource("1_5i0e6")] +_maxHP = 600 + +[node name="Sprite2D" parent="." index="0"] +texture = ExtResource("2_w2jbi") +hframes = 8 +vframes = 3 + +[node name="AnimationPlayer" parent="." index="1"] +libraries = { +"": SubResource("AnimationLibrary_v4l78"), +"garlic": ExtResource("3_jkb3q") +} + +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeBlendSpace1D_8mvpm") +parameters/blend_position = 1.0 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] +position = Vector2(1, 11.5) +shape = SubResource("RectangleShape2D_thlvs") + +[node name="Behaviour" type="Node" parent="." index="4"] +script = ExtResource("4_bv44h") + +[node name="ReturnEffect" type="Node" parent="." index="5"] +script = ExtResource("5_oob20") +_effectToReturn = ExtResource("6_gho1l") + +[connection signal="OnHPChanged" from="." to="Behaviour" method="OnHPChanged"] +[connection signal="OnHPChanged" from="." to="ReturnEffect" method="OnDamageRecieved"] diff --git a/scenes/projectiles/snowpea_projectile.tscn b/scenes/projectiles/snowpea_projectile.tscn index bd0187a..b141c84 100644 --- a/scenes/projectiles/snowpea_projectile.tscn +++ b/scenes/projectiles/snowpea_projectile.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=5 format=3 uid="uid://domeukw4ucmyr"] [ext_resource type="Script" path="res://scripts/components/LinearProjectile.cs" id="1_fkydi"] -[ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://resources/effects/SnowSlow.tres" id="2_txupr"] +[ext_resource type="Resource" uid="uid://7uj0oe656jfx" path="res://resources/effects/SnowSlow.tres" id="2_fn62x"] [ext_resource type="Texture2D" uid="uid://dn4l67snkx5mr" path="res://assets/sprites/plants/snowpea_projectile.tres" id="2_xt8td"] [sub_resource type="CircleShape2D" id="CircleShape2D_ix1sk"] @@ -13,7 +13,7 @@ collision_mask = 8 script = ExtResource("1_fkydi") _speed = 3.0 _damage = 10 -_impactEffect = ExtResource("2_txupr") +_impactEffect = ExtResource("2_fn62x") _damageType = 1 [node name="Sprite" type="Sprite2D" parent="."] diff --git a/scripts/Utility.cs b/scripts/Utility.cs index ba2e1d2..7de042a 100644 --- a/scripts/Utility.cs +++ b/scripts/Utility.cs @@ -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; diff --git a/scripts/components/plants/ReturnEffect.cs b/scripts/components/plants/ReturnEffect.cs new file mode 100644 index 0000000..149e8b5 --- /dev/null +++ b/scripts/components/plants/ReturnEffect.cs @@ -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); + } + } +} diff --git a/scripts/components/zombies/EatBox.cs b/scripts/components/zombies/EatBox.cs index 79b2604..6645255 100644 --- a/scripts/components/zombies/EatBox.cs +++ b/scripts/components/zombies/EatBox.cs @@ -15,7 +15,8 @@ public partial class EatBox : Area2D public void Bite() { - plant?.TakeDamage(_damage,GetParent()); + if (GetParent().AbleToEat) + plant?.TakeDamage(_damage,GetParent()); } public void OnAreaEntered(Area2D area) diff --git a/scripts/components/zombies/RuntimeZombieData.cs b/scripts/components/zombies/RuntimeZombieData.cs index d4da31d..17893f6 100644 --- a/scripts/components/zombies/RuntimeZombieData.cs +++ b/scripts/components/zombies/RuntimeZombieData.cs @@ -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; diff --git a/scripts/systems/effects/GarlicEffect.cs b/scripts/systems/effects/GarlicEffect.cs new file mode 100644 index 0000000..d48a60a --- /dev/null +++ b/scripts/systems/effects/GarlicEffect.cs @@ -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) + { + + } +}