Garlic
This commit is contained in:
parent
34638272aa
commit
2e3226b5c1
14 changed files with 200 additions and 10 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 12 KiB After Width: | Height: | Size: 5 KiB |
7
assets/sprites/plants/garlic.tres
Normal file
7
assets/sprites/plants/garlic.tres
Normal file
|
|
@ -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)
|
||||||
BIN
resources/animations/plants/garlic.res
Normal file
BIN
resources/animations/plants/garlic.res
Normal file
Binary file not shown.
8
resources/effects/GarlicEffect.tres
Normal file
8
resources/effects/GarlicEffect.tres
Normal file
|
|
@ -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
|
||||||
|
|
@ -7,4 +7,4 @@ script = ExtResource("1_8md01")
|
||||||
ColorOverride = Color(0, 1, 1, 1)
|
ColorOverride = Color(0, 1, 1, 1)
|
||||||
Multiplier = 0.75
|
Multiplier = 0.75
|
||||||
Duration = 3.25
|
Duration = 3.25
|
||||||
Slot = 2
|
Slot = 0
|
||||||
|
|
|
||||||
14
resources/plants/Garlic.tres
Normal file
14
resources/plants/Garlic.tres
Normal file
|
|
@ -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
|
||||||
|
|
@ -50,19 +50,19 @@ wait_time = 5.0
|
||||||
autostart = true
|
autostart = true
|
||||||
|
|
||||||
[node name="Zombie" parent="." instance=ExtResource("9_vwrdf")]
|
[node name="Zombie" parent="." instance=ExtResource("9_vwrdf")]
|
||||||
position = Vector2(806, 254)
|
position = Vector2(806, 134)
|
||||||
_line = 3
|
_line = 3
|
||||||
|
|
||||||
[node name="Zombie2" parent="." instance=ExtResource("9_vwrdf")]
|
[node name="Zombie2" parent="." instance=ExtResource("9_vwrdf")]
|
||||||
position = Vector2(824, 254)
|
position = Vector2(824, 134)
|
||||||
_line = 3
|
_line = 3
|
||||||
|
|
||||||
[node name="Zombie3" parent="." instance=ExtResource("9_vwrdf")]
|
[node name="Zombie3" parent="." instance=ExtResource("9_vwrdf")]
|
||||||
position = Vector2(779, 254)
|
position = Vector2(779, 134)
|
||||||
_line = 3
|
_line = 3
|
||||||
|
|
||||||
[node name="Zombie4" parent="." instance=ExtResource("9_vwrdf")]
|
[node name="Zombie4" parent="." instance=ExtResource("9_vwrdf")]
|
||||||
position = Vector2(848, 254)
|
position = Vector2(848, 134)
|
||||||
_line = 3
|
_line = 3
|
||||||
|
|
||||||
[node name="Zombie5" parent="." instance=ExtResource("9_vwrdf")]
|
[node name="Zombie5" parent="." instance=ExtResource("9_vwrdf")]
|
||||||
|
|
|
||||||
82
scenes/entities/plants/garlic.tscn
Normal file
82
scenes/entities/plants/garlic.tscn
Normal file
|
|
@ -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"]
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=5 format=3 uid="uid://domeukw4ucmyr"]
|
[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="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"]
|
[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"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_ix1sk"]
|
||||||
|
|
@ -13,7 +13,7 @@ collision_mask = 8
|
||||||
script = ExtResource("1_fkydi")
|
script = ExtResource("1_fkydi")
|
||||||
_speed = 3.0
|
_speed = 3.0
|
||||||
_damage = 10
|
_damage = 10
|
||||||
_impactEffect = ExtResource("2_txupr")
|
_impactEffect = ExtResource("2_fn62x")
|
||||||
_damageType = 1
|
_damageType = 1
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
|
|
|
||||||
|
|
@ -14,13 +14,13 @@ public class Utility
|
||||||
//
|
//
|
||||||
#region Enums
|
#region Enums
|
||||||
|
|
||||||
public enum EffectSlots {FREEZE, STUN, POISON, BEBRA};
|
public enum EffectSlots {FREEZE, STUN, POISON, GARLIC};
|
||||||
|
|
||||||
public enum DamageTypes {PHYSICAL, ICE};
|
public enum DamageTypes {PHYSICAL, ICE};
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public const int EffectSlotCount = 3;
|
public const int EffectSlotCount = 4;
|
||||||
public const int LineCount = 5;
|
public const int LineCount = 5;
|
||||||
public const int TileWidth = 50;
|
public const int TileWidth = 50;
|
||||||
public const int TileHeight = 60;
|
public const int TileHeight = 60;
|
||||||
|
|
|
||||||
19
scripts/components/plants/ReturnEffect.cs
Normal file
19
scripts/components/plants/ReturnEffect.cs
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -15,7 +15,8 @@ public partial class EatBox : Area2D
|
||||||
|
|
||||||
public void Bite()
|
public void Bite()
|
||||||
{
|
{
|
||||||
plant?.TakeDamage(_damage,GetParent());
|
if (GetParent<RuntimeZombieData>().AbleToEat)
|
||||||
|
plant?.TakeDamage(_damage,GetParent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnAreaEntered(Area2D area)
|
public void OnAreaEntered(Area2D area)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@ public partial class RuntimeZombieData : Node2D, IEntity, ILocalTimescale, IEffe
|
||||||
|
|
||||||
public int Line => _line;
|
public int Line => _line;
|
||||||
|
|
||||||
|
public bool AbleToEat = true;
|
||||||
|
|
||||||
public float LocalTimescale
|
public float LocalTimescale
|
||||||
{
|
{
|
||||||
get => _localTimescale;
|
get => _localTimescale;
|
||||||
|
|
|
||||||
57
scripts/systems/effects/GarlicEffect.cs
Normal file
57
scripts/systems/effects/GarlicEffect.cs
Normal 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)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue