diff --git a/default_bus_layout.tres b/default_bus_layout.tres new file mode 100644 index 0000000..4ef58b7 --- /dev/null +++ b/default_bus_layout.tres @@ -0,0 +1,15 @@ +[gd_resource type="AudioBusLayout" format=3 uid="uid://cdugntqhtcyd"] + +[resource] +bus/1/name = &"BGM" +bus/1/solo = false +bus/1/mute = false +bus/1/bypass_fx = false +bus/1/volume_db = 0.0 +bus/1/send = &"Master" +bus/2/name = &"SoundEffect" +bus/2/solo = false +bus/2/mute = false +bus/2/bypass_fx = false +bus/2/volume_db = -0.0127316 +bus/2/send = &"Master" diff --git a/prefab/entitys/Character.tscn b/prefab/entitys/Character.tscn index 0837ada..d015d78 100644 --- a/prefab/entitys/Character.tscn +++ b/prefab/entitys/Character.tscn @@ -59,3 +59,5 @@ position = Vector2(15, 20) [node name="DamageNumber" type="Marker2D" parent="."] position = Vector2(0, -47) script = ExtResource("3_lrmsw") + +[node name="AudioListener2D" type="AudioListener2D" parent="."] diff --git a/prefab/packsacks/packsack.tscn b/prefab/packsacks/packsack.tscn index cac9ee7..0c95327 100644 --- a/prefab/packsacks/packsack.tscn +++ b/prefab/packsacks/packsack.tscn @@ -15,10 +15,6 @@ collision_mask = 38 script = ExtResource("1_slakl") NumberSlots = 30 Id = "packsack" -UniqueName = null -UniqueDescription = null -_minContactInjury = null -_maxContactInjury = null [node name="DamageArea2D" type="Area2D" parent="."] collision_layer = 8 diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn index ba4ffa5..3f34eb5 100644 --- a/prefab/projectile/curseOfTheUndead.tscn +++ b/prefab/projectile/curseOfTheUndead.tscn @@ -30,3 +30,7 @@ collision_mask = 78 [node name="CollisionShape2D" type="CollisionShape2D" parent="CollisionDetectionArea"] shape = SubResource("CircleShape2D_8117d") + +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="."] +bus = &"SoundEffect" +area_mask = 16 diff --git a/prefab/weapons/staffOfTheUndead.tscn b/prefab/weapons/staffOfTheUndead.tscn index c666b57..666f0d3 100644 --- a/prefab/weapons/staffOfTheUndead.tscn +++ b/prefab/weapons/staffOfTheUndead.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=6 format=3 uid="uid://dnnn2xyayiehk"] +[gd_scene load_steps=7 format=3 uid="uid://dnnn2xyayiehk"] [ext_resource type="Texture2D" uid="uid://e6670ykyq145" path="res://sprites/weapon/staffOfTheUndead.png" id="1_ms3us"] [ext_resource type="Script" path="res://scripts/weapon/ProjectileWeapon.cs" id="1_w8hhv"] [ext_resource type="PackedScene" uid="uid://c01av43yk1q71" path="res://prefab/projectile/curseOfTheUndead.tscn" id="2_34250"] +[ext_resource type="AudioStream" uid="uid://cak6chjjsu7wo" path="res://sounds/fire.wav" id="4_ffr2k"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_obcq2"] size = Vector2(49, 5) @@ -36,3 +37,7 @@ shape = SubResource("RectangleShape2D_14m1g") [node name="Marker2D" type="Marker2D" parent="."] position = Vector2(65, 0) + +[node name="AudioStreamPlayer2D" type="AudioStreamPlayer2D" parent="Marker2D"] +stream = ExtResource("4_ffr2k") +bus = &"SoundEffect" diff --git a/scripts/pickable/PickAbleTemplate.cs b/scripts/pickable/PickAbleTemplate.cs index a52c4ac..21f147f 100644 --- a/scripts/pickable/PickAbleTemplate.cs +++ b/scripts/pickable/PickAbleTemplate.cs @@ -80,7 +80,7 @@ public partial class PickAbleTemplate : RigidBody2D, IItem //If it leaves the ground or walls. //如果离开了地面或墙壁。 - if (node is TileMap) + if (node is TileMapLayer) { _tileMapNumber--; if (_tileMapNumber == 0) @@ -105,7 +105,7 @@ public partial class PickAbleTemplate : RigidBody2D, IItem return; } - if (node is TileMap) + if (node is TileMapLayer) { _tileMapNumber++; EnableContactInjury = false; diff --git a/scripts/weapon/WeaponTemplate.cs b/scripts/weapon/WeaponTemplate.cs index b6380f9..93620ee 100644 --- a/scripts/weapon/WeaponTemplate.cs +++ b/scripts/weapon/WeaponTemplate.cs @@ -13,6 +13,18 @@ public abstract partial class WeaponTemplate : PickAbleTemplate { private float _gravity = ProjectSettings.GetSetting("physics/2d/default_gravity").AsSingle(); + /// + /// Fire audio playback component + /// 开火音效播放组件 + /// + private AudioStreamPlayer2D? _audioStreamPlayer2D; + + public override void _Ready() + { + base._Ready(); + _audioStreamPlayer2D = GetNodeOrNull("Marker2D/AudioStreamPlayer2D"); + } + public override void Use(Node2D? owner, Vector2 targetGlobalPosition) { Fire(owner, targetGlobalPosition); @@ -93,6 +105,7 @@ public abstract partial class WeaponTemplate : PickAbleTemplate } } + _audioStreamPlayer2D?.Play(); DoFire(owner, enemyGlobalPosition); _lastFiringTime = nowTime; } diff --git a/sounds/fire.wav b/sounds/fire.wav new file mode 100644 index 0000000..397b8e1 Binary files /dev/null and b/sounds/fire.wav differ diff --git a/sounds/fire.wav.import b/sounds/fire.wav.import new file mode 100644 index 0000000..e0a8a2d --- /dev/null +++ b/sounds/fire.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cak6chjjsu7wo" +path="res://.godot/imported/fire.wav-bffbfc47d9390c80437953e7f312d8b6.sample" + +[deps] + +source_file="res://sounds/fire.wav" +dest_files=["res://.godot/imported/fire.wav-bffbfc47d9390c80437953e7f312d8b6.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