From c397aff0264cf3d50d88947487e6d9f62663cf53 Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Sun, 28 Jul 2024 17:53:54 +0800 Subject: [PATCH] =?UTF-8?q?Add=20sound=20effects.=20=E5=8A=A0=E5=85=A5?= =?UTF-8?q?=E9=9F=B3=E6=95=88=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- default_bus_layout.tres | 15 +++++++++++++++ prefab/entitys/Character.tscn | 2 ++ prefab/packsacks/packsack.tscn | 4 ---- prefab/projectile/curseOfTheUndead.tscn | 4 ++++ prefab/weapons/staffOfTheUndead.tscn | 7 ++++++- scripts/pickable/PickAbleTemplate.cs | 4 ++-- scripts/weapon/WeaponTemplate.cs | 13 +++++++++++++ sounds/fire.wav | Bin 0 -> 14216 bytes sounds/fire.wav.import | 24 ++++++++++++++++++++++++ 9 files changed, 66 insertions(+), 7 deletions(-) create mode 100644 default_bus_layout.tres create mode 100644 sounds/fire.wav create mode 100644 sounds/fire.wav.import 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 0000000000000000000000000000000000000000..397b8e1fb05bd3869796a5b39a5cd3698589e633 GIT binary patch literal 14216 zcmeI&XLMBcqBihdre!7x>BTfs;3A=@$PwX)Lg-CUT0j(3ii&_pmwFTh1&j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