Add audio system

This commit is contained in:
Mario Martínez 2024-10-09 12:36:14 +02:00
parent be045c220b
commit 0bfcbbf5f1
45 changed files with 693 additions and 10 deletions

2
.gitattributes vendored
View file

@ -2,3 +2,5 @@
* text=auto eol=lf
*.png filter=lfs diff=lfs merge=lfs -text lockable
*.[tT][tT][fF] filter=lfs diff=lfs merge=lfs -text lockable
*.wav filter=lfs diff=lfs merge=lfs -text lockable
*.mp[34] filter=lfs diff=lfs merge=lfs -text lockable

BIN
Audio/BGM/olympus_combat.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://jlr3b1nye15g"
path="res://.godot/imported/olympus_combat.mp3-599f3eaab3c0e1f24a9caebb3f1f4bc6.mp3str"
[deps]
source_file="res://Audio/BGM/olympus_combat.mp3"
dest_files=["res://.godot/imported/olympus_combat.mp3-599f3eaab3c0e1f24a9caebb3f1f4bc6.mp3str"]
[params]
loop=true
loop_offset=0.66
bpm=0.0
beat_count=0
bar_beats=4

BIN
Audio/BGM/olympus_overworld.mp3 (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://osasql3x1b8q"
path="res://.godot/imported/olympus_overworld.mp3-9490863377fdcac4c0a1d48df9c90915.mp3str"
[deps]
source_file="res://Audio/BGM/olympus_overworld.mp3"
dest_files=["res://.godot/imported/olympus_overworld.mp3-9490863377fdcac4c0a1d48df9c90915.mp3str"]
[params]
loop=true
loop_offset=14.778
bpm=0.0
beat_count=0
bar_beats=4

BIN
Audio/SFX/accept.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://01sdb5n7snib"
path="res://.godot/imported/accept.wav-9449d916ad08f7ed2c514004bdb8a99a.sample"
[deps]
source_file="res://Audio/SFX/accept.wav"
dest_files=["res://.godot/imported/accept.wav-9449d916ad08f7ed2c514004bdb8a99a.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

BIN
Audio/SFX/attack1.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dwvq50tfulr43"
path="res://.godot/imported/attack1.wav-146957159e922939fdee86d98610f407.sample"
[deps]
source_file="res://Audio/SFX/attack1.wav"
dest_files=["res://.godot/imported/attack1.wav-146957159e922939fdee86d98610f407.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

BIN
Audio/SFX/attack2.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ck7bsakeccju0"
path="res://.godot/imported/attack2.wav-e412bcbaff20a9867a9b0931c31ed2fa.sample"
[deps]
source_file="res://Audio/SFX/attack2.wav"
dest_files=["res://.godot/imported/attack2.wav-e412bcbaff20a9867a9b0931c31ed2fa.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

BIN
Audio/SFX/dialog_open.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://drossx2nhgeue"
path="res://.godot/imported/dialog_open.wav-3ebd2a749cac39a43ee08835f8d689c8.sample"
[deps]
source_file="res://Audio/SFX/dialog_open.wav"
dest_files=["res://.godot/imported/dialog_open.wav-3ebd2a749cac39a43ee08835f8d689c8.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

BIN
Audio/SFX/dialog_page.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b72f2jvv2283j"
path="res://.godot/imported/dialog_page.wav-cb65501f9b4a89cdf8f0f25ee05c197f.sample"
[deps]
source_file="res://Audio/SFX/dialog_page.wav"
dest_files=["res://.godot/imported/dialog_page.wav-cb65501f9b4a89cdf8f0f25ee05c197f.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

BIN
Audio/SFX/hit1.wav (Stored with Git LFS) Normal file

Binary file not shown.

24
Audio/SFX/hit1.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://btwcqirsk7053"
path="res://.godot/imported/hit1.wav-3e256e252ad03dcc25545cbe66848bb5.sample"
[deps]
source_file="res://Audio/SFX/hit1.wav"
dest_files=["res://.godot/imported/hit1.wav-3e256e252ad03dcc25545cbe66848bb5.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

BIN
Audio/SFX/hit2.wav (Stored with Git LFS) Normal file

Binary file not shown.

24
Audio/SFX/hit2.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ukgx1p060uts"
path="res://.godot/imported/hit2.wav-6e6475021e86119df0ebc8161640b5b3.sample"
[deps]
source_file="res://Audio/SFX/hit2.wav"
dest_files=["res://.godot/imported/hit2.wav-6e6475021e86119df0ebc8161640b5b3.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

BIN
Audio/SFX/hit3.wav (Stored with Git LFS) Normal file

Binary file not shown.

24
Audio/SFX/hit3.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bxrow17gforve"
path="res://.godot/imported/hit3.wav-237afa0d1d843629dd62d8d9f8226a0b.sample"
[deps]
source_file="res://Audio/SFX/hit3.wav"
dest_files=["res://.godot/imported/hit3.wav-237afa0d1d843629dd62d8d9f8226a0b.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

BIN
Audio/SFX/hit4.wav (Stored with Git LFS) Normal file

Binary file not shown.

24
Audio/SFX/hit4.wav.import Normal file
View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://noh0wd5cb342"
path="res://.godot/imported/hit4.wav-21cdfd99af7010f29347789b01f99543.sample"
[deps]
source_file="res://Audio/SFX/hit4.wav"
dest_files=["res://.godot/imported/hit4.wav-21cdfd99af7010f29347789b01f99543.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

12
Audio/SFX/melee.tres Normal file
View file

@ -0,0 +1,12 @@
[gd_resource type="AudioStreamRandomizer" load_steps=3 format=3 uid="uid://di3fpfsl2vcyi"]
[ext_resource type="AudioStream" uid="uid://dwvq50tfulr43" path="res://Audio/SFX/attack1.wav" id="1_6lpn5"]
[ext_resource type="AudioStream" uid="uid://ck7bsakeccju0" path="res://Audio/SFX/attack2.wav" id="2_ey8ig"]
[resource]
playback_mode = 1
streams_count = 2
stream_0/stream = ExtResource("1_6lpn5")
stream_0/weight = 1.0
stream_1/stream = ExtResource("2_ey8ig")
stream_1/weight = 1.0

18
Audio/SFX/melee_hit.tres Normal file
View file

@ -0,0 +1,18 @@
[gd_resource type="AudioStreamRandomizer" load_steps=5 format=3 uid="uid://dmpd83t5hrd81"]
[ext_resource type="AudioStream" uid="uid://btwcqirsk7053" path="res://Audio/SFX/hit1.wav" id="1_8053b"]
[ext_resource type="AudioStream" uid="uid://ukgx1p060uts" path="res://Audio/SFX/hit2.wav" id="2_78aou"]
[ext_resource type="AudioStream" uid="uid://bxrow17gforve" path="res://Audio/SFX/hit3.wav" id="3_u5k38"]
[ext_resource type="AudioStream" uid="uid://noh0wd5cb342" path="res://Audio/SFX/hit4.wav" id="4_sampv"]
[resource]
playback_mode = 1
streams_count = 4
stream_0/stream = ExtResource("1_8053b")
stream_0/weight = 1.0
stream_1/stream = ExtResource("2_78aou")
stream_1/weight = 1.0
stream_2/stream = ExtResource("3_u5k38")
stream_2/weight = 1.0
stream_3/stream = ExtResource("4_sampv")
stream_3/weight = 1.0

BIN
Audio/SFX/pause.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bp70snfsk40vy"
path="res://.godot/imported/pause.wav-31b7f1fec69aeb043b45654c37f79656.sample"
[deps]
source_file="res://Audio/SFX/pause.wav"
dest_files=["res://.godot/imported/pause.wav-31b7f1fec69aeb043b45654c37f79656.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

BIN
Audio/SFX/puff_smoke.wav (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cvkvgyxqnksir"
path="res://.godot/imported/puff_smoke.wav-e205fe2c6edbf9a60abb47e9cdb79be9.sample"
[deps]
source_file="res://Audio/SFX/puff_smoke.wav"
dest_files=["res://.godot/imported/puff_smoke.wav-e205fe2c6edbf9a60abb47e9cdb79be9.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

109
Audio/music_manager.tscn Normal file
View file

@ -0,0 +1,109 @@
[gd_scene load_steps=6 format=3 uid="uid://81jm7ixvk25n"]
[ext_resource type="Script" path="res://Scripts/Audio/music_manager.gd" id="1_6oqmm"]
[sub_resource type="Animation" id="Animation_pdo8g"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Track2:volume_db")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [-80.0]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Track1:volume_db")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_6vmfp"]
resource_name = "fade_to1"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Track2:volume_db")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0.15, 1),
"transitions": PackedFloat32Array(2.71828, 1),
"update": 0,
"values": [0.0, -80.0]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Track1:volume_db")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0, 0.8),
"transitions": PackedFloat32Array(0.367879, 1),
"update": 0,
"values": [-80.0, 0.0]
}
[sub_resource type="Animation" id="Animation_yv1t3"]
resource_name = "fade_to2"
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("Track2:volume_db")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0, 0.8),
"transitions": PackedFloat32Array(0.367879, 1),
"update": 0,
"values": [-80.0, 0.0]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("Track1:volume_db")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0.15, 1),
"transitions": PackedFloat32Array(2.71828, 1),
"update": 0,
"values": [0.0, -80.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ug0wt"]
_data = {
"RESET": SubResource("Animation_pdo8g"),
"fade_to1": SubResource("Animation_6vmfp"),
"fade_to2": SubResource("Animation_yv1t3")
}
[node name="MusicManager" type="Node"]
process_mode = 3
script = ExtResource("1_6oqmm")
[node name="Track1" type="AudioStreamPlayer" parent="."]
bus = &"BGM"
[node name="Track2" type="AudioStreamPlayer" parent="."]
volume_db = -80.0
bus = &"BGM"
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
libraries = {
"": SubResource("AnimationLibrary_ug0wt")
}
[connection signal="animation_finished" from="AnimationPlayer" to="." method="_on_animation_player_animation_finished"]

14
Audio/sound_manager.tscn Normal file
View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://bbybt6r6351yp"]
[ext_resource type="Script" path="res://Scripts/Audio/sound_manager.gd" id="1_psrqm"]
[ext_resource type="Script" path="res://Scripts/Audio/sound_queue.gd" id="2_y30yw"]
[node name="SoundManager" type="Node"]
process_mode = 3
script = ExtResource("1_psrqm")
[node name="SoundQueue" type="Node" parent="."]
script = ExtResource("2_y30yw")
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="SoundQueue"]
bus = &"SFX"

View file

@ -1,8 +1,13 @@
[gd_resource type="Resource" script_class="Cutscene" load_steps=4 format=3 uid="uid://cwfayxsvfvfp3"]
[gd_resource type="Resource" script_class="Cutscene" load_steps=6 format=3 uid="uid://cwfayxsvfvfp3"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/cutscene.gd" id="1_5oimi"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/wait.gd" id="1_b7jis"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/show_dialogue.gd" id="1_m28bn"]
[sub_resource type="Resource" id="Resource_j0qrl"]
script = ExtResource("1_b7jis")
time = 2.01667
[sub_resource type="Resource" id="Resource_eeatu"]
script = ExtResource("1_m28bn")
character = 0
@ -11,4 +16,4 @@ textbox_direction = 0
[resource]
script = ExtResource("1_5oimi")
commands = Array[Resource("res://Scripts/Cutscenes/Commands/base.gd")]([SubResource("Resource_eeatu")])
commands = Array[Resource("res://Scripts/Cutscenes/Commands/base.gd")]([SubResource("Resource_j0qrl"), SubResource("Resource_eeatu")])

View file

@ -1,11 +1,19 @@
[gd_resource type="Resource" script_class="Cutscene" load_steps=13 format=3 uid="uid://bj3rm1r1ouq0r"]
[gd_resource type="Resource" script_class="Cutscene" load_steps=18 format=3 uid="uid://bj3rm1r1ouq0r"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/cutscene.gd" id="1_ejncn"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/wait.gd" id="1_mrqg0"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/show_dialogue.gd" id="1_r5tuj"]
[ext_resource type="AudioStream" uid="uid://osasql3x1b8q" path="res://Audio/BGM/olympus_overworld.mp3" id="1_wnm4j"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/turn_character.gd" id="2_eqfp1"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/cue_bgm.gd" id="2_fbljl"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/move_character.gd" id="3_rxd5p"]
[ext_resource type="Script" path="res://Scripts/Cutscenes/Commands/lookat_character.gd" id="4_dcsx8"]
[ext_resource type="AudioStream" uid="uid://jlr3b1nye15g" path="res://Audio/BGM/olympus_combat.mp3" id="8_o2rwe"]
[sub_resource type="Resource" id="Resource_xw6ah"]
script = ExtResource("2_fbljl")
music = ExtResource("1_wnm4j")
crossfade = false
[sub_resource type="Resource" id="Resource_h6w6u"]
script = ExtResource("1_mrqg0")
@ -43,7 +51,12 @@ character = 0
messages = Array[String](["Whaaat? Who are you!?", "You have no chance against me!!"])
textbox_direction = 0
[sub_resource type="Resource" id="Resource_1sjaa"]
script = ExtResource("2_fbljl")
music = ExtResource("8_o2rwe")
crossfade = true
[resource]
resource_name = "prototype_start"
script = ExtResource("1_ejncn")
commands = Array[Resource("res://Scripts/Cutscenes/Commands/base.gd")]([SubResource("Resource_h6w6u"), SubResource("Resource_22owj"), SubResource("Resource_rtvbh"), SubResource("Resource_r2p8t"), SubResource("Resource_fuu2y"), SubResource("Resource_x3xc6")])
commands = Array[Resource("res://Scripts/Cutscenes/Commands/base.gd")]([SubResource("Resource_xw6ah"), SubResource("Resource_h6w6u"), SubResource("Resource_22owj"), SubResource("Resource_rtvbh"), SubResource("Resource_r2p8t"), SubResource("Resource_fuu2y"), SubResource("Resource_x3xc6"), SubResource("Resource_1sjaa")])

View file

@ -0,0 +1,36 @@
extends Node
var _current = 0
@onready var _tracks = [ $Track1, $Track2 ]
@onready var _animation_player = $AnimationPlayer
func play_music(audio: AudioStream, crossfade = true):
if crossfade:
_current += 1
_current %= 2
_tracks[_current].stream = audio
_tracks[_current].play()
_animation_player.play("fade_to{0}".format([_current+1]))
else:
_tracks[_current].stream = audio
_tracks[_current].play()
func _on_game_paused():
_tracks[_current].volume_db = -10.0
func _on_game_unpaused():
_tracks[_current].volume_db = 0.0
func _on_cutscene_issued_command(command: CutsceneCommand, manager: CutsceneManager):
if command is CueBGMCommand:
play_music(command.music, command.crossfade)
manager.step()
func _on_animation_player_animation_finished(anim_name: StringName):
if anim_name == &"fade_to1":
_tracks[1].stop()
else:
_tracks[0].stop()

View file

@ -0,0 +1,41 @@
extends Node
const dialogue_continue = preload("res://Audio/SFX/dialog_page.wav")
@export var sounds: Dictionary = {
&"melee": preload("res://Audio/SFX/melee.tres"),
&"melee_hit": preload("res://Audio/SFX/melee_hit.tres"),
&"effect_smoke": preload("res://Audio/SFX/puff_smoke.wav"),
&"pause": preload("res://Audio/SFX/pause.wav"),
&"unpause": preload("res://Audio/SFX/accept.wav"),
&"dialogue_open": preload("res://Audio/SFX/dialog_open.wav"),
&"dialogue_continue": preload("res://Audio/SFX/dialog_page.wav")
}
@onready var queue = $SoundQueue
var timer = 0.0
func play_sound(sound_name: StringName):
var item = sounds.get(sound_name)
if not item is AudioStream:
push_error("The sound with name {0} is not an AudioStream!".format([sound_name]))
else:
queue.play_sound(item)
func _on_game_pause_toggled(paused: bool):
play_sound("pause" if paused else "unpause")
func _on_ui_dialogue_opened():
play_sound("dialogue_open")
func _on_ui_dialogue_continued():
play_sound("dialogue_continue")
func _on_character_got_hurt(new_health: int):
play_sound("melee_hit")
if new_health <= 0 and Globals.nsfw:
play_sound("effect_smoke")
func _on_humanoid_character_attacked():
play_sound("melee")

View file

@ -0,0 +1,46 @@
@tool
class_name SoundQueue extends Node
@export_range(1, 16) var count: int = 8
var _next: int = 0
var _tries: int = 0
var _players: Array[AudioStreamPlayer] = []
func _ready():
if Engine.is_editor_hint():
return
if get_child_count() == 0:
push_warning("A SoundQueue has no child AudioStreamPlayer!")
return
var child = get_child(0)
if child is AudioStreamPlayer:
_players.append(child as AudioStreamPlayer)
for i in count-1:
var duplicate_player = (child as AudioStreamPlayer).duplicate()
add_child(duplicate_player)
_players.append(duplicate_player)
func _get_configuration_warnings():
if get_child_count() == 0:
return ["An AudioStreamPlayer must be set as the first child."]
if not get_child(0) is AudioStreamPlayer:
return ["The first child is not an AudioStreamPlayer."]
func play_sound(sound: AudioStream):
var player = _players[_next]
if player.playing:
_next+=1
_next %= _players.size()
_tries += 1
if _tries < _players.size():
play_sound(sound)
else:
push_warning("Too many sounds playing!")
else:
_tries = 0
player.stream = sound
player.play()
func _on_sound_queued(sound: AudioStream):
play_sound(sound)

View file

@ -10,6 +10,7 @@ class_name CharacterBase
@export var KNOCKBACK_POWER: float = 40
@export var KNOCKBACK_RANDOMNESS: float = 50
signal attacked
signal attack_did_hit(other: Area2D, power: int, attack_direction: Vector2)
signal got_hurt(new_health: int)
signal defeated

View file

@ -0,0 +1,4 @@
class_name CueBGMCommand extends CutsceneCommand
@export var music: AudioStream
@export var crossfade = true

View file

@ -5,14 +5,14 @@ var blink_time = 0
@onready var label = $Control/Label
signal game_unpaused
signal game_unpause_queued
func _input(event):
if event.is_action_pressed("pause"):
get_tree().paused = false
visible = false
get_viewport().set_input_as_handled()
game_unpaused.emit()
game_unpause_queued.emit()
func _process(delta):
blink_time += delta

View file

@ -22,6 +22,8 @@ enum TextboxDirection {
$RightTextbox/ChatboxContainer/Chatbox/PlacementContainer/NextIndicator
]
signal dialogue_started
signal dialogue_opened
signal display_completed
signal dialogue_continued
signal dialogue_completed
@ -72,6 +74,7 @@ func _dialogue_start(_who: Util.CastCharacter, dialogue: Array[String], directio
_text = _dialogue[_next]
_display_text = ""
animation_player.play("show_" + _directions[_direction])
dialogue_started.emit()
func _dialogue_continue():
_next += 1
@ -91,6 +94,7 @@ func _end_dialogue():
func _on_animation_finished(anim_name: StringName):
if anim_name.contains("show"):
_displaying = true
dialogue_opened.emit()
elif anim_name.contains("hide"):
dialogue_completed.emit()

View file

@ -1,10 +1,15 @@
extends Node
signal game_paused
signal game_pause_toggled(paused: bool)
var can_pause = true
func _unhandled_input(event):
if event.is_action_pressed("pause") and can_pause:
game_paused.emit()
game_pause_toggled.emit(true)
get_tree().paused = true
func _on_game_unpause_queued():
get_tree().paused = false
game_pause_toggled.emit(false)

View file

@ -161,6 +161,7 @@ func _on_animation_tree_animation_finished(anim_name):
var animation_rng = randf_range(0, 1)
anim_tree.set("parameters/melee/blend_position", animation_rng)
anim_tree.set("parameters/conditions/melee", true)
attacked.emit()
else:
state_machine.send_event("melee_complete")
@ -218,6 +219,7 @@ func _on_melee_state_entered():
attack_counter_limit = randi_range(3, 5)
anim_tree.set("parameters/conditions/melee", true)
state_machine.set_expression_property("melee_stage", 0)
attacked.emit()
func _on_meleebox_body_exited(body):
if body == player_character:

View file

@ -18,6 +18,7 @@ func _unhandled_input(event):
anim_tree.set("parameters/conditions/melee", true)
can_move = false
velocity = Vector2.ZERO
attacked.emit()
func _process(_delta):
if movement_scripted_by != null:

15
default_bus_layout.tres Normal file
View file

@ -0,0 +1,15 @@
[gd_resource type="AudioBusLayout" format=3 uid="uid://41c8rrd77eur"]
[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 = &"SFX"
bus/2/solo = false
bus/2/mute = false
bus/2/bypass_fx = false
bus/2/volume_db = 0.0
bus/2/send = &"Master"

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=28 format=3 uid="uid://bxuxjqxxqy7ce"]
[gd_scene load_steps=30 format=3 uid="uid://bxuxjqxxqy7ce"]
[ext_resource type="PackedScene" uid="uid://di21xheryhp0k" path="res://Hiro/hiro_player.tscn" id="1_c1gpq"]
[ext_resource type="PackedScene" uid="uid://b8sfype1vx5ad" path="res://Nem/nem_npc.tscn" id="1_sqt7d"]
@ -23,7 +23,9 @@
[ext_resource type="Script" path="res://Scripts/Cutscenes/manager.gd" id="19_5yvrq"]
[ext_resource type="Resource" uid="uid://bj3rm1r1ouq0r" path="res://Cutscenes/prototype_start.tres" id="20_elypl"]
[ext_resource type="PackedScene" uid="uid://bwrwh5of0jw4a" path="res://Reed/reed_ai.tscn" id="21_dioix"]
[ext_resource type="PackedScene" uid="uid://81jm7ixvk25n" path="res://Audio/music_manager.tscn" id="24_03wyf"]
[ext_resource type="Script" path="res://Scripts/game_state.gd" id="24_6ypry"]
[ext_resource type="PackedScene" uid="uid://bbybt6r6351yp" path="res://Audio/sound_manager.tscn" id="25_hm8b0"]
[sub_resource type="LabelSettings" id="LabelSettings_f2g0a"]
font = ExtResource("2_64thh")
@ -242,26 +244,38 @@ reduce_recoil_time_threshold = 0.75
health = 400
attack_power = 10
[node name="MusicManager" parent="." instance=ExtResource("24_03wyf")]
[node name="SoundManager" parent="." instance=ExtResource("25_hm8b0")]
[node name="GameState" type="Node" parent="."]
process_mode = 3
script = ExtResource("24_6ypry")
[connection signal="game_unpause_queued" from="PauseMenu" to="GameState" method="_on_game_unpause_queued"]
[connection signal="dialogue_completed" from="TextboxUI" to="CutsceneManager" method="_on_ui_dialogue_completed"]
[connection signal="dialogue_continued" from="TextboxUI" to="SoundManager" method="_on_ui_dialogue_continued"]
[connection signal="dialogue_opened" from="TextboxUI" to="SoundManager" method="_on_ui_dialogue_opened"]
[connection signal="attack_did_hit" from="HiroPlayer" to="HiroAI" method="_on_player_attack_did_hit"]
[connection signal="attacked" from="HiroPlayer" to="SoundManager" method="_on_humanoid_character_attacked"]
[connection signal="defeated" from="HiroPlayer" to="." method="_on_player_defeated"]
[connection signal="defeated" from="HiroPlayer" to="HiroAI" method="_on_player_been_defeated"]
[connection signal="defeated" from="HiroPlayer" to="ReedAI" method="_on_player_been_defeated"]
[connection signal="got_hurt" from="HiroPlayer" to="CanvasLayer/BattleUI" method="_on_player_got_hurt"]
[connection signal="got_hurt" from="HiroPlayer" to="SoundManager" method="_on_character_got_hurt"]
[connection signal="attack_did_hit" from="HiroAI" to="HiroPlayer" method="_on_enemy_attack_did_hit"]
[connection signal="attacked" from="HiroAI" to="SoundManager" method="_on_humanoid_character_attacked"]
[connection signal="defeated" from="HiroAI" to="." method="_on_ai_defeated"]
[connection signal="got_hurt" from="HiroAI" to="CanvasLayer/BattleUI" method="_on_enemy_got_hurt"]
[connection signal="got_hurt" from="HiroAI" to="SoundManager" method="_on_character_got_hurt"]
[connection signal="finished" from="CutsceneManager" to="." method="_on_cutscene_finished"]
[connection signal="issued_command" from="CutsceneManager" to="." method="_on_cutscene_manager_issued_command"]
[connection signal="issued_command" from="CutsceneManager" to="TextboxUI" method="_on_cutscene_command_issued"]
[connection signal="issued_command" from="CutsceneManager" to="HiroAI" method="_on_cutscene_issued_command"]
[connection signal="issued_command" from="CutsceneManager" to="CutsceneManager" method="_on_issued_command"]
[connection signal="issued_command" from="CutsceneManager" to="MusicManager" method="_on_cutscene_issued_command"]
[connection signal="started" from="CutsceneManager" to="." method="_on_cutscene_started"]
[connection signal="attack_did_hit" from="ReedAI" to="HiroPlayer" method="_on_enemy_attack_did_hit"]
[connection signal="defeated" from="ReedAI" to="." method="_on_ai_defeated"]
[connection signal="got_hurt" from="ReedAI" to="CanvasLayer/BattleUI" method="_on_enemy_got_hurt"]
[connection signal="game_paused" from="GameState" to="PauseMenu" method="_on_game_paused"]
[connection signal="game_pause_toggled" from="GameState" to="SoundManager" method="_on_game_pause_toggled"]