diff --git a/assets/sprites/atlases/plants/peashooter.png b/assets/sprites/atlases/plants/peashooter.png index a7ad42d..dcd4665 100644 Binary files a/assets/sprites/atlases/plants/peashooter.png and b/assets/sprites/atlases/plants/peashooter.png differ diff --git a/assets/sprites/atlases/plants/potato_mine.png b/assets/sprites/atlases/plants/potato_mine.png index 0c75e4e..7f97eba 100644 Binary files a/assets/sprites/atlases/plants/potato_mine.png and b/assets/sprites/atlases/plants/potato_mine.png differ diff --git a/assets/sprites/atlases/plants/snow_pea.png b/assets/sprites/atlases/plants/snow_pea.png index ff1f19b..6949348 100644 Binary files a/assets/sprites/atlases/plants/snow_pea.png and b/assets/sprites/atlases/plants/snow_pea.png differ diff --git a/assets/sprites/atlases/plants/spikeweed.png b/assets/sprites/atlases/plants/spikeweed.png index 730f3be..60e1ac7 100644 Binary files a/assets/sprites/atlases/plants/spikeweed.png and b/assets/sprites/atlases/plants/spikeweed.png differ diff --git a/assets/sprites/atlases/plants/sunflower.png b/assets/sprites/atlases/plants/sunflower.png index e3f19ec..757fd22 100644 Binary files a/assets/sprites/atlases/plants/sunflower.png and b/assets/sprites/atlases/plants/sunflower.png differ diff --git a/assets/sprites/atlases/plants/wallnut.png b/assets/sprites/atlases/plants/wallnut.png index b3a5e21..f06aa77 100644 Binary files a/assets/sprites/atlases/plants/wallnut.png and b/assets/sprites/atlases/plants/wallnut.png differ diff --git a/resources/animations/plants/aloe.res b/resources/animations/plants/aloe.res index 4a82d5b..f6ca8e8 100644 Binary files a/resources/animations/plants/aloe.res and b/resources/animations/plants/aloe.res differ diff --git a/resources/animations/plants/peashooter.res b/resources/animations/plants/peashooter.res index d1d2307..bdc4052 100644 Binary files a/resources/animations/plants/peashooter.res and b/resources/animations/plants/peashooter.res differ diff --git a/resources/animations/plants/potato_mine.res b/resources/animations/plants/potato_mine.res new file mode 100644 index 0000000..63e274f Binary files /dev/null and b/resources/animations/plants/potato_mine.res differ diff --git a/resources/animations/plants/snowpea.res b/resources/animations/plants/snowpea.res index 4dc13fc..2bb2ac0 100644 Binary files a/resources/animations/plants/snowpea.res and b/resources/animations/plants/snowpea.res differ diff --git a/resources/animations/plants/spikeweed.res b/resources/animations/plants/spikeweed.res new file mode 100644 index 0000000..f02edf7 Binary files /dev/null and b/resources/animations/plants/spikeweed.res differ diff --git a/resources/animations/plants/sunflower.res b/resources/animations/plants/sunflower.res new file mode 100644 index 0000000..bd06154 Binary files /dev/null and b/resources/animations/plants/sunflower.res differ diff --git a/resources/animations/plants/wallnut.res b/resources/animations/plants/wallnut.res new file mode 100644 index 0000000..4dd4261 Binary files /dev/null and b/resources/animations/plants/wallnut.res differ diff --git a/resources/plants/PotatoMine.tres b/resources/plants/PotatoMine.tres index c48f18e..bc1d045 100644 --- a/resources/plants/PotatoMine.tres +++ b/resources/plants/PotatoMine.tres @@ -9,6 +9,6 @@ script = ExtResource("1_33j6b") Cost = 25 Scene = ExtResource("2_ig2ti") ReloadTime = 25.0 -StartReloadTime = 0.0 +ReloadProgress = 0.0 Preview = ExtResource("1_xk2pg") Layer = 1 diff --git a/resources/plants/Sunflower.tres b/resources/plants/Sunflower.tres index 204e8ea..2b499a4 100644 --- a/resources/plants/Sunflower.tres +++ b/resources/plants/Sunflower.tres @@ -1,14 +1,14 @@ [gd_resource type="Resource" script_class="PlantResource" load_steps=4 format=3 uid="uid://drm42f48urvc4"] [ext_resource type="Texture2D" uid="uid://iw75j816gbc" path="res://assets/sprites/plants/sunflower.tres" id="1_8rd5i"] -[ext_resource type="PackedScene" uid="uid://hsllvtm3q34d" path="res://scenes/entities/plants/sunflower.tscn" id="2_e5o45"] +[ext_resource type="PackedScene" uid="uid://bg7lomiorxo2c" path="res://scenes/entities/plants/sunflower.tscn" id="2_gcyr5"] [ext_resource type="Script" path="res://scripts/resources/PlantResource.cs" id="3_vt4jc"] [resource] script = ExtResource("3_vt4jc") Cost = 50 -Scene = ExtResource("2_e5o45") +Scene = ExtResource("2_gcyr5") ReloadTime = 5.0 -StartReloadTime = 0.0 +ReloadProgress = 1.0 Preview = ExtResource("1_8rd5i") Layer = 1 diff --git a/resources/plants/Wallnut.tres b/resources/plants/Wallnut.tres index c38ae93..c975f37 100644 --- a/resources/plants/Wallnut.tres +++ b/resources/plants/Wallnut.tres @@ -2,13 +2,13 @@ [ext_resource type="Texture2D" uid="uid://g2oppl54efja" path="res://assets/sprites/plants/Wallnut.tres" id="1_2akap"] [ext_resource type="Script" path="res://scripts/resources/PlantResource.cs" id="1_27l0t"] -[ext_resource type="PackedScene" uid="uid://dh6rm7o3taaek" path="res://scenes/entities/plants/wallnut.tscn" id="2_l87er"] +[ext_resource type="PackedScene" uid="uid://bq7imkpr2yqyr" path="res://scenes/entities/plants/wallnut.tscn" id="2_rkn3h"] [resource] script = ExtResource("1_27l0t") Cost = 50 -Scene = ExtResource("2_l87er") +Scene = ExtResource("2_rkn3h") ReloadTime = 20.0 -StartReloadTime = 0.0 +ReloadProgress = 0.0 Preview = ExtResource("1_2akap") Layer = 1 diff --git a/scenes/entities/plants/aloe.tscn b/scenes/entities/plants/aloe.tscn index 37fc086..9b0b8ec 100644 --- a/scenes/entities/plants/aloe.tscn +++ b/scenes/entities/plants/aloe.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://bw1w8jp0yeypy"] +[gd_scene load_steps=18 format=3 uid="uid://bw1w8jp0yeypy"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_n25yi"] [ext_resource type="Texture2D" uid="uid://b6tyoa5htapir" path="res://assets/sprites/atlases/plants/aloe.png" id="2_iup5p"] @@ -19,12 +19,67 @@ tracks/0/keys = { "update": 1, "values": [0] } +tracks/1/type = "value" +tracks/1/imported = false +tracks/1/enabled = true +tracks/1/path = NodePath("AnimationTree:parameters/conditions/heal") +tracks/1/interp = 1 +tracks/1/loop_wrap = true +tracks/1/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} [sub_resource type="AnimationLibrary" id="AnimationLibrary_wlien"] _data = { "RESET": SubResource("Animation_vknky") } +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_c25ew"] +animation = &"aloe/heal" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6dmta"] +animation = &"aloe/idle" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_7tkf5"] +animation = &"aloe/idle_used" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_8bc4q"] +animation = &"aloe/recharge" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_gi6e0"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_l1t7h"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_cut4s"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_um4ov"] +advance_mode = 2 +advance_condition = &"heal" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_4kdc0"] +advance_mode = 2 +advance_condition = &"charged" + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_bldox"] +states/aloe_heal/node = SubResource("AnimationNodeAnimation_c25ew") +states/aloe_heal/position = Vector2(530, 41) +states/aloe_idle/node = SubResource("AnimationNodeAnimation_6dmta") +states/aloe_idle/position = Vector2(359, 100) +states/aloe_idle_used/node = SubResource("AnimationNodeAnimation_7tkf5") +states/aloe_idle_used/position = Vector2(710, 105) +states/aloe_recharge/node = SubResource("AnimationNodeAnimation_8bc4q") +states/aloe_recharge/position = Vector2(530, 171) +transitions = ["Start", "aloe_idle", SubResource("AnimationNodeStateMachineTransition_gi6e0"), "aloe_heal", "aloe_idle_used", SubResource("AnimationNodeStateMachineTransition_l1t7h"), "aloe_recharge", "aloe_idle", SubResource("AnimationNodeStateMachineTransition_cut4s"), "aloe_idle", "aloe_heal", SubResource("AnimationNodeStateMachineTransition_um4ov"), "aloe_idle_used", "aloe_recharge", SubResource("AnimationNodeStateMachineTransition_4kdc0")] +graph_offset = Vector2(-78.082, -71.7578) + [sub_resource type="RectangleShape2D" id="RectangleShape2D_oe0dc"] size = Vector2(22, 32) @@ -42,17 +97,20 @@ libraries = { "": SubResource("AnimationLibrary_wlien"), "aloe": ExtResource("3_3sp3b") } -autoplay = "aloe/idle" -[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] -shape = SubResource("RectangleShape2D_oe0dc") +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeStateMachine_bldox") +parameters/conditions/charged = false +parameters/conditions/heal = false -[node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_player")] +[node name="Behaviour" type="Node" parent="." index="3"] script = ExtResource("4_55asm") -_player = NodePath("../AnimationPlayer") [node name="Timer" type="Timer" parent="Behaviour" index="0"] wait_time = 15.0 one_shot = true +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] +shape = SubResource("RectangleShape2D_oe0dc") + [connection signal="timeout" from="Behaviour/Timer" to="Behaviour" method="OnTimeout"] diff --git a/scenes/entities/plants/peashooter.tscn b/scenes/entities/plants/peashooter.tscn index 6b860c7..6eb42fb 100644 --- a/scenes/entities/plants/peashooter.tscn +++ b/scenes/entities/plants/peashooter.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=11 format=3 uid="uid://dy41q1kxray5t"] +[gd_scene load_steps=19 format=3 uid="uid://dy41q1kxray5t"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_pyk3o"] [ext_resource type="Texture2D" uid="uid://cksryh4w5dbbx" path="res://assets/sprites/atlases/plants/peashooter.png" id="2_14qlx"] @@ -9,29 +9,73 @@ [ext_resource type="Script" path="res://scripts/components/plants/Eyesight.cs" id="7_2bki8"] [ext_resource type="Script" path="res://scripts/components/plants/PlantEyesightLimiter.cs" id="8_nl4jc"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_r7xnh"] -size = Vector2(20, 44) +[sub_resource type="Animation" id="Animation_a2y0j"] +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_ipp6b"] +_data = { +"RESET": SubResource("Animation_a2y0j") +} + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_34v85"] +animation = &"peashooter/idle" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_u4o2k"] +animation = &"peashooter/shoot" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_70n3m"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_2lwpg"] +advance_mode = 2 +advance_condition = &"ready" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_k61yr"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_13o7y"] +states/peashooter_idle/node = SubResource("AnimationNodeAnimation_34v85") +states/peashooter_idle/position = Vector2(420, 92) +states/peashooter_shoot/node = SubResource("AnimationNodeAnimation_u4o2k") +states/peashooter_shoot/position = Vector2(674, 82) +transitions = ["Start", "peashooter_idle", SubResource("AnimationNodeStateMachineTransition_70n3m"), "peashooter_idle", "peashooter_shoot", SubResource("AnimationNodeStateMachineTransition_2lwpg"), "peashooter_shoot", "peashooter_idle", SubResource("AnimationNodeStateMachineTransition_k61yr")] [sub_resource type="SegmentShape2D" id="SegmentShape2D_8iovl"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_r7xnh"] +size = Vector2(20, 44) + [node name="Peashooter" instance=ExtResource("1_pyk3o")] _maxHP = 100 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_14qlx") -hframes = 2 -vframes = 10 -frame = 6 +hframes = 10 +vframes = 2 [node name="AnimationPlayer" parent="." index="1"] libraries = { +"": SubResource("AnimationLibrary_ipp6b"), "peashooter": ExtResource("3_8lrhp") } autoplay = "peashooter/idle" -[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] -position = Vector2(0, 5) -shape = SubResource("RectangleShape2D_r7xnh") +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeStateMachine_13o7y") +parameters/conditions/ready = false [node name="Shooter" type="Marker2D" parent="." index="3" node_paths=PackedStringArray("_timer")] position = Vector2(12, -4) @@ -60,3 +104,7 @@ shape = SubResource("SegmentShape2D_8iovl") script = ExtResource("8_nl4jc") [node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="." index="6"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] +position = Vector2(0, 5) +shape = SubResource("RectangleShape2D_r7xnh") diff --git a/scenes/entities/plants/potato_mine.tscn b/scenes/entities/plants/potato_mine.tscn index e4169ef..7f0e2a2 100644 --- a/scenes/entities/plants/potato_mine.tscn +++ b/scenes/entities/plants/potato_mine.tscn @@ -1,91 +1,55 @@ -[gd_scene load_steps=14 format=3 uid="uid://b5x35v3w2u8dx"] +[gd_scene load_steps=20 format=3 uid="uid://b5x35v3w2u8dx"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_dj7ul"] [ext_resource type="Texture2D" uid="uid://c77o6ba0mw7a3" path="res://assets/sprites/atlases/plants/potato_mine.png" id="2_sneas"] [ext_resource type="Script" path="res://scripts/components/plants/ExplosionComponent.cs" id="3_2hd5y"] +[ext_resource type="AnimationLibrary" uid="uid://bjlbdvr6f0r7e" path="res://resources/animations/plants/potato_mine.res" id="3_7tqmj"] [ext_resource type="Script" path="res://scripts/components/plants/behaviours/PotatomineBehaviour.cs" id="4_twx65"] -[sub_resource type="Animation" id="Animation_lpsw3"] -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": [1] -} +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_6uutc"] +animation = &"potato_mine/explode" -[sub_resource type="Animation" id="Animation_n8bxp"] -resource_name = "idle_primed" -length = 2.00001 -loop_mode = 1 -step = 0.0833333 -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, 0.333333, 0.666667, 1, 1.33333, 1.66667), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), -"update": 1, -"values": [0, 3, 6, 9, 12, 15] -} +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_qdgub"] +animation = &"potato_mine/idle_primed" -[sub_resource type="Animation" id="Animation_vmabh"] -resource_name = "idle_unprimed" -length = 4.00001 -loop_mode = 1 -step = 0.0833333 -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, 3.75, 3.91667), -"transitions": PackedFloat32Array(1, 1, 1), -"update": 1, -"values": [1, 7, 1] -} +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_cohta"] +animation = &"potato_mine/idle_unprimed" -[sub_resource type="Animation" id="Animation_ekg7n"] -resource_name = "prime" -length = 0.583342 -step = 0.0833333 -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, 0.0833333, 0.166667, 0.25, 0.333333, 0.416667, 0.5), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [2, 5, 8, 11, 14, 17, 20] -} +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_j42h1"] +animation = &"potato_mine/prime" -[sub_resource type="AnimationLibrary" id="AnimationLibrary_4kofx"] -_data = { -"RESET": SubResource("Animation_lpsw3"), -"idle_primed": SubResource("Animation_n8bxp"), -"idle_unprimed": SubResource("Animation_vmabh"), -"prime": SubResource("Animation_ekg7n") -} +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ttnxb"] +advance_mode = 2 -[sub_resource type="RectangleShape2D" id="RectangleShape2D_qfqko"] -size = Vector2(15, 27) +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_8nvnf"] +advance_mode = 2 +advance_condition = &"primed" -[sub_resource type="RectangleShape2D" id="RectangleShape2D_ti2g4"] -size = Vector2(34, 19) +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_q0arb"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_dikhn"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_lqd1d"] +advance_mode = 2 +advance_condition = &"explode" + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_nfn7b"] +states/End/position = Vector2(1104, 75.168) +states/Start/position = Vector2(46, 130) +states/potato_mine_explode/node = SubResource("AnimationNodeAnimation_6uutc") +states/potato_mine_explode/position = Vector2(934.656, 75.168) +states/potato_mine_idle_primed/node = SubResource("AnimationNodeAnimation_qdgub") +states/potato_mine_idle_primed/position = Vector2(703.656, 75.168) +states/potato_mine_idle_unprimed/node = SubResource("AnimationNodeAnimation_cohta") +states/potato_mine_idle_unprimed/position = Vector2(271.656, 75.168) +states/potato_mine_prime/node = SubResource("AnimationNodeAnimation_j42h1") +states/potato_mine_prime/position = Vector2(490.656, 75.168) +transitions = ["Start", "potato_mine_idle_unprimed", SubResource("AnimationNodeStateMachineTransition_ttnxb"), "potato_mine_idle_unprimed", "potato_mine_prime", SubResource("AnimationNodeStateMachineTransition_8nvnf"), "potato_mine_explode", "End", SubResource("AnimationNodeStateMachineTransition_q0arb"), "potato_mine_prime", "potato_mine_idle_primed", SubResource("AnimationNodeStateMachineTransition_dikhn"), "potato_mine_idle_primed", "potato_mine_explode", SubResource("AnimationNodeStateMachineTransition_lqd1d")] +graph_offset = Vector2(-16.3438, -67.832) [sub_resource type="CircleShape2D" id="CircleShape2D_v0g5b"] radius = 19.0263 @@ -93,29 +57,30 @@ radius = 19.0263 [sub_resource type="CircleShape2D" id="CircleShape2D_wvns6"] radius = 19.0263 +[sub_resource type="RectangleShape2D" id="RectangleShape2D_qfqko"] +size = Vector2(15, 27) + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ti2g4"] +size = Vector2(34, 19) + [node name="Potato mine" instance=ExtResource("1_dj7ul")] _maxHP = 100 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_sneas") -hframes = 3 -vframes = 7 -frame = 1 +hframes = 7 +vframes = 4 [node name="AnimationPlayer" parent="." index="1"] libraries = { -"": SubResource("AnimationLibrary_4kofx") +"potato_mine": ExtResource("3_7tqmj") } autoplay = "idle_unprimed" -[node name="Unprimed" type="CollisionShape2D" parent="Hitbox" index="0"] -position = Vector2(-0.5, 14.5) -shape = SubResource("RectangleShape2D_qfqko") - -[node name="Primed" type="CollisionShape2D" parent="Hitbox" index="1"] -position = Vector2(0, 16.5) -shape = SubResource("RectangleShape2D_ti2g4") -disabled = true +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeStateMachine_nfn7b") +parameters/conditions/explode = false +parameters/conditions/primed = false [node name="Detectionbox" type="Area2D" parent="." index="3"] collision_layer = 0 @@ -140,17 +105,20 @@ wait_time = 15.0 one_shot = true autostart = true -[node name="Behaviour" type="Node" parent="." index="6" node_paths=PackedStringArray("_player", "_hitbox", "_unprimedShape", "_primedShape")] +[node name="Behaviour" type="Node" parent="." index="6" node_paths=PackedStringArray("_hitbox", "_unprimedShape", "_primedShape")] script = ExtResource("4_twx65") -_player = NodePath("../AnimationPlayer") _hitbox = NodePath("../Hitbox") _unprimedShape = NodePath("../Hitbox/Unprimed") _primedShape = NodePath("../Hitbox/Primed") -[node name="ExplosionTimer" type="Timer" parent="Behaviour" index="0"] -wait_time = 0.333 -one_shot = true +[node name="Unprimed" type="CollisionShape2D" parent="Hitbox" index="0"] +position = Vector2(-0.5, 14.5) +shape = SubResource("RectangleShape2D_qfqko") + +[node name="Primed" type="CollisionShape2D" parent="Hitbox" index="1"] +position = Vector2(0, 16.5) +shape = SubResource("RectangleShape2D_ti2g4") +disabled = true [connection signal="area_entered" from="Detectionbox" to="Behaviour" method="OnAreaEntered"] [connection signal="timeout" from="PrimeTimer" to="Behaviour" method="Prime"] -[connection signal="timeout" from="Behaviour/ExplosionTimer" to="ExplosionBox" method="Explode"] diff --git a/scenes/entities/plants/snowpea.tscn b/scenes/entities/plants/snowpea.tscn index 7e49b63..575d9e4 100644 --- a/scenes/entities/plants/snowpea.tscn +++ b/scenes/entities/plants/snowpea.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://b7innrovtmf5u"] +[gd_scene load_steps=13 format=3 uid="uid://b7innrovtmf5u"] [ext_resource type="PackedScene" uid="uid://dy41q1kxray5t" path="res://scenes/entities/plants/peashooter.tscn" id="1_lp85e"] [ext_resource type="Texture2D" uid="uid://cu0651pvvkmvm" path="res://assets/sprites/atlases/plants/snow_pea.png" id="2_ytrm0"] @@ -25,11 +25,34 @@ _data = { "RESET": SubResource("Animation_pephc") } +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_dv2ad"] +animation = &"snowpea/idle" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ptach"] +animation = &"snowpea/shoot" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_8spty"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_lshcr"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_ihul0"] +advance_mode = 2 +advance_condition = &"ready" + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_qdmro"] +states/snowpea_idle/node = SubResource("AnimationNodeAnimation_dv2ad") +states/snowpea_idle/position = Vector2(408, 100) +states/snowpea_shoot/node = SubResource("AnimationNodeAnimation_ptach") +states/snowpea_shoot/position = Vector2(682, 100) +transitions = ["snowpea_shoot", "snowpea_idle", SubResource("AnimationNodeStateMachineTransition_8spty"), "Start", "snowpea_idle", SubResource("AnimationNodeStateMachineTransition_lshcr"), "snowpea_idle", "snowpea_shoot", SubResource("AnimationNodeStateMachineTransition_ihul0")] + [node name="Snowpea" instance=ExtResource("1_lp85e")] [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_ytrm0") -frame = 0 [node name="AnimationPlayer" parent="." index="1"] libraries = { @@ -38,8 +61,8 @@ libraries = { } autoplay = "snowpea/idle" +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeStateMachine_qdmro") + [node name="Shooter" parent="." index="3"] _projectile = ExtResource("5_bv86m") - -[node name="Behaviour" parent="." index="4"] -_libName = "snowpea" diff --git a/scenes/entities/plants/spikeweed.tscn b/scenes/entities/plants/spikeweed.tscn index 84599cf..d740250 100644 --- a/scenes/entities/plants/spikeweed.tscn +++ b/scenes/entities/plants/spikeweed.tscn @@ -1,115 +1,55 @@ -[gd_scene load_steps=11 format=3 uid="uid://bdhod5c6o53ha"] +[gd_scene load_steps=10 format=3 uid="uid://bdhod5c6o53ha"] [ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_vmbvr"] [ext_resource type="Texture2D" uid="uid://coafh3mjharxo" path="res://assets/sprites/atlases/plants/spikeweed.png" id="2_ffrjr"] -[ext_resource type="AudioStream" uid="uid://ypihbxy7tsqn" path="res://assets/audio/sfx/spikeweed_attack.mp3" id="3_5wcts"] [ext_resource type="Script" path="res://scripts/components/plants/AreaAttack.cs" id="3_hqtbm"] +[ext_resource type="AnimationLibrary" uid="uid://cen6ku4y01dyg" path="res://resources/animations/plants/spikeweed.res" id="3_nwshn"] [ext_resource type="Script" path="res://scripts/components/plants/behaviours/SpikeweedBehaviour.cs" id="3_uhpn7"] -[sub_resource type="Animation" id="Animation_7bhr0"] -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="AnimationNodeAnimation" id="AnimationNodeAnimation_lmfqg"] +animation = &"spikeweed/idle" -[sub_resource type="Animation" id="Animation_swkxy"] -resource_name = "attack" -length = 0.666675 -loop_mode = 1 -step = 0.0833333 -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, 0.166667, 0.333333, 0.5), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 1, -"values": [3, 5, 7, 9] -} -tracks/1/type = "method" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Hitbox") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0.166667), -"transitions": PackedFloat32Array(1), -"values": [{ -"args": [], -"method": &"Attack" -}] -} -tracks/2/type = "audio" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("AudioStreamPlayer2D") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"clips": [{ -"end_offset": 0.0, -"start_offset": 0.0, -"stream": ExtResource("3_5wcts") -}], -"times": PackedFloat32Array(0.166667) -} -tracks/2/use_blend = true +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ccr6v"] +animation = &"spikeweed/attack" -[sub_resource type="Animation" id="Animation_h2f35"] -resource_name = "idle" -length = 2.50001 -loop_mode = 1 -step = 0.0833333 -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, 0.166667, 0.333333, 0.5, 0.666667, 0.833333, 1, 2, 2.16667, 2.33333), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [0, 2, 4, 6, 8, 10, 12, 6, 8, 14] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_m4h7k"] -_data = { -"RESET": SubResource("Animation_7bhr0"), -"attack": SubResource("Animation_swkxy"), -"idle": SubResource("Animation_h2f35") -} +[sub_resource type="AnimationNodeBlendSpace1D" id="AnimationNodeBlendSpace1D_1y7y3"] +blend_point_0/node = SubResource("AnimationNodeAnimation_lmfqg") +blend_point_0/pos = 0.0 +blend_point_1/node = SubResource("AnimationNodeAnimation_ccr6v") +blend_point_1/pos = 1.0 +min_space = 0.0 +snap = 1.0 +value_label = "attack" +blend_mode = 1 [sub_resource type="RectangleShape2D" id="RectangleShape2D_1di76"] size = Vector2(49, 38) [node name="Spikeweed" instance=ExtResource("1_vmbvr")] +_maxHP = 100 [node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_ffrjr") -hframes = 2 -vframes = 10 +hframes = 10 +vframes = 2 +frame = 8 [node name="AnimationPlayer" parent="." index="1"] libraries = { -"": SubResource("AnimationLibrary_m4h7k") +"spikeweed": ExtResource("3_nwshn") } -autoplay = "idle" -[node name="Hitbox" parent="." index="2"] +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeBlendSpace1D_1y7y3") +parameters/blend_position = 0.0 + +[node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_tree")] +script = ExtResource("3_uhpn7") +_tree = NodePath("../AnimationTree") + +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="." index="4"] + +[node name="Hitbox" parent="." index="5"] collision_layer = 4 collision_mask = 8 script = ExtResource("3_hqtbm") @@ -119,11 +59,5 @@ _damage = 2 position = Vector2(0.5, 9) shape = SubResource("RectangleShape2D_1di76") -[node name="Behaviour" type="Node" parent="." index="3" node_paths=PackedStringArray("_player")] -script = ExtResource("3_uhpn7") -_player = NodePath("../AnimationPlayer") - -[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="." index="4"] - [connection signal="area_entered" from="Hitbox" to="Behaviour" method="OnHitboxEntered"] [connection signal="area_exited" from="Hitbox" to="Behaviour" method="OnHitboxExited"] diff --git a/scenes/entities/plants/sunflower.tscn b/scenes/entities/plants/sunflower.tscn index 94efeff..1015bfb 100644 --- a/scenes/entities/plants/sunflower.tscn +++ b/scenes/entities/plants/sunflower.tscn @@ -1,121 +1,92 @@ -[gd_scene load_steps=11 format=3 uid="uid://hsllvtm3q34d"] +[gd_scene load_steps=16 format=3 uid="uid://bg7lomiorxo2c"] -[ext_resource type="Script" path="res://scripts/components/plants/RuntimePlantData.cs" id="1_2wmcw"] +[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_bikjn"] [ext_resource type="Texture2D" uid="uid://b3tuidu8dag8u" path="res://assets/sprites/atlases/plants/sunflower.png" id="2_fwcda"] +[ext_resource type="AnimationLibrary" uid="uid://yjytiuj4u7oh" path="res://resources/animations/plants/sunflower.res" id="3_btsik"] [ext_resource type="Script" path="res://scripts/components/plants/PlantSunSpawner.cs" id="3_te0pl"] [ext_resource type="PackedScene" uid="uid://bpekho7leatr5" path="res://scenes/sun.tscn" id="4_b8hls"] [ext_resource type="Script" path="res://scripts/components/plants/behaviours/SunflowerBehaviour.cs" id="5_26je0"] -[sub_resource type="Animation" id="Animation_7b6ex"] +[sub_resource type="Animation" id="Animation_bfx6v"] length = 0.001 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:frame") +tracks/0/path = NodePath("AnimationTree:parameters/conditions/produce") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { "times": PackedFloat32Array(0), "transitions": PackedFloat32Array(1), "update": 1, -"values": [12] +"values": [false] } -[sub_resource type="Animation" id="Animation_w8qjp"] -resource_name = "idle" -length = 0.833342 -loop_mode = 2 -step = 0.0833333 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.166667, 0.333333, 0.5, 0.666667, 0.833333), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1), -"update": 1, -"values": [4, 6, 8, 10, 12, 14] -} - -[sub_resource type="Animation" id="Animation_18upv"] -resource_name = "produce" -step = 0.0833333 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.0833333, 0.166667, 0.25, 0.333333, 0.416667, 0.5, 0.583333, 0.666666), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [1, 3, 5, 7, 9, 11, 13, 15, 17] -} -tracks/1/type = "method" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("PlantSunSpawner") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0.5), -"transitions": PackedFloat32Array(1), -"values": [{ -"args": [], -"method": &"Spawn" -}] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_piyjs"] +[sub_resource type="AnimationLibrary" id="AnimationLibrary_ek2al"] _data = { -"RESET": SubResource("Animation_7b6ex"), -"idle": SubResource("Animation_w8qjp"), -"produce": SubResource("Animation_18upv") +"RESET": SubResource("Animation_bfx6v") } -[sub_resource type="RectangleShape2D" id="RectangleShape2D_626vr"] +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_lkpmx"] +animation = &"sunflower/idle" + +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_hc6hn"] +animation = &"sunflower/produce" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_26fia"] +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_d2akw"] +advance_mode = 2 +advance_condition = &"produce" + +[sub_resource type="AnimationNodeStateMachineTransition" id="AnimationNodeStateMachineTransition_sww40"] +switch_mode = 2 +advance_mode = 2 + +[sub_resource type="AnimationNodeStateMachine" id="AnimationNodeStateMachine_enpal"] +states/sunflower_idle/node = SubResource("AnimationNodeAnimation_lkpmx") +states/sunflower_idle/position = Vector2(371, 100) +states/sunflower_produce/node = SubResource("AnimationNodeAnimation_hc6hn") +states/sunflower_produce/position = Vector2(624, 99) +transitions = ["Start", "sunflower_idle", SubResource("AnimationNodeStateMachineTransition_26fia"), "sunflower_idle", "sunflower_produce", SubResource("AnimationNodeStateMachineTransition_d2akw"), "sunflower_produce", "sunflower_idle", SubResource("AnimationNodeStateMachineTransition_sww40")] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_4xs4g"] size = Vector2(26, 48) -[node name="Sunflower" type="Node2D"] -use_parent_material = true -script = ExtResource("1_2wmcw") -_maxHP = 100 +[node name="Sunflower" instance=ExtResource("1_bikjn")] -[node name="Sprite" type="Sprite2D" parent="."] -use_parent_material = true +[node name="Sprite2D" parent="." index="0"] texture = ExtResource("2_fwcda") -hframes = 2 -vframes = 9 -frame = 12 +hframes = 9 +vframes = 2 +frame = 1 -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +[node name="AnimationPlayer" parent="." index="1"] libraries = { -"": SubResource("AnimationLibrary_piyjs") +"": SubResource("AnimationLibrary_ek2al"), +"sunflower": ExtResource("3_btsik") } -autoplay = "idle" -[node name="Hitbox" type="Area2D" parent="."] -collision_layer = 2 -collision_mask = 0 +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeStateMachine_enpal") +parameters/conditions/produce = false -[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] -position = Vector2(0, 4) -shape = SubResource("RectangleShape2D_626vr") - -[node name="PlantSunSpawner" type="Node2D" parent="."] +[node name="PlantSunSpawner" type="Node2D" parent="." index="3"] position = Vector2(-2, 0) script = ExtResource("3_te0pl") _sunScene = ExtResource("4_b8hls") _amountPerSun = 25 -[node name="Behaviour" type="Node" parent="."] +[node name="Behaviour" type="Node" parent="." index="4"] script = ExtResource("5_26je0") -[node name="Timer" type="Timer" parent="Behaviour"] +[node name="Timer" type="Timer" parent="Behaviour" index="0"] wait_time = 5.0 autostart = true +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] +position = Vector2(0, 4) +shape = SubResource("RectangleShape2D_4xs4g") + [connection signal="timeout" from="Behaviour/Timer" to="Behaviour" method="Timeout"] diff --git a/scenes/entities/plants/wallnut.tscn b/scenes/entities/plants/wallnut.tscn index 07940d0..72d177e 100644 --- a/scenes/entities/plants/wallnut.tscn +++ b/scenes/entities/plants/wallnut.tscn @@ -1,117 +1,54 @@ -[gd_scene load_steps=11 format=3 uid="uid://dh6rm7o3taaek"] +[gd_scene load_steps=10 format=3 uid="uid://bq7imkpr2yqyr"] -[ext_resource type="Texture2D" uid="uid://dstqh1wc5dvmo" path="res://assets/sprites/atlases/plants/wallnut.png" id="1_571nl"] -[ext_resource type="Script" path="res://scripts/components/plants/RuntimePlantData.cs" id="1_mt5mt"] -[ext_resource type="Script" path="res://scripts/components/plants/behaviours/WallnutBehaviour.cs" id="3_tu4pm"] +[ext_resource type="PackedScene" uid="uid://b1hjjbdwf1rtc" path="res://scenes/templates/plant_template.tscn" id="1_fluxn"] +[ext_resource type="Texture2D" uid="uid://dstqh1wc5dvmo" path="res://assets/sprites/atlases/plants/wallnut.png" id="2_o5tda"] +[ext_resource type="AnimationLibrary" uid="uid://0bdesb8j2mbo" path="res://resources/animations/plants/wallnut.res" id="3_xl65q"] +[ext_resource type="Script" path="res://scripts/components/plants/behaviours/HpBasedBehaviour.cs" id="4_cjtyy"] -[sub_resource type="Animation" id="Animation_s4r5j"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite: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="AnimationNodeAnimation" id="AnimationNodeAnimation_ds5ry"] +animation = &"wallnut/idle_full" -[sub_resource type="Animation" id="Animation_lfaj3"] -resource_name = "idle_full" -length = 8.50002 -loop_mode = 1 -step = 0.25 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 2.25, 2.5, 2.75, 3, 3.25, 4.25, 4.5, 6.75, 7, 7.25, 7.5, 9.75), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [0, 3, 6, 9, 12, 15, 12, 9, 6, 3, 27, 30, 3] -} +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_frsxy"] +animation = &"wallnut/idle_mid" -[sub_resource type="Animation" id="Animation_u73od"] -resource_name = "idle_low" -length = 3.00003 -loop_mode = 1 -step = 0.25 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32] -} +[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_7avgo"] +animation = &"wallnut/idle_low" -[sub_resource type="Animation" id="Animation_c8ofx"] -resource_name = "idle_mid" -length = 3.50005 -loop_mode = 1 -step = 0.25 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath("Sprite:frame") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.25, 0.5, 0.75, 1, 1.25, 1.5, 1.75, 2, 2.25, 2.5, 2.75), -"transitions": PackedFloat32Array(1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1), -"update": 1, -"values": [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34] -} +[sub_resource type="AnimationNodeBlendSpace1D" id="AnimationNodeBlendSpace1D_nij8v"] +blend_point_0/node = SubResource("AnimationNodeAnimation_ds5ry") +blend_point_0/pos = 1.0 +blend_point_1/node = SubResource("AnimationNodeAnimation_frsxy") +blend_point_1/pos = 0.7 +blend_point_2/node = SubResource("AnimationNodeAnimation_7avgo") +blend_point_2/pos = 0.3 +min_space = 0.0 +blend_mode = 1 -[sub_resource type="AnimationLibrary" id="AnimationLibrary_7mgid"] -_data = { -"RESET": SubResource("Animation_s4r5j"), -"idle_full": SubResource("Animation_lfaj3"), -"idle_low": SubResource("Animation_u73od"), -"idle_mid": SubResource("Animation_c8ofx") -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_ytjo1"] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_523ui"] +[sub_resource type="RectangleShape2D" id="RectangleShape2D_khltr"] size = Vector2(33, 46) -[node name="Wallnut" type="Node2D"] -script = ExtResource("1_mt5mt") +[node name="Wallnut" instance=ExtResource("1_fluxn")] _maxHP = 1000 -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +[node name="Sprite2D" parent="." index="0"] +texture = ExtResource("2_o5tda") +hframes = 12 +vframes = 3 + +[node name="AnimationPlayer" parent="." index="1"] libraries = { -"": SubResource("AnimationLibrary_7mgid"), -"wallnut": SubResource("AnimationLibrary_ytjo1") +"wallnut": ExtResource("3_xl65q") } -autoplay = "idle_full" -[node name="Sprite" type="Sprite2D" parent="."] -use_parent_material = true -texture = ExtResource("1_571nl") -hframes = 3 -vframes = 12 +[node name="AnimationTree" parent="." index="2"] +tree_root = SubResource("AnimationNodeBlendSpace1D_nij8v") +parameters/blend_position = 1.0 -[node name="Behaviour" type="Node" parent="."] -script = ExtResource("3_tu4pm") - -[node name="Hitbox" type="Area2D" parent="."] -collision_layer = 2 -collision_mask = 0 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"] +[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" index="0"] position = Vector2(3.5, 5) -shape = SubResource("RectangleShape2D_523ui") +shape = SubResource("RectangleShape2D_khltr") + +[node name="Behaviour" type="Node" parent="." index="4"] +script = ExtResource("4_cjtyy") [connection signal="OnHPChanged" from="." to="Behaviour" method="OnHPChanged"] diff --git a/scenes/templates/plant_template.tscn b/scenes/templates/plant_template.tscn index 5b1bdef..8683501 100644 --- a/scenes/templates/plant_template.tscn +++ b/scenes/templates/plant_template.tscn @@ -10,6 +10,9 @@ use_parent_material = true [node name="AnimationPlayer" type="AnimationPlayer" parent="."] +[node name="AnimationTree" type="AnimationTree" parent="."] +anim_player = NodePath("../AnimationPlayer") + [node name="Hitbox" type="Area2D" parent="."] collision_layer = 2 collision_mask = 0 diff --git a/scripts/components/level/PoolContainer.cs b/scripts/components/level/PoolContainer.cs index a90fef4..cf490c6 100644 --- a/scripts/components/level/PoolContainer.cs +++ b/scripts/components/level/PoolContainer.cs @@ -21,9 +21,37 @@ public partial class PoolContainer : Node public static PoolContainer Instance {get; private set;} - public Dictionary[] EntityField = { new Dictionary(), new Dictionary(), new Dictionary() }; + public Dictionary[] EntityField = { new(), new(), new() }; public override void _Ready() { Instance = this; } + public bool TryGetEntity(Vector2 key, out IEntity result, int layer = 1) + { + if (EntityField[layer].ContainsKey(key)) + { + result = EntityField[layer][key]; + } + else + { + result = null; + } + return EntityField[layer].ContainsKey(key) + && EntityField[layer][key] != null; + } + + public bool TryGetEntity(Vector2 key, out T result, int layer = 1) where T : class + { + if (EntityField[layer].ContainsKey(key)) + { + result = EntityField[layer][key] as T; + } + else + { + result = null; + } + return EntityField[layer].ContainsKey(key) + && EntityField[layer][key] != null + && result != null; + } } diff --git a/scripts/components/plants/RuntimePlantData.cs b/scripts/components/plants/RuntimePlantData.cs index d2174c7..ed780e3 100644 --- a/scripts/components/plants/RuntimePlantData.cs +++ b/scripts/components/plants/RuntimePlantData.cs @@ -11,7 +11,7 @@ public partial class RuntimePlantData : Node2D, IEntity { [Export] private int _maxHP; - [Export]private int _hp; + private int _hp; public int Hp => _hp; public int MaxHp => _maxHP; public int Line {get; set;} diff --git a/scripts/components/plants/behaviours/AloeBehaviour.cs b/scripts/components/plants/behaviours/AloeBehaviour.cs index e36f959..6233e8d 100644 --- a/scripts/components/plants/behaviours/AloeBehaviour.cs +++ b/scripts/components/plants/behaviours/AloeBehaviour.cs @@ -3,40 +3,46 @@ using Newlon.Components.Level; namespace Newlon.Components.Plants.Behaviours; -public partial class AloeBehaviour : Node +public partial class AloeBehaviour : BaseBehaviour { - [Export] private AnimationPlayer _player; [Export] private float _hpTreshold = 0.25f; private Timer _timer; private bool _charge = true; public override void _Ready() { + base._Ready(); _timer = GetNode("Timer"); } - - public override void _Process(double delta) { + _tree.Set("parameters/conditions/charged",_charge); + var checkPos = GetParent().GlobalPosition + Vector2.Right * Utility.TileWidth; - if(_charge && PoolContainer.Instance.EntityField[1].ContainsKey(checkPos) && PoolContainer.Instance.EntityField[1][checkPos] is RuntimePlantData plantData) + if(_charge && PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData)) { if((float)plantData.Hp / (float)plantData.MaxHp < _hpTreshold) { - plantData.Heal(3000 + 25 * plantData.MaxHp,GetParent()); _charge = false; - _player.Play("aloe/heal"); - _player.Queue("aloe/idle_used"); - _timer.Start(); + _tree.Set("parameters/conditions/heal",true); + _timer.Start(); } } } + public void Heal() + { + var checkPos = GetParent().GlobalPosition + Vector2.Right * Utility.TileWidth; + if (PoolContainer.Instance.TryGetEntity(checkPos, out RuntimePlantData plantData)) + { + plantData.Heal(3000 + 25 * plantData.MaxHp, GetParent()); + GD.Print("IM TRYING"); + } + } + public void OnTimeout() { _charge = true; - _player.Play("aloe/recharge"); - _player.Queue("aloe/idle"); } } diff --git a/scripts/components/plants/behaviours/BaseBehaviour.cs b/scripts/components/plants/behaviours/BaseBehaviour.cs new file mode 100644 index 0000000..346160b --- /dev/null +++ b/scripts/components/plants/behaviours/BaseBehaviour.cs @@ -0,0 +1,11 @@ +using Godot; +using System; + +public abstract partial class BaseBehaviour : Node +{ + protected AnimationTree _tree; + public override void _Ready() + { + _tree = GetNode("../AnimationTree"); + } +} diff --git a/scripts/components/plants/behaviours/HpBasedBehaviour.cs b/scripts/components/plants/behaviours/HpBasedBehaviour.cs new file mode 100644 index 0000000..d49af31 --- /dev/null +++ b/scripts/components/plants/behaviours/HpBasedBehaviour.cs @@ -0,0 +1,18 @@ +using Godot; + +namespace Newlon.Components.Plants.Behaviours; + +public partial class HpBasedBehaviour : BaseBehaviour +{ + private RuntimePlantData _data; + public override void _Ready() + { + base._Ready(); + _data = GetParent(); + } + + public void OnHPChanged(int amount,Node origin) + { + _tree.Set("parameters/blend_position",(float)_data.Hp/_data.MaxHp); + } +} diff --git a/scripts/components/plants/behaviours/PeashooterBehaviour.cs b/scripts/components/plants/behaviours/PeashooterBehaviour.cs index c2eaf01..be36c8e 100644 --- a/scripts/components/plants/behaviours/PeashooterBehaviour.cs +++ b/scripts/components/plants/behaviours/PeashooterBehaviour.cs @@ -2,21 +2,15 @@ using Godot; namespace Newlon.Components.Plants.Behaviours; -public partial class PeashooterBehaviour : Node +public partial class PeashooterBehaviour : BaseBehaviour { - [Export] private AnimationPlayer _player; [Export] private Timer _shootTimer; [Export] private Eyesight _sight; - [Export] private string _libName; public override void _Process(double delta) { bool readyToShoot = _sight.EnemyDetected && _shootTimer.TimeLeft <= 0; - if(readyToShoot) - { - _player.Play(_libName+"/shoot"); - _player.Queue(_libName+"/idle"); - } + _tree.Set("parameters/conditions/ready",readyToShoot); } } diff --git a/scripts/components/plants/behaviours/PotatomineBehaviour.cs b/scripts/components/plants/behaviours/PotatomineBehaviour.cs index 35232a7..75c38c3 100644 --- a/scripts/components/plants/behaviours/PotatomineBehaviour.cs +++ b/scripts/components/plants/behaviours/PotatomineBehaviour.cs @@ -2,18 +2,15 @@ using Godot; namespace Newlon.Components.Plants.Behaviours; -public partial class PotatomineBehaviour : Node +public partial class PotatomineBehaviour : BaseBehaviour { - [Export] private AnimationPlayer _player; [Export] private Area2D _hitbox; [Export] private CollisionShape2D _unprimedShape; [Export] private CollisionShape2D _primedShape; - private bool _primed = false; public void Prime() { - _player.Play("prime"); - _player.Queue("idle_primed"); + _tree.Set("parameters/conditions/primed",true); _hitbox.Monitorable = false; @@ -25,6 +22,7 @@ public partial class PotatomineBehaviour : Node public void OnAreaEntered(Area2D area) { if (_primed == false) return; - GetNode("ExplosionTimer").Start(); + _tree.Set("parameters/conditions/explode",true); + _primed = false; } } diff --git a/scripts/components/plants/behaviours/SpikeweedBehaviour.cs b/scripts/components/plants/behaviours/SpikeweedBehaviour.cs index d175907..7e4d3e6 100644 --- a/scripts/components/plants/behaviours/SpikeweedBehaviour.cs +++ b/scripts/components/plants/behaviours/SpikeweedBehaviour.cs @@ -4,18 +4,18 @@ namespace Newlon.Components.Plants.Behaviours; public partial class SpikeweedBehaviour : Node { - [Export] private AnimationPlayer _player; + [Export] private AnimationTree _tree; private int _inCount = 0; public void OnHitboxEntered(Area2D _area) { if (_inCount++ == 0) - _player.Play("attack"); + _tree.Set("parameters/blend_position",1); } public void OnHitboxExited(Area2D _area) { if (--_inCount == 0) - _player.Play("idle"); + _tree.Set("parameters/blend_position",0); } } diff --git a/scripts/components/plants/behaviours/SunflowerBehaviour.cs b/scripts/components/plants/behaviours/SunflowerBehaviour.cs index 292c56f..735a8f5 100644 --- a/scripts/components/plants/behaviours/SunflowerBehaviour.cs +++ b/scripts/components/plants/behaviours/SunflowerBehaviour.cs @@ -4,17 +4,16 @@ namespace Newlon.Components.Plants.Behaviours; public partial class SunflowerBehaviour : Node { - private AnimationPlayer _player; + private AnimationTree _tree; public override void _Ready() { - _player = GetNode("../AnimationPlayer"); + _tree = GetNode("../AnimationTree"); } public void Timeout() { - _player.Play("produce"); - _player.Queue("idle"); + _tree.Set("parameters/conditions/produce",true); } } diff --git a/scripts/components/plants/behaviours/WallnutBehaviour.cs b/scripts/components/plants/behaviours/WallnutBehaviour.cs deleted file mode 100644 index b623fab..0000000 --- a/scripts/components/plants/behaviours/WallnutBehaviour.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Godot; - -namespace Newlon.Components.Plants.Behaviours; - -public partial class WallnutBehaviour : Node -{ - private AnimationPlayer _player; - private RuntimePlantData _data; - public override void _Ready() - { - _player = GetNode("../AnimationPlayer"); - _data = GetParent(); - } - - public void OnHPChanged(int amount) - { - - if(_data.Hp <= _data.MaxHp*2.0/3.0 && _data.Hp > _data.MaxHp/3.0) - { - _player.Play("idle_mid"); - } - else if(_data.Hp < _data.MaxHp/3.0) - { - _player.Play("idle_low"); - } - else - { - _player.Play("idle_full"); - } - } -} diff --git a/scripts/resources/PlantResource.cs b/scripts/resources/PlantResource.cs index 2164a26..ff43361 100644 --- a/scripts/resources/PlantResource.cs +++ b/scripts/resources/PlantResource.cs @@ -11,8 +11,8 @@ public partial class PlantResource : Resource public PackedScene Scene; [Export] public float ReloadTime; - [Export] - public float StartReloadTime; + [Export(PropertyHint.Range,"0,1,0.01")] + public float ReloadProgress; [Export] public Texture2D Preview; [Export] public int Layer = 1;