repeater and compound projectile

This commit is contained in:
Rendo 2025-07-30 05:27:20 +05:00
commit 3d9f0f7423
9 changed files with 235 additions and 42 deletions

View file

@ -0,0 +1,22 @@
[gd_resource type="Resource" script_class="PlantResource" load_steps=5 format=3 uid="uid://b4r1687hg0rf5"]
[ext_resource type="Texture2D" uid="uid://dvldjlg0nr355" path="res://assets/sprites/atlases/atlas1.png" id="1_6km43"]
[ext_resource type="PackedScene" uid="uid://bb4ya5qx224ca" path="res://scenes/entities/plants/repeater.tscn" id="2_6km43"]
[ext_resource type="Script" uid="uid://cyenlko1knygw" path="res://scripts/resources/entities/PlantResource.cs" id="3_e606l"]
[sub_resource type="AtlasTexture" id="AtlasTexture_qnsfo"]
atlas = ExtResource("1_6km43")
region = Rect2(604, 241, 45, 51)
[resource]
script = ExtResource("3_e606l")
Layer = 1
DontRegister = false
NameKey = "repeater"
DescriptionKey = "repeater_desc"
Cost = 175.0
Scene = ExtResource("2_6km43")
ReloadTime = 5.0
ReloadProgress = 0.0
Preview = SubResource("AtlasTexture_qnsfo")
Order = 12

View file

