1
1
mirror of https://github.com/Rundll86/Dog-Lynx-And-HCN.git synced 2026-06-07 04:07:13 +08:00

Add audio effect and implement FireScan bullet behavior

- Added Rip.wav audio effect to the project.
- Created FireScan bullet script with speed and damage properties.
- Implemented basic AI movement for FireScan bullets.
- Introduced Wave class for managing enemy waves with dynamic counts and spawning logic.
This commit is contained in:
2025-08-26 17:28:20 +08:00
parent 66413bd75d
commit 9a10e87cb0
17 changed files with 283 additions and 70 deletions
+120 -29
View File
@@ -1,11 +1,15 @@
[gd_scene load_steps=13 format=3 uid="uid://cvogxi7mktumf"]
[gd_scene load_steps=17 format=3 uid="uid://cvogxi7mktumf"]
[ext_resource type="Script" path="res://scripts/Statemachine/EntityBase.gd" id="1_mvol6"]
[ext_resource type="Texture2D" uid="uid://dwwpkn4q07ja2" path="res://icon.svg" id="2_7lpu0"]
[ext_resource type="PackedScene" uid="uid://dcjqjqere8ets" path="res://components/UI/EntityStateBar.tscn" id="2_uje1g"]
[sub_resource type="SpriteFrames" id="SpriteFrames_wcqpm"]
animations = [{
"frames": [],
"frames": [{
"duration": 1.0,
"texture": ExtResource("2_7lpu0")
}],
"loop": true,
"name": &"idle",
"speed": 5.0
@@ -19,22 +23,7 @@ animations = [{
[sub_resource type="CircleShape2D" id="CircleShape2D_buhm1"]
radius = 40.0
[sub_resource type="Animation" id="Animation_3wcjn"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(1, 1)]
}
[sub_resource type="Animation" id="Animation_4veur"]
[sub_resource type="Animation" id="Animation_vxanw"]
resource_name = "left"
tracks/0/type = "value"
tracks/0/imported = false
@@ -49,7 +38,7 @@ tracks/0/keys = {
"values": [Vector2(-1, 1)]
}
[sub_resource type="Animation" id="Animation_fgeas"]
[sub_resource type="Animation" id="Animation_nuh11"]
resource_name = "left"
tracks/0/type = "value"
tracks/0/imported = false
@@ -64,11 +53,26 @@ tracks/0/keys = {
"values": [Vector2(1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_kbmff"]
[sub_resource type="Animation" id="Animation_sxh2u"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:scale")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [Vector2(-1, 1)]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_daot2"]
_data = {
"RESET": SubResource("Animation_3wcjn"),
"left": SubResource("Animation_4veur"),
"right": SubResource("Animation_fgeas")
"RESET": SubResource("Animation_sxh2u"),
"left": SubResource("Animation_vxanw"),
"right": SubResource("Animation_nuh11")
}
[sub_resource type="AnimationNodeAnimation" id="AnimationNodeAnimation_ao5k4"]
@@ -84,6 +88,86 @@ blend_point_1/node = SubResource("AnimationNodeAnimation_611yr")
blend_point_1/pos = 1.0
snap = 1.0
[sub_resource type="Animation" id="Animation_3wcjn"]
length = 0.001
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate:r")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.2, 0, 0.2, 0),
"times": PackedFloat32Array(0)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate:g")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.2, 0, 0.2, 0),
"times": PackedFloat32Array(0)
}
tracks/2/type = "bezier"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath(".:modulate:b")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"handle_modes": PackedInt32Array(0),
"points": PackedFloat32Array(1, -0.2, 0, 0.2, 0),
"times": PackedFloat32Array(0)
}
[sub_resource type="Animation" id="Animation_wl2we"]
resource_name = "hurt"
length = 0.4
step = 0.1
tracks/0/type = "bezier"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath(".:modulate:r")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"handle_modes": PackedInt32Array(0, 0, 0),
"points": PackedFloat32Array(1, -0.2, 0, 0.2, 0, 10, -0.2, 0, 0.2, 0, 1, -0.2, 0, 0.2, 0),
"times": PackedFloat32Array(0, 0.2, 0.4)
}
tracks/1/type = "bezier"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath(".:modulate:g")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"handle_modes": PackedInt32Array(0, 0, 0),
"points": PackedFloat32Array(1, -0.2, 0, 0.2, 0, 10, -0.2, 0, 0.2, 0, 1, -0.2, 0, 0.2, 0),
"times": PackedFloat32Array(0, 0.2, 0.4)
}
tracks/2/type = "bezier"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath(".:modulate:b")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"handle_modes": PackedInt32Array(0, 0, 0),
"points": PackedFloat32Array(1, -0.2, 0, 0.2, 0, 10, -0.2, 0, 0.2, 0, 1, -0.2, 0, 0.2, 0),
"times": PackedFloat32Array(0, 0.2, 0.4)
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_kbmff"]
_data = {
"RESET": SubResource("Animation_3wcjn"),
"hurt": SubResource("Animation_wl2we")
}
[sub_resource type="CircleShape2D" id="CircleShape2D_34h7q"]
[node name="EntityBase" type="CharacterBody2D"]
@@ -92,17 +176,18 @@ script = ExtResource("1_mvol6")
[node name="sounds" type="Node2D" parent="."]
unique_name_in_owner = true
[node name="attack" type="AudioStreamPlayer2D" parent="sounds"]
[node name="sprint" type="AudioStreamPlayer2D" parent="sounds"]
[node name="miss" type="AudioStreamPlayer2D" parent="sounds"]
[node name="hurt" type="AudioStreamPlayer2D" parent="sounds"]
[node name="attack0" type="AudioStreamPlayer2D" parent="sounds"]
[node name="texture" type="AnimatedSprite2D" parent="."]
unique_name_in_owner = true
position = Vector2(0, -50)
scale = Vector2(-1, 1)
sprite_frames = SubResource("SpriteFrames_wcqpm")
animation = &"idle"
@@ -113,16 +198,23 @@ unique_name_in_owner = true
shape = SubResource("CircleShape2D_buhm1")
[node name="animator" type="AnimationPlayer" parent="texture"]
unique_name_in_owner = true
libraries = {
"": SubResource("AnimationLibrary_kbmff")
"": SubResource("AnimationLibrary_daot2")
}
[node name="animatree" type="AnimationTree" parent="texture/animator"]
unique_name_in_owner = true
root_node = NodePath("%animatree/../..")
root_node = NodePath("%animator/..")
tree_root = SubResource("AnimationNodeBlendSpace1D_51ube")
anim_player = NodePath("..")
parameters/blend_position = 1.0
parameters/blend_position = 1.36
[node name="hurtAnimator" type="AnimationPlayer" parent="texture"]
unique_name_in_owner = true
libraries = {
"": SubResource("AnimationLibrary_kbmff")
}
[node name="weapons" type="Node2D" parent="texture"]
unique_name_in_owner = true
@@ -137,4 +229,3 @@ position = Vector2(0, -20)
[node name="movebox" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_34h7q")
disabled = true
+14
View File
@@ -0,0 +1,14 @@
[gd_scene load_steps=4 format=3 uid="uid://db2cbgyyjpydp"]
[ext_resource type="PackedScene" uid="uid://crtdkysmnkith" path="res://components/Abstracts/BulletBase.tscn" id="1_cqre5"]
[ext_resource type="Script" path="res://scripts/Contents/Bullets/FireScan.gd" id="2_qprdp"]
[sub_resource type="SegmentShape2D" id="SegmentShape2D_omahd"]
a = Vector2(0, -10)
[node name="FireScan" instance=ExtResource("1_cqre5")]
script = ExtResource("2_qprdp")
lifeDistance = 200.0
[node name="hitbox" parent="." index="1"]
shape = SubResource("SegmentShape2D_omahd")
+7 -2
View File
@@ -1,10 +1,11 @@
[gd_scene load_steps=8 format=3 uid="uid://b0ncrvm8u4pox"]
[gd_scene load_steps=9 format=3 uid="uid://b0ncrvm8u4pox"]
[ext_resource type="PackedScene" uid="uid://cvogxi7mktumf" path="res://components/Abstracts/EntityBase.tscn" id="1_goqmy"]
[ext_resource type="Script" path="res://scripts/Contents/Characters/Chick.gd" id="2_r6bub"]
[ext_resource type="Texture2D" uid="uid://7pkplcqqxvnp" path="res://resources/characters/chick/chick-a.svg" id="2_syddq"]
[ext_resource type="Texture2D" uid="uid://dj5dvqb8gsedr" path="res://resources/characters/chick/chick-b.svg" id="3_064jv"]
[ext_resource type="AudioStream" uid="uid://b7pxuov1id0ho" path="res://resources/sounds/effect/Pew.mp3" id="3_ik1xf"]
[ext_resource type="AudioStream" uid="uid://bx3n11awokuyd" path="res://resources/sounds/effect/Rip.wav" id="4_oyq2p"]
[ext_resource type="PackedScene" uid="uid://dny25qkcvtaa2" path="res://components/Effects/FirePot.tscn" id="6_kvx3n"]
[sub_resource type="SpriteFrames" id="SpriteFrames_xji3d"]
@@ -34,9 +35,12 @@ script = ExtResource("2_r6bub")
cooldownUnit = 200.0
displayName = "小鸡"
[node name="hurt" parent="sounds" index="3"]
[node name="hurt" parent="sounds" index="2"]
stream = ExtResource("3_ik1xf")
[node name="attack1" type="AudioStreamPlayer2D" parent="sounds" index="4"]
stream = ExtResource("4_oyq2p")
[node name="texture" parent="." index="1"]
position = Vector2(0, -37)
sprite_frames = SubResource("SpriteFrames_xji3d")
@@ -46,6 +50,7 @@ animation = &"walk"
position = Vector2(30, -12)
[node name="firepot" parent="texture/weapons/normal" index="0" instance=ExtResource("6_kvx3n")]
unique_name_in_owner = true
[node name="statebar" parent="." index="2" node_paths=PackedStringArray("entity")]
position = Vector2(0, -82)
+1 -1
View File
@@ -35,7 +35,7 @@ radius = 40.0
script = ExtResource("2_8u5a0")
cooldownUnit = 500.0
[node name="hurt" parent="sounds" index="3"]
[node name="hurt" parent="sounds" index="2"]
stream = ExtResource("3_ojyt7")
[node name="texture" parent="." index="1"]
+10 -7
View File
@@ -38,25 +38,25 @@ radius = 41.0122
script = ExtResource("2_oqdqd")
cooldownUnit = 200.0
[node name="attack" parent="sounds" index="0"]
stream = ExtResource("3_4syso")
[node name="sprint" parent="sounds" index="1"]
[node name="sprint" parent="sounds" index="0"]
stream = ExtResource("4_66s6c")
[node name="miss" parent="sounds" index="2"]
[node name="miss" parent="sounds" index="1"]
stream = ExtResource("5_xnbhq")
[node name="hurt" parent="sounds" index="3"]
[node name="hurt" parent="sounds" index="2"]
stream = ExtResource("6_nmmw2")
[node name="attack0" parent="sounds" index="3"]
stream = ExtResource("3_4syso")
[node name="texture" parent="." index="1"]
position = Vector2(0, -70)
sprite_frames = SubResource("SpriteFrames_4v2ol")
animation = &"walk"
[node name="hitbox" parent="texture/hurtbox" index="0"]
position = Vector2(12, 16)
position = Vector2(0, 30)
shape = SubResource("CircleShape2D_h1v0q")
[node name="normal" type="Node2D" parent="texture/weapons" index="0"]
@@ -65,3 +65,6 @@ position = Vector2(54, -45)
[node name="statebar" parent="." index="2" node_paths=PackedStringArray("entity")]
position = Vector2(0, -151)
entity = NodePath("..")
[node name="movebox" parent="." index="3"]
disabled = true
+14 -3
View File
@@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=3 uid="uid://dny25qkcvtaa2"]
[gd_scene load_steps=13 format=3 uid="uid://dny25qkcvtaa2"]
[ext_resource type="PackedScene" uid="uid://bcvuuy2m0pke0" path="res://components/Abstracts/EffectBase.tscn" id="1_k7ukc"]
@@ -22,6 +22,15 @@ colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1)
[sub_resource type="GradientTexture1D" id="GradientTexture1D_miml8"]
gradient = SubResource("Gradient_g8be5")
[sub_resource type="Curve" id="Curve_iaern"]
min_value = -200.0
max_value = 200.0
_data = [Vector2(0, -200), 0.0, 0.0, 0, 0, Vector2(1, 200), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_1flsn"]
curve = SubResource("Curve_iaern")
[sub_resource type="Curve" id="Curve_qy5ym"]
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
@@ -33,11 +42,13 @@ curve = SubResource("Curve_qy5ym")
particle_flag_disable_z = true
angle_min = 1.07288e-05
angle_max = 360.0
direction = Vector3(0, -1, 0)
spread = 15.0
initial_velocity_min = 10.0
initial_velocity_max = 300.0
initial_velocity_max = 500.0
gravity = Vector3(0, 0, 0)
linear_accel_min = -2.23517e-06
linear_accel_max = -2.23517e-06
linear_accel_curve = SubResource("CurveTexture_1flsn")
scale_min = 2.0
scale_max = 12.0
scale_over_velocity_curve = SubResource("CurveTexture_wcx7i")
+6 -16
View File
@@ -1,10 +1,8 @@
[gd_scene load_steps=7 format=3 uid="uid://dmxi1ikn6avig"]
[gd_scene load_steps=5 format=3 uid="uid://dmxi1ikn6avig"]
[ext_resource type="Script" path="res://scripts/Tools/WorldTool.gd" id="1_t2xvy"]
[ext_resource type="PackedScene" uid="uid://dfwg750a47ggx" path="res://components/Scenes/UI.tscn" id="2_04cdd"]
[ext_resource type="PackedScene" uid="uid://bm7ymrri6pykb" path="res://components/Characters/Rooster.tscn" id="3_5ui6q"]
[ext_resource type="PackedScene" uid="uid://b0ncrvm8u4pox" path="res://components/Characters/Chick.tscn" id="4_tnil0"]
[ext_resource type="PackedScene" uid="uid://c8h1abpbe6cww" path="res://components/Characters/Hen.tscn" id="5_i6i4p"]
[ext_resource type="Texture2D" uid="uid://ckk8kahhof06u" path="res://resources/maps/Castle 2.png" id="6_p0nkj"]
[node name="world" type="Node2D"]
@@ -13,6 +11,11 @@ script = ExtResource("1_t2xvy")
[node name="UI" parent="." instance=ExtResource("2_04cdd")]
[node name="background" type="Sprite2D" parent="."]
z_index = -1
position = Vector2(468, 320)
texture = ExtResource("6_p0nkj")
[node name="rooster" parent="." groups=["players"] instance=ExtResource("3_5ui6q")]
position = Vector2(394, 274)
@@ -20,16 +23,3 @@ position = Vector2(394, 274)
position = Vector2(0, -100)
process_callback = 0
position_smoothing_enabled = true
[node name="hen" parent="." groups=["mobs"] instance=ExtResource("5_i6i4p")]
position = Vector2(210, 455)
displayName = "母鸡"
[node name="Chick" parent="." instance=ExtResource("4_tnil0")]
position = Vector2(788, 513)
isBoss = true
[node name="Castle2" type="Sprite2D" parent="."]
z_index = -1
position = Vector2(468, 320)
texture = ExtResource("6_p0nkj")
Binary file not shown.
+24
View File
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bx3n11awokuyd"
path="res://.godot/imported/Rip.wav-252d78561730eebe258400cdc7225903.sample"
[deps]
source_file="res://resources/sounds/effect/Rip.wav"
dest_files=["res://.godot/imported/Rip.wav-252d78561730eebe258400cdc7225903.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0
+10
View File
@@ -0,0 +1,10 @@
extends BulletBase
class_name FireScan
func _ready():
fields[FieldStore.Bullet.SPEED] = 5
fields[FieldStore.Bullet.DAMAGE] = 20
super._ready()
func ai():
forward(Vector2.from_angle(rotation))
+14 -2
View File
@@ -1,7 +1,10 @@
extends EntityBase
class_name Chick
@onready var firepot = $"%firepot"
var angle = 0
func _ready():
fields[FieldStore.Entity.MAX_HEALTH] = 1000
fields[FieldStore.Entity.MOVEMENT_SPEED] = 0.1
@@ -9,9 +12,18 @@ func _ready():
func ai():
move(currentFocusedBoss.position - position)
if tryAttack(0):
angle += 20
if currentFocusedBoss.position.distance_to(position) < 300:
tryAttack(1)
else:
if tryAttack(0):
angle += 20
func attack(type):
if type == 0:
var weaponPos = findWeaponAnchor("normal")
BulletBase.generate(preload("res://components/Bullets/Diamond.tscn"), self, weaponPos, deg_to_rad(angle))
elif type == 1:
var weaponPos = findWeaponAnchor("normal")
var target = weaponPos.angle_to_point(currentFocusedBoss.position)
firepot.global_rotation = target
firepot.shot()
BulletBase.generate(preload("res://components/Bullets/FireScan.tscn"), self, weaponPos, target)
+4
View File
@@ -1,6 +1,10 @@
extends EntityBase
class_name Rooster
func _ready():
fields[FieldStore.Entity.MAX_HEALTH] = 500
super._ready()
func ai():
texture.play("walk")
var direction = Vector2(
+48
View File
@@ -0,0 +1,48 @@
class_name Wave
var entity: PackedScene
var minCount: int = 1
var maxCount: int = 1
var isBoss: bool = false
var from: float = 0
var to: float = 0
var per: int = 0
static var current: int = 0
static var countBoost: float = 0.1 # 每波增加的敌人数量百分比,指数级
static var data: Array[Wave] = [
# entity, minCount, maxCount, isBoss, from, to, per
create(preload("res://components/Characters/Hen.tscn"), 1, 5, false, 0, INF, 1)
]
static func create(
entity_: PackedScene,
minCount_: int = 1,
maxCount_: int = 1,
isBoss_: bool = false,
from_: float = 0,
to_: float = 0,
per_: int = 0
) -> Wave:
var wave = Wave.new()
wave.entity = entity_
wave.minCount = minCount_
wave.maxCount = maxCount_
wave.isBoss = isBoss_
wave.from = from_
wave.to = to_
wave.per = per_
return wave
static func entityCountOf(wave: Wave) -> int:
if wave.from <= current and wave.to >= current and int(current - wave.from) % wave.per == 0:
print("abc")
return randi_range(int(wave.minCount), int(wave.maxCount * ((1 + countBoost) ** current)))
return 0
static func spawn():
for i in range(len(data)):
var wave = data[i]
for j in range(entityCountOf(wave)):
EntityBase.generate(wave.entity, MathTool.randv2_range(500), true, wave.isBoss)
static func next():
spawn()
current += 1
+1 -1
View File
@@ -58,5 +58,5 @@ static func generate(
instance.position = spawnPosition
instance.rotation = spawnRotation
if addToWorld:
WorldTool.rootNode.add_child(instance)
WorldManager.rootNode.add_child(instance)
return instance
+1 -1
View File
@@ -22,5 +22,5 @@ static func create(spawnDamage: float, spawnCrit: bool, spawnPosition: Vector2,
instance.crit = spawnCrit
instance.position = spawnPosition
if addToWorld:
WorldTool.rootNode.add_child(instance)
WorldManager.rootNode.add_child(instance)
return instance
+7 -7
View File
@@ -21,6 +21,7 @@ var fields = {
@onready var hurtbox: Area2D = $"%hurtbox"
@onready var statebar: EntityStateBar = $"%statebar"
@onready var sounds: Node2D = $"%sounds"
@onready var hurtAnimator: AnimationPlayer = $"%hurtAnimator"
var health: float = 0
@@ -57,6 +58,7 @@ func move(direction: Vector2, isSprinting: bool = false):
if currentDirection != 0:
lastDirection = currentDirection
func takeDamage(bullet: BulletBase, crit: bool):
hurtAnimator.play("hurt")
var baseDamage: float = bullet.fields.get(FieldStore.Bullet.DAMAGE) * randf_range(1 - GameRule.damageOffset, 1 + GameRule.damageOffset)
var damage = baseDamage + baseDamage * int(crit) * fields.get(FieldStore.Entity.CRIT_DAMAGE)
if sprinting:
@@ -82,7 +84,7 @@ func startCooldown():
func tryAttack(type: int):
var state = startCooldown()
if state:
playSound("attack")
playSound("attack" + str(type))
attack(type)
return state
func trySprint():
@@ -125,17 +127,15 @@ func sprint():
static func generate(
entity: PackedScene,
spawnPosition: Vector2,
spawnRotation: float,
isMob: bool = true,
spawnAsBoss: bool = false,
addtoWorld: bool = true
addToWorld: bool = true
):
var instance: EntityBase = entity.instance()
var instance: EntityBase = entity.instantiate()
instance.position = spawnPosition
instance.rotation = spawnRotation
instance.isBoss = spawnAsBoss
if isMob:
instance.add_to_group("mobs")
if addtoWorld:
WorldTool.rootNode.add_child(instance)
if addToWorld:
WorldManager.rootNode.add_child(instance)
return instance
+2 -1
View File
@@ -1,5 +1,5 @@
extends Node2D
class_name WorldTool
class_name WorldManager
static var rootNode: Node2D
static var tree: SceneTree
@@ -7,3 +7,4 @@ static var tree: SceneTree
func _ready():
tree = get_tree()
rootNode = self
Wave.next()