diff --git a/assets/plants/Aloe.tres b/assets/plants/Aloe.tres index 29afa64..d2229a7 100644 --- a/assets/plants/Aloe.tres +++ b/assets/plants/Aloe.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_vw2kg") -Tags = [] Layer = 1 DontRegister = false NameKey = "aloe" @@ -17,6 +16,3 @@ ReloadTime = 15.0 ReloadProgress = 0.0 Preview = ExtResource("1_t4137") Order = 6 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/Cucumber.tres b/assets/plants/Cucumber.tres index 80d4300..3dca246 100644 --- a/assets/plants/Cucumber.tres +++ b/assets/plants/Cucumber.tres @@ -10,7 +10,6 @@ region = Rect2(2, 1, 41, 65) [resource] script = ExtResource("1_jrx81") -Tags = [] Layer = 1 DontRegister = false NameKey = "cucumber" @@ -21,7 +20,4 @@ ReloadTime = 5.0 ReloadProgress = 0.0 Preview = SubResource("AtlasTexture_3gogt") Order = 8 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) metadata/_custom_type_script = "uid://cyenlko1knygw" diff --git a/assets/plants/Garlic.tres b/assets/plants/Garlic.tres index fc697e4..9b19b7b 100644 --- a/assets/plants/Garlic.tres +++ b/assets/plants/Garlic.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_e15gf") -Tags = [] Layer = 1 DontRegister = false NameKey = "garlic" @@ -17,6 +16,3 @@ ReloadTime = 7.5 ReloadProgress = 0.67 Preview = ExtResource("1_datic") Order = 7 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/Nerdus.tres b/assets/plants/Nerdus.tres index f93600d..90aeb8d 100644 --- a/assets/plants/Nerdus.tres +++ b/assets/plants/Nerdus.tres @@ -19,5 +19,5 @@ Scene = ExtResource("2_0i6qf") ReloadTime = 10.0 ReloadProgress = 0.0 Preview = SubResource("AtlasTexture_ivp5w") -Order = 11 +Order = 10 metadata/_custom_type_script = "uid://cyenlko1knygw" diff --git a/assets/plants/Peashooter.tres b/assets/plants/Peashooter.tres index 1fde53e..cf3a204 100644 --- a/assets/plants/Peashooter.tres +++ b/assets/plants/Peashooter.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_amvh8") -Tags = [] Layer = 1 DontRegister = false NameKey = "peashooter" @@ -17,6 +16,3 @@ ReloadTime = 5.0 ReloadProgress = 0.0 Preview = ExtResource("1_rnq6r") Order = 0 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/PotatoMine.tres b/assets/plants/PotatoMine.tres index 0a87b1a..1abf969 100644 --- a/assets/plants/PotatoMine.tres +++ b/assets/plants/PotatoMine.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_33j6b") -Tags = [] Layer = 1 DontRegister = false NameKey = "potatomine" @@ -17,6 +16,3 @@ ReloadTime = 25.0 ReloadProgress = 0.9 Preview = ExtResource("1_xk2pg") Order = 3 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/Snipach.tres b/assets/plants/Snipach.tres new file mode 100644 index 0000000..501a276 --- /dev/null +++ b/assets/plants/Snipach.tres @@ -0,0 +1,23 @@ +[gd_resource type="Resource" script_class="PlantResource" load_steps=5 format=3 uid="uid://drb8nk0i3oyyl"] + +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_1eecn"] +[ext_resource type="PackedScene" uid="uid://bmk41n57j7hgx" path="res://scenes/entities/plants/snipach.tscn" id="1_h5ln5"] +[ext_resource type="Script" uid="uid://cyenlko1knygw" path="res://scripts/resources/entities/PlantResource.cs" id="1_u5a4p"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_dgfdr"] +atlas = ExtResource("1_1eecn") +region = Rect2(525, 241, 79, 72) + +[resource] +script = ExtResource("1_u5a4p") +Layer = 1 +DontRegister = false +NameKey = "snipach" +DescriptionKey = "snipach_desc" +Cost = 400.0 +Scene = ExtResource("1_h5ln5") +ReloadTime = 7.5 +ReloadProgress = 0.0 +Preview = SubResource("AtlasTexture_dgfdr") +Order = 11 +metadata/_custom_type_script = "uid://cyenlko1knygw" diff --git a/assets/plants/Snowpea.tres b/assets/plants/Snowpea.tres index cc4c8a3..13bc7d0 100644 --- a/assets/plants/Snowpea.tres +++ b/assets/plants/Snowpea.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_0cpi0") -Tags = [] Layer = 1 DontRegister = false NameKey = "snowpea" @@ -17,6 +16,3 @@ ReloadTime = 5.0 ReloadProgress = 0.0 Preview = ExtResource("1_7fyy2") Order = 5 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/Spikeweed.tres b/assets/plants/Spikeweed.tres index 743221b..4502b23 100644 --- a/assets/plants/Spikeweed.tres +++ b/assets/plants/Spikeweed.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_0bymo") -Tags = [] Layer = 1 DontRegister = false NameKey = "spikeweed" @@ -17,6 +16,3 @@ ReloadTime = 5.0 ReloadProgress = 0.0 Preview = ExtResource("1_2ol2i") Order = 4 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/Sunflower.tres b/assets/plants/Sunflower.tres index 7a730b4..9c2c30f 100644 --- a/assets/plants/Sunflower.tres +++ b/assets/plants/Sunflower.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("3_vt4jc") -Tags = [] Layer = 1 DontRegister = false NameKey = "sunflower" @@ -17,6 +16,3 @@ ReloadTime = 5.0 ReloadProgress = 1.0 Preview = ExtResource("1_8rd5i") Order = 1 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/plants/Threepeater.tres b/assets/plants/Threepeater.tres index 30757ad..d6348e9 100644 --- a/assets/plants/Threepeater.tres +++ b/assets/plants/Threepeater.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("3_3lugi") -Tags = [] Layer = 1 DontRegister = false NameKey = "threepeater" @@ -16,7 +15,4 @@ Scene = ExtResource("2_uqpu0") ReloadTime = 5.0 ReloadProgress = 0.0 Preview = ExtResource("1_hinp6") -Order = 10 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) +Order = 9 diff --git a/assets/plants/Wallnut.tres b/assets/plants/Wallnut.tres index 7f38263..dc3ab26 100644 --- a/assets/plants/Wallnut.tres +++ b/assets/plants/Wallnut.tres @@ -6,7 +6,6 @@ [resource] script = ExtResource("1_27l0t") -Tags = [] Layer = 1 DontRegister = false NameKey = "wallnut" @@ -17,6 +16,3 @@ ReloadTime = 20.0 ReloadProgress = 0.0 Preview = ExtResource("1_2akap") Order = 2 -Parameters = Dictionary[String, float]({ -"max_hp": 30.0 -}) diff --git a/assets/sprites/atlases/atlas1.png b/assets/sprites/atlases/atlas1.png index 0804d21..c96795c 100644 Binary files a/assets/sprites/atlases/atlas1.png and b/assets/sprites/atlases/atlas1.png differ diff --git a/project.godot b/project.godot index 3aaf06e..751a535 100644 --- a/project.godot +++ b/project.godot @@ -136,6 +136,7 @@ locale/test="en" 2d_physics/layer_3="Plants True" 2d_physics/layer_4="Zombies Dummy" 2d_physics/layer_5="Zombies True" +2d_physics/layer_6="Projectiles" 2d_physics/layer_7="FallLine" 2d_physics/layer_8="FallParticles" diff --git a/scenes/entities/Zombies/zombie.tscn b/scenes/entities/Zombies/zombie.tscn index 83be5f7..4117e84 100644 --- a/scenes/entities/Zombies/zombie.tscn +++ b/scenes/entities/Zombies/zombie.tscn @@ -868,7 +868,7 @@ metadata/_edit_lock_ = true [node name="LeftLowerLeg" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/LeftUpperLeg"] position = Vector2(-1, 13) -scale = Vector2(0.999835, 0.999835) +scale = Vector2(0.999834, 0.999834) rest = Transform2D(1, 0, 0, 1, -1, 13) editor_settings/show_bone_gizmo = false @@ -922,7 +922,7 @@ editor_settings/show_bone_gizmo = false [node name="RightHand" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/RightUpperArm/RightLowerArm"] position = Vector2(-1, 13) -scale = Vector2(0.999827, 0.999827) +scale = Vector2(0.999828, 0.999828) rest = Transform2D(1, 0, 0, 1, -1, 13) auto_calculate_length_and_angle = false length = 8.0 @@ -950,7 +950,7 @@ metadata/_edit_lock_ = true [node name="Tie" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"] position = Vector2(-9, -21) -rotation = -0.0584133 +rotation = -0.151557 skew = -0.000476003 rest = Transform2D(1, 0, 0, 1, -9, -21) auto_calculate_length_and_angle = false @@ -966,7 +966,7 @@ metadata/_edit_lock_ = true [node name="Head" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"] position = Vector2(-10, -25) -scale = Vector2(0.999828, 0.999828) +scale = Vector2(0.999829, 0.999829) rest = Transform2D(1, 0, 0, 1, -10, -25) editor_settings/show_bone_gizmo = false @@ -988,7 +988,7 @@ offset = Vector2(-20, -24) metadata/_edit_lock_ = true [node name="Right_Eye" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"] -position = Vector2(-16, -8.00001) +position = Vector2(-16, -8) texture = SubResource("AtlasTexture_vcc72") centered = false offset = Vector2(-2, -2) @@ -1002,8 +1002,8 @@ offset = Vector2(-2, -2) metadata/_edit_lock_ = true [node name="Jaw" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/Head/HeadParticle/Head"] -position = Vector2(-2.68751, 2.2458) -rotation = 0.00598567 +position = Vector2(-2.81092, 2.54366) +rotation = -0.107471 scale = Vector2(0.99983, 0.99983) texture = SubResource("AtlasTexture_x5uj2") centered = false @@ -1055,7 +1055,7 @@ remote_path = NodePath("../../HeadParticle/Head/Left_Eye") [node name="LeftUpperArm" type="Bone2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body"] position = Vector2(-1, -20) -scale = Vector2(0.999832, 0.999832) +scale = Vector2(0.999831, 0.999831) rest = Transform2D(1, 0, 0, 1, -1, -20) editor_settings/show_bone_gizmo = false @@ -1077,8 +1077,8 @@ minTorque = -45.0 maxTorque = 45.0 [node name="Left_Lower_Arm" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile"] -rotation = 0.0631719 -scale = Vector2(0.999997, 0.999997) +rotation = -0.160747 +scale = Vector2(0.999998, 0.999998) texture = SubResource("AtlasTexture_auqeq") centered = false offset = Vector2(-5, 0) @@ -1086,9 +1086,9 @@ metadata/_edit_lock_ = true [node name="Left_Hand" type="Sprite2D" parent="CanvasGroup/basic_zombie_walk/Zombie/Butt/Body/LeftUpperArm/HandProjectile/Left_Lower_Arm"] show_behind_parent = true -position = Vector2(-0.99983, 12.9978) -rotation = -0.123862 -scale = Vector2(0.999657, 0.999657) +position = Vector2(-0.999828, 12.9978) +rotation = -0.133017 +scale = Vector2(0.999656, 0.999656) texture = SubResource("AtlasTexture_vlvtp") centered = false offset = Vector2(-4, -1) @@ -1165,7 +1165,7 @@ entity = NodePath("..") [node name="Mover" type="Node" parent="."] script = ExtResource("4_u5syx") _speed = SubResource("Resource_ckb7n") -_speedControlMult = 2.03653 +_speedControlMult = 1.02866 [node name="HitPlayer" type="Node" parent="."] script = ExtResource("12_he8da") diff --git a/scenes/entities/plants/snipach.tscn b/scenes/entities/plants/snipach.tscn new file mode 100644 index 0000000..23319ae --- /dev/null +++ b/scenes/entities/plants/snipach.tscn @@ -0,0 +1,85 @@ +[gd_scene load_steps=13 format=3 uid="uid://bmk41n57j7hgx"] + +[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_ltcu2"] +[ext_resource type="Shader" uid="uid://cgc7spjkhsx7c" path="res://assets/shaders/generic_flash.gdshader" id="2_ktw4a"] +[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="3_ktw4a"] +[ext_resource type="Script" uid="uid://cu63aiowp5bqd" path="res://scripts/entities/plants/DragAction.cs" id="4_5jowj"] +[ext_resource type="Script" uid="uid://co7ttejdo2qot" path="res://scripts/entities/plants/AreaAttack.cs" id="5_twsk4"] +[ext_resource type="Script" uid="uid://csgksiyma0h4t" path="res://scripts/entities/plants/behaviours/SnipachBehaviour.cs" id="6_twsk4"] +[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/TimeScalableTimer.cs" id="7_3hyni"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_f4wwx"] +resource_local_to_scene = true +shader = ExtResource("2_ktw4a") +shader_parameter/FLASH_COLOR = Color(0.78, 0.78, 0.78, 0.501961) +shader_parameter/HIGHLIGHT_COLOR = Color(0.69, 0, 0, 0.282353) +shader_parameter/selected = false +shader_parameter/blend = 0.0 + +[sub_resource type="AtlasTexture" id="AtlasTexture_f4wwx"] +atlas = ExtResource("3_ktw4a") +region = Rect2(525, 241, 79, 72) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ktw4a"] +size = Vector2(37, 66) + +[sub_resource type="AtlasTexture" id="AtlasTexture_3hyni"] +atlas = ExtResource("3_ktw4a") +region = Rect2(592, 64, 50, 60) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_5jowj"] +size = Vector2(40, 36) + +[node name="Snipach" instance=ExtResource("1_ltcu2")] +internal_id = "snipach" +MaxHP = 30.0 + +[node name="Sprite2D" parent="." index="0"] +material = SubResource("ShaderMaterial_f4wwx") +position = Vector2(8, -16) +texture = SubResource("AtlasTexture_f4wwx") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] +position = Vector2(-2, -13) +shape = SubResource("RectangleShape2D_ktw4a") + +[node name="DragAction" type="Node" parent="Hitbox" index="1"] +script = ExtResource("4_5jowj") + +[node name="FlashController" parent="." index="4"] +shaderMaterial = SubResource("ShaderMaterial_f4wwx") + +[node name="ShootBox" type="Area2D" parent="." index="5"] +visible = false +collision_layer = 32 +collision_mask = 24 +input_pickable = false +script = ExtResource("5_twsk4") +_damage = 400 + +[node name="Sprite2D" type="Sprite2D" parent="ShootBox" index="0"] +texture = SubResource("AtlasTexture_3hyni") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="ShootBox" index="1"] +shape = SubResource("RectangleShape2D_5jowj") + +[node name="Behaviour" type="Node" parent="." index="6" node_paths=PackedStringArray("attackBox", "timer", "guardTimer")] +script = ExtResource("6_twsk4") +attackBox = NodePath("../ShootBox") +timer = NodePath("Timer") +guardTimer = NodePath("GuardTimer") + +[node name="Timer" type="Timer" parent="Behaviour" index="0" node_paths=PackedStringArray("entity")] +wait_time = 15.0 +one_shot = true +script = ExtResource("7_3hyni") +entity = NodePath("../..") + +[node name="GuardTimer" type="Timer" parent="Behaviour" index="1"] +wait_time = 0.2 +one_shot = true +autostart = true +ignore_time_scale = true + +[connection signal="DragBegin" from="Hitbox/DragAction" to="Behaviour" method="OnDragBegin"] +[connection signal="DragEnd" from="Hitbox/DragAction" to="Behaviour" method="OnDragEnd"] diff --git a/scenes/entities/plants/spikeweed.tscn b/scenes/entities/plants/spikeweed.tscn index 870291f..6375ed5 100644 --- a/scenes/entities/plants/spikeweed.tscn +++ b/scenes/entities/plants/spikeweed.tscn @@ -54,7 +54,6 @@ material = SubResource("ShaderMaterial_yfuxj") texture = ExtResource("2_ffrjr") hframes = 10 vframes = 2 -frame = 1 [node name="AnimationPlayer" parent="." index="1"] libraries = { diff --git a/scripts/entities/plants/DragAction.cs b/scripts/entities/plants/DragAction.cs new file mode 100644 index 0000000..b672106 --- /dev/null +++ b/scripts/entities/plants/DragAction.cs @@ -0,0 +1,32 @@ +using Godot; + +namespace Newlon.Components.Plants; + +public partial class DragAction : Node +{ + [Signal] public delegate void DragBeginEventHandler(); + [Signal] public delegate void DragEndEventHandler(); + private bool dragging = false; + + public override void _Ready() + { + GetParent().InputEvent += OnInputEvent; + } + public void OnInputEvent(Node viewport, InputEvent @event, long shape_index) + { + if (@event.IsActionPressed("primary_action")) + { + dragging = true; + EmitSignal(SignalName.DragBegin); + } + } + public override void _Input(InputEvent @event) + { + if (dragging && @event.IsActionReleased("primary_action")) + { + dragging = false; + EmitSignal(SignalName.DragEnd); + } + } + +} diff --git a/scripts/entities/plants/DragAction.cs.uid b/scripts/entities/plants/DragAction.cs.uid new file mode 100644 index 0000000..1a68ba3 --- /dev/null +++ b/scripts/entities/plants/DragAction.cs.uid @@ -0,0 +1 @@ +uid://cu63aiowp5bqd diff --git a/scripts/entities/plants/behaviours/SnipachBehaviour.cs b/scripts/entities/plants/behaviours/SnipachBehaviour.cs new file mode 100644 index 0000000..1f0f329 --- /dev/null +++ b/scripts/entities/plants/behaviours/SnipachBehaviour.cs @@ -0,0 +1,36 @@ +using Godot; + +namespace Newlon.Components.Plants; + +public partial class SnipachBehaviour : BaseBehaviour +{ + [Export] public AreaAttack attackBox; + [Export] public Timer timer; + [Export] public Timer guardTimer; + private bool dragging = false; + + public void OnDragBegin() + { + if (timer.TimeLeft > 0 || guardTimer.TimeLeft > 0) return; + dragging = true; + attackBox.Visible = dragging; + } + + public void OnDragEnd() + { + if (dragging == false) return; + attackBox.Attack(); + dragging = false; + attackBox.Visible = dragging; + timer.Start(); + } + + public override void _PhysicsProcess(double delta) + { + if (dragging) + { + attackBox.GlobalPosition = (attackBox.GetGlobalMousePosition() / FieldParams.Tile).Ceil() * FieldParams.Tile - new Vector2(20, 14); + } + } + +} diff --git a/scripts/entities/plants/behaviours/SnipachBehaviour.cs.uid b/scripts/entities/plants/behaviours/SnipachBehaviour.cs.uid new file mode 100644 index 0000000..08f907f --- /dev/null +++ b/scripts/entities/plants/behaviours/SnipachBehaviour.cs.uid @@ -0,0 +1 @@ +uid://csgksiyma0h4t diff --git a/translations/plants.csv b/translations/plants.csv index 8d50652..4d161f1 100644 --- a/translations/plants.csv +++ b/translations/plants.csv @@ -83,3 +83,11 @@ Firerate: [color=darkred] {FireTimer.wait_time} seconds[/color].","Он имее Время перезарядки: [color=darkred]{ReloadTime} секунд[/color]. Урон семечка: [color=darkred] {_damage}[/color]. Скорость стрельбы: [color=darkred]{FireTimer.wait_time} секунд[/color]." +snipach,Snipach,Спинат +snipach_desc,"Health points: [color=DARK_RED]{MaxHP}[/color] +Reload time: [color=DARK_RED]{ReloadTime} seconds[/color]. +Shot damage: [color=darkred]{_damage}[/color]. +Ability recharge: [color=darkred]{Timer.wait_time}[/color].","Очки здоровья: [color=DARK_RED]{MaxHP}[/color] +Время перезарядки: [color=DARK_RED]{ReloadTime} секунд[/color]. +Урон за выстрел: [color=darkred]{_damage}[/color]. +Перезарядка способности: [color=darkred]{Timer.wait_time}[/color]." diff --git a/translations/plants.en.translation b/translations/plants.en.translation index 7d65083..9729c48 100644 Binary files a/translations/plants.en.translation and b/translations/plants.en.translation differ diff --git a/translations/plants.ru.translation b/translations/plants.ru.translation index 436e21c..1d66222 100644 Binary files a/translations/plants.ru.translation and b/translations/plants.ru.translation differ