@ -6,7 +6,7 @@
[ext_resource type="Script" uid="uid://dn53jvpjyg63l" path="res://scripts/entities/plants/Eyesight.cs" id="3_d45iq"]
[ext_resource type="Script" uid="uid://dwlwi42smgxkb" path="res://scripts/TimeScalableAnimationTree.cs" id="3_q31qc"]
[ext_resource type="Script" uid="uid://ceprqkraw3v6m" path="res://scripts/entities/plants/Shooter.cs" id="4_sckvu"]
[ext_resource type="PackedScene" uid="uid://c1ig40gtdcb60" path="res://scenes/projectiles/cucumber_projectile.tscn" id="5_sckvu"]
[ext_resource type="PackedScene" uid="uid://c1ig40gtdcb60" path="res://scenes/projectiles/cucumber_projectile_compound.tscn" id="5_sckvu"]
[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/TimeScalableTimer.cs" id="6_xwpd6"]
[ext_resource type="Script" uid="uid://bdk5iqtw4xbkl" path="res://scripts/entities/plants/behaviours/PeashooterBehaviour.cs" id="7_q31qc"]
[ext_resource type="Script" uid="uid://30pbgasu64aw" path="res://scripts/entities/FlashShaderController.cs" id="9_a66ro"]

View file

@ -0,0 +1,149 @@
[gd_scene load_steps=27 format=3 uid="uid://bb4ya5qx224ca"]
[ext_resource type="Script" uid="uid://dli2i6albvugt" path="res://scripts/entities/plants/RuntimePlantData.cs" id="1_22an6"]
[ext_resource type="Material" uid="uid://cn7ac4meka1hc" path="res://assets/GenericFlashMaterial.tres" id="2_tut6f"]
[ext_resource type="Texture2D" uid="uid://cksryh4w5dbbx" path="res://assets/sprites/atlases/plants/peashooter.png" id="3_8aoci"]
[ext_resource type="AnimationLibrary" uid="uid://bv1dl1g4dmbho" path="res://assets/animations/plants/peashooter.res" id="4_rdf0i"]
[ext_resource type="Script" uid="uid://dwlwi42smgxkb" path="res://scripts/TimeScalableAnimationTree.cs" id="5_dwhke"]
[ext_resource type="Script" uid="uid://ceprqkraw3v6m" path="res://scripts/entities/plants/Shooter.cs" id="6_f5jji"]
[ext_resource type="PackedScene" uid="uid://b45wmmcie6yeg" path="res://scenes/projectiles/repeater_projectile.tscn" id="7_22an6"]
[ext_resource type="Script" uid="uid://c4jy0cnbnx33h" path="res://scripts/TimeScalableTimer.cs" id="8_w0eom"]
[ext_resource type="Script" uid="uid://bdk5iqtw4xbkl" path="res://scripts/entities/plants/behaviours/PeashooterBehaviour.cs" id="9_cqtdb"]
[ext_resource type="Script" uid="uid://dn53jvpjyg63l" path="res://scripts/entities/plants/Eyesight.cs" id="10_bi2sw"]
[ext_resource type="Script" uid="uid://hccb0aee0x0o" path="res://scripts/entities/plants/PlantEyesightLimiter.cs" id="11_4nqum"]
[ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="12_7n1bh"]
[ext_resource type="AudioStream" uid="uid://dsv81mvrdg3w3" path="res://assets/audio/sfx/throw_generic.tres" id="13_hxb23"]
[ext_resource type="Script" uid="uid://30pbgasu64aw" path="res://scripts/entities/FlashShaderController.cs" id="14_aq7hn"]
[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="AnimationNodeTimeScale" id="AnimationNodeTimeScale_mbbd7"]
[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="AnimationNodeBlendTree" id="AnimationNodeBlendTree_q58jr"]
graph_offset = Vector2(-518.8, 27.8)
nodes/TimeScale/node = SubResource("AnimationNodeTimeScale_mbbd7")
nodes/TimeScale/position = Vector2(0, 120)
nodes/Tree/node = SubResource("AnimationNodeStateMachine_13o7y")
nodes/Tree/position = Vector2(-300, 120)
node_connections = [&"TimeScale", 0, &"Tree", &"output", 0, &"TimeScale"]
[sub_resource type="SegmentShape2D" id="SegmentShape2D_8iovl"]
resource_local_to_scene = true
[sub_resource type="RectangleShape2D" id="RectangleShape2D_r7xnh"]
size = Vector2(20, 44)
[node name="Repeater" type="Node2D" node_paths=PackedStringArray("_player", "_tree")]
script = ExtResource("1_22an6")
MaxHP = 30.0
_player = NodePath("AnimationPlayer")
_tree = NodePath("AnimationTree")
[node name="Sprite2D" type="Sprite2D" parent="."]
material = ExtResource("2_tut6f")
texture = ExtResource("3_8aoci")
hframes = 10
vframes = 2
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
&"": SubResource("AnimationLibrary_ipp6b"),
&"peashooter": ExtResource("4_rdf0i")
}
autoplay = "peashooter/idle"
[node name="AnimationTree" type="AnimationTree" parent="." node_paths=PackedStringArray("entity")]
tree_root = SubResource("AnimationNodeBlendTree_q58jr")
anim_player = NodePath("../AnimationPlayer")
parameters/TimeScale/scale = 1.0
parameters/Tree/conditions/ready = false
script = ExtResource("5_dwhke")
entity = NodePath("..")
[node name="Shooter" type="Marker2D" parent="." node_paths=PackedStringArray("_timer")]
position = Vector2(12, -4)
script = ExtResource("6_f5jji")
_projectile = ExtResource("7_22an6")
_timer = NodePath("FireTimer")
[node name="FireTimer" type="Timer" parent="Shooter" node_paths=PackedStringArray("entity")]
wait_time = 1.5
one_shot = true
script = ExtResource("8_w0eom")
entity = NodePath("../..")
[node name="Behaviour" type="Node" parent="." node_paths=PackedStringArray("_shootTimer", "_sight")]
script = ExtResource("9_cqtdb")
_shootTimer = NodePath("../Shooter/FireTimer")
_sight = NodePath("../Eysight")
[node name="Eysight" type="Area2D" parent="."]
collision_layer = 4
collision_mask = 8
script = ExtResource("10_bi2sw")
[node name="CollisionShape2D" type="CollisionShape2D" parent="Eysight"]
shape = SubResource("SegmentShape2D_8iovl")
script = ExtResource("11_4nqum")
[node name="Hitbox" type="Area2D" parent="."]
collision_layer = 2
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
position = Vector2(0, 5)
shape = SubResource("RectangleShape2D_r7xnh")
[node name="ChannelPlayer" type="Node" parent="."]
script = ExtResource("12_7n1bh")
audioStream = ExtResource("13_hxb23")
channel = "pea_shoot"
metadata/_custom_type_script = "uid://c36bj8u7jghc7"
[node name="FlashController" type="Node" parent="."]
script = ExtResource("14_aq7hn")
shaderMaterial = ExtResource("2_tut6f")
[connection signal="OnDamaged" from="." to="FlashController" method="DamageFlash"]

View file

@ -1,24 +1,23 @@
[gd_scene load_steps=3 format=3 uid="uid://c1ig40gtdcb60"]
[gd_scene load_steps=5 format=3 uid="uid://pf8sq0bk3epn"]
[ext_resource type="PackedScene" uid="uid://pf8sq0bk3epn" path="res://scenes/projectiles/cucumber_projectile_part.tscn" id="1_3auks"]
[ext_resource type="PackedScene" uid="uid://b2hrv0aqbui7u" path="res://scenes/projectiles/pea.tscn" id="1_iyfw1"]
[ext_resource type="Texture2D" uid="uid://c68mrfs4wb81x" path="res://assets/sprites/atlases/atlas2.png" id="2_12o6v"]
[sub_resource type="GDScript" id="GDScript_3auks"]
resource_name = "cucumber"
script/source = "extends Node2D
[sub_resource type="AtlasTexture" id="AtlasTexture_h74iy"]
atlas = ExtResource("2_12o6v")
region = Rect2(24, 88, 7, 13)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_iyfw1"]
radius = 6.0
height = 24.0
func _ready() -> void:
await get_tree().process_frame
get_child(0).reparent(get_parent())
get_child(0).reparent(get_parent())
queue_free()
"
[node name="CucumberProjectile" instance=ExtResource("1_iyfw1")]
_speed = 5.0
_damage = 25
[node name="CucumberProjectileScene" type="Node2D"]
script = SubResource("GDScript_3auks")
[node name="Sprite" parent="." index="0"]
rotation = -1.5708
texture = SubResource("AtlasTexture_h74iy")
[node name="CucumberProjectile" parent="." instance=ExtResource("1_3auks")]
rotation = 1.5708
[node name="CucumberProjectile2" parent="." instance=ExtResource("1_3auks")]
rotation = 4.71239
[node name="CollisionShape2D" parent="." index="1"]
shape = SubResource("CapsuleShape2D_iyfw1")

View file

@ -0,0 +1,13 @@
[gd_scene load_steps=3 format=3 uid="uid://c1ig40gtdcb60"]
[ext_resource type="PackedScene" uid="uid://pf8sq0bk3epn" path="res://scenes/projectiles/cucumber_projectile.tscn" id="1_3auks"]
[ext_resource type="Script" uid="uid://j6nq8w2n8532" path="res://scripts/projectiles/CompoundProjectile.cs" id="1_pmbxx"]
[node name="CucumberProjectileScene" type="Node2D"]
script = ExtResource("1_pmbxx")
[node name="CucumberProjectile" parent="." instance=ExtResource("1_3auks")]
rotation = 1.5708
[node name="CucumberProjectile2" parent="." instance=ExtResource("1_3auks")]
rotation = 4.71239

View file

@ -1,23 +0,0 @@
[gd_scene load_steps=5 format=3 uid="uid://pf8sq0bk3epn"]
[ext_resource type="PackedScene" uid="uid://b2hrv0aqbui7u" path="res://scenes/projectiles/pea.tscn" id="1_iyfw1"]
[ext_resource type="Texture2D" uid="uid://c68mrfs4wb81x" path="res://assets/sprites/atlases/atlas2.png" id="2_12o6v"]
[sub_resource type="AtlasTexture" id="AtlasTexture_h74iy"]
atlas = ExtResource("2_12o6v")
region = Rect2(24, 88, 7, 13)
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_iyfw1"]
radius = 6.0
height = 24.0
[node name="CucumberProjectile" instance=ExtResource("1_iyfw1")]
_speed = 5.0
_damage = 25
[node name="Sprite" parent="." index="0"]
rotation = -1.5708
texture = SubResource("AtlasTexture_h74iy")
[node name="CollisionShape2D" parent="." index="1"]
shape = SubResource("CapsuleShape2D_iyfw1")

View file

@ -0,0 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://b45wmmcie6yeg"]
[ext_resource type="PackedScene" uid="uid://b2hrv0aqbui7u" path="res://scenes/projectiles/pea.tscn" id="1_6vktd"]
[node name="RepeaterProjectile" type="Node2D"]
[node name="Pea" parent="." instance=ExtResource("1_6vktd")]
[node name="Pea2" parent="." instance=ExtResource("1_6vktd")]
position = Vector2(-21, 0)

View file

@ -0,0 +1,22 @@
using Godot;
public partial class CompoundProjectile : Node2D
{
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
GetTree().ProcessFrame += ReleaseCompound;
}
public void ReleaseCompound()
{
GetTree().ProcessFrame -= ReleaseCompound;
foreach (var child in GetChildren())
{
child.Reparent(GetParent());
}
QueueFree();
}
}

View file

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