diff --git a/#Scenes/SceneScripts/HealScene.gd b/#Scenes/SceneScripts/HealScene.gd index 219c0d12..194a5a63 100644 --- a/#Scenes/SceneScripts/HealScene.gd +++ b/#Scenes/SceneScripts/HealScene.gd @@ -1,4 +1,5 @@ extends Control func _ready() -> void: + AudioManager.start_music(GlobalEnums.MusicTrack.HEAL) SaveManager.execute_save() diff --git a/#Scenes/SceneScripts/MainMenu.gd b/#Scenes/SceneScripts/MainMenu.gd index 6b324e45..59890484 100644 --- a/#Scenes/SceneScripts/MainMenu.gd +++ b/#Scenes/SceneScripts/MainMenu.gd @@ -6,6 +6,7 @@ var continue_button: TextureButton #on opening the main menu we grab the focus of the start button func _ready() -> void: + AudioManager.start_music(GlobalEnums.MusicTrack.MAIN_MENU) $"Menu buttons/Continue".grab_focus() $"game version".text = ProjectSettings.get_setting("application/config/version") for child in get_node("Menu buttons").get_children(): @@ -22,11 +23,13 @@ func _on_start_pressed() -> void: if SaveManager.has_saved_data(): start_new_game_dialog.show() else: + AudioManager.stop_music() _init_managers() SceneManager.goto_scene("res://#Scenes/MapUI.tscn") func _on_continue_pressed() -> void: if SaveManager.has_saved_data(): + AudioManager.stop_music() PlayerManager.load_player() MapManager.load_map_data() XpManager.load_data() @@ -40,6 +43,7 @@ func _on_button_hovered(button: TextureButton) -> void: ## Scene to be loaded when option button is pressed func _on_options_pressed() -> void: + AudioManager.play_sfx(GlobalEnums.SoundEffect.UUUUU) SceneManager.goto_scene("res://#Scenes/OptionsMenu.tscn") @@ -54,6 +58,7 @@ func _on_credits_pressed() -> void: func _on_start_new_game_dialog_confirmed() -> void: SaveManager.clear_data() + AudioManager.stop_music() _init_managers() SceneManager.goto_scene("res://#Scenes/MapUI.tscn") diff --git a/#Scenes/SceneScripts/ShopScene.gd b/#Scenes/SceneScripts/ShopScene.gd index dd5b6385..6a96d9e3 100644 --- a/#Scenes/SceneScripts/ShopScene.gd +++ b/#Scenes/SceneScripts/ShopScene.gd @@ -2,6 +2,7 @@ extends Control class_name ShopScene func _ready() -> void: + AudioManager.start_music(GlobalEnums.MusicTrack.SHOP) # This code has to happen after the map has done '.on_event_started' [br] # so I just put a .1 delay on it diff --git a/#Scenes/SceneScripts/TestingScene.gd b/#Scenes/SceneScripts/TestingScene.gd index 38235ccf..c21961f2 100644 --- a/#Scenes/SceneScripts/TestingScene.gd +++ b/#Scenes/SceneScripts/TestingScene.gd @@ -5,5 +5,20 @@ extends Node2D ## Now that the main scene is the main menu and we load the testing scene from there, we init to properly init the game state func _ready() -> void: + _play_music() SaveManager.execute_save() PhaseManager.initialize_game() + +func _play_music() -> void: + var percentage_complete: float = MapManager.get_map_percent_with_player_position() + var music_track: GlobalEnums.MusicTrack + if MapManager.is_on_last_floor(): + music_track = GlobalEnums.MusicTrack.BOSS + elif percentage_complete <= 33: + music_track = GlobalEnums.MusicTrack.AREA_ONE + elif percentage_complete > 33 and percentage_complete <= 66: + music_track = GlobalEnums.MusicTrack.AREA_TWO + elif percentage_complete > 66 and percentage_complete <= 99: + music_track = GlobalEnums.MusicTrack.AREA_THREE + + AudioManager.start_music(music_track) diff --git a/#Scenes/SceneScripts/TestingScene_UIcontrol.gd b/#Scenes/SceneScripts/TestingScene_UIcontrol.gd index 7ac73950..5f976e75 100644 --- a/#Scenes/SceneScripts/TestingScene_UIcontrol.gd +++ b/#Scenes/SceneScripts/TestingScene_UIcontrol.gd @@ -2,4 +2,5 @@ extends Control func _on_back_to_main_menu_pressed() -> void: + AudioManager.stop_music() SceneManager.goto_scene("res://#Scenes/MainMenu.tscn") diff --git a/Audio/Battle/area_1.wav b/Audio/Battle/area_1.wav new file mode 100644 index 00000000..c3fb841e Binary files /dev/null and b/Audio/Battle/area_1.wav differ diff --git a/Audio/Battle/area_1.wav.import b/Audio/Battle/area_1.wav.import new file mode 100644 index 00000000..3185c68a --- /dev/null +++ b/Audio/Battle/area_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://bcul2j5636jou" +path="res://.godot/imported/area_1.wav-2c34baa1e3757ba46478140199d2135e.sample" + +[deps] + +source_file="res://Audio/Battle/area_1.wav" +dest_files=["res://.godot/imported/area_1.wav-2c34baa1e3757ba46478140199d2135e.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Audio/Battle/area_2.wav b/Audio/Battle/area_2.wav new file mode 100644 index 00000000..0804b290 Binary files /dev/null and b/Audio/Battle/area_2.wav differ diff --git a/Audio/Battle/area_2.wav.import b/Audio/Battle/area_2.wav.import new file mode 100644 index 00000000..e47b2548 --- /dev/null +++ b/Audio/Battle/area_2.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c1l85a2sb0uvx" +path="res://.godot/imported/area_2.wav-1fe080959541db71ffe9c331b81c4fb5.sample" + +[deps] + +source_file="res://Audio/Battle/area_2.wav" +dest_files=["res://.godot/imported/area_2.wav-1fe080959541db71ffe9c331b81c4fb5.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Audio/Battle/area_3.wav b/Audio/Battle/area_3.wav new file mode 100644 index 00000000..48848f45 Binary files /dev/null and b/Audio/Battle/area_3.wav differ diff --git a/Audio/Battle/area_3.wav.import b/Audio/Battle/area_3.wav.import new file mode 100644 index 00000000..57705cfe --- /dev/null +++ b/Audio/Battle/area_3.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://c87sumxo08tbt" +path="res://.godot/imported/area_3.wav-e75c187215113b3d3dba7cc6f9d09a31.sample" + +[deps] + +source_file="res://Audio/Battle/area_3.wav" +dest_files=["res://.godot/imported/area_3.wav-e75c187215113b3d3dba7cc6f9d09a31.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Audio/Battle/boss_1.wav b/Audio/Battle/boss_1.wav new file mode 100644 index 00000000..3043eff6 Binary files /dev/null and b/Audio/Battle/boss_1.wav differ diff --git a/Audio/Battle/boss_1.wav.import b/Audio/Battle/boss_1.wav.import new file mode 100644 index 00000000..d2824efc --- /dev/null +++ b/Audio/Battle/boss_1.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dv22f2psd5s2u" +path="res://.godot/imported/boss_1.wav-0297eb94cdd4630efa5f828b2e37dc8f.sample" + +[deps] + +source_file="res://Audio/Battle/boss_1.wav" +dest_files=["res://.godot/imported/boss_1.wav-0297eb94cdd4630efa5f828b2e37dc8f.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Audio/MainMenu/cicadas.wav b/Audio/MainMenu/cicadas.wav new file mode 100644 index 00000000..86a91860 Binary files /dev/null and b/Audio/MainMenu/cicadas.wav differ diff --git a/Audio/MainMenu/cicadas.wav.import b/Audio/MainMenu/cicadas.wav.import new file mode 100644 index 00000000..2b6e50ae --- /dev/null +++ b/Audio/MainMenu/cicadas.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dn4vvohka34oa" +path="res://.godot/imported/cicadas.wav-dcbeb09c6e6173bc4f40cabe17efe450.sample" + +[deps] + +source_file="res://Audio/MainMenu/cicadas.wav" +dest_files=["res://.godot/imported/cicadas.wav-dcbeb09c6e6173bc4f40cabe17efe450.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Audio/World/heal.wav b/Audio/World/heal.wav new file mode 100644 index 00000000..b4f58dbf Binary files /dev/null and b/Audio/World/heal.wav differ diff --git a/Audio/World/heal.wav.import b/Audio/World/heal.wav.import new file mode 100644 index 00000000..57bc7721 --- /dev/null +++ b/Audio/World/heal.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://dg6gyqm1ejosu" +path="res://.godot/imported/heal.wav-5ab6d90a27f406b6b2d2e28cb6291aa4.sample" + +[deps] + +source_file="res://Audio/World/heal.wav" +dest_files=["res://.godot/imported/heal.wav-5ab6d90a27f406b6b2d2e28cb6291aa4.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Audio/World/shop.wav b/Audio/World/shop.wav new file mode 100644 index 00000000..44122cac Binary files /dev/null and b/Audio/World/shop.wav differ diff --git a/Audio/World/shop.wav.import b/Audio/World/shop.wav.import new file mode 100644 index 00000000..9bcfdf77 --- /dev/null +++ b/Audio/World/shop.wav.import @@ -0,0 +1,24 @@ +[remap] + +importer="wav" +type="AudioStreamWAV" +uid="uid://cpbi46kxjtqm7" +path="res://.godot/imported/shop.wav-cb470f972d3892abc362f53b8b54009b.sample" + +[deps] + +source_file="res://Audio/World/shop.wav" +dest_files=["res://.godot/imported/shop.wav-cb470f972d3892abc362f53b8b54009b.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=2 +edit/loop_begin=0 +edit/loop_end=-1 +compress/mode=0 diff --git a/Dialog/EventDialogueWindow.gd b/Dialog/EventDialogueWindow.gd index 016b8447..de40c0fd 100644 --- a/Dialog/EventDialogueWindow.gd +++ b/Dialog/EventDialogueWindow.gd @@ -89,6 +89,7 @@ var dialogue_line: DialogueLine: func _ready() -> void: + _play_music() SaveManager.execute_save() balloon.hide() Engine.get_singleton("DialogueManager").mutated.connect(_on_mutated) @@ -177,3 +178,15 @@ func add_flavor_text(flavor_text: String, flavor_number: int) -> void: func _on_responses_menu_response_selected(response: DialogueResponse) -> void: next(response.next_id) + +func _play_music() -> void: + var percentage_complete: float = MapManager.get_map_percent_with_player_position() + var music_track: GlobalEnums.MusicTrack + if percentage_complete <= 33: + music_track = GlobalEnums.MusicTrack.AREA_ONE + elif percentage_complete > 33 and percentage_complete <= 66: + music_track = GlobalEnums.MusicTrack.AREA_TWO + elif percentage_complete > 66 and percentage_complete <= 99: + music_track = GlobalEnums.MusicTrack.AREA_THREE + + AudioManager.start_music(music_track) diff --git a/Global/Global_Enums.gd b/Global/Global_Enums.gd index fb308437..a1458bc4 100644 --- a/Global/Global_Enums.gd +++ b/Global/Global_Enums.gd @@ -184,6 +184,23 @@ enum PossibleEnemies { the_berts, } +# Enums to each music track +enum MusicTrack { + AREA_ONE, + AREA_TWO, + AREA_THREE, + BOSS, + HEAL, + SHOP, + MAIN_MENU, + NO_TRACK +} + +# Enums to each SFX +enum SoundEffect { + UUUUU +} + enum CardType { ATTACK, SKILL, diff --git a/Managers/AudioManager.gd b/Managers/AudioManager.gd new file mode 100644 index 00000000..2104edd5 --- /dev/null +++ b/Managers/AudioManager.gd @@ -0,0 +1,75 @@ +extends Node + + +# Music +var battle_area_1: AudioStream = preload("res://Audio/Battle/area_1.wav") +var battle_area_2: AudioStream = preload("res://Audio/Battle/area_2.wav") +var battle_area_3: AudioStream = preload("res://Audio/Battle/area_3.wav") +var boss: AudioStream = preload("res://Audio/Battle/boss_1.wav") +var heal_event: AudioStream = preload("res://Audio/World/heal.wav") +var shop_event: AudioStream = preload("res://Audio/World/shop.wav") +var main_menu: AudioStream = preload("res://Audio/MainMenu/cicadas.wav") + +var music_dictionary: Dictionary = { + GlobalEnums.MusicTrack.AREA_ONE: battle_area_1, + GlobalEnums.MusicTrack.AREA_TWO: battle_area_2, + GlobalEnums.MusicTrack.AREA_THREE: battle_area_3, + GlobalEnums.MusicTrack.BOSS: boss, + GlobalEnums.MusicTrack.HEAL: heal_event, + GlobalEnums.MusicTrack.SHOP: shop_event, + GlobalEnums.MusicTrack.MAIN_MENU: main_menu +} + +# SFX +var uuuuu: AudioStream = preload("res://Audio/fauna_uuu_test.mp3") + +var sfx_dictionary: Dictionary = { + GlobalEnums.SoundEffect.UUUUU: uuuuu +} + +var music_stream: AudioStreamPlayer = AudioStreamPlayer.new() +var sfx_stream: AudioStreamPlayer = AudioStreamPlayer.new() + +var current_song: GlobalEnums.MusicTrack = GlobalEnums.MusicTrack.NO_TRACK + +func _ready() -> void: + add_child(music_stream) + add_child(sfx_stream) + +func start_music(song: GlobalEnums.MusicTrack) -> void: + if current_song == song or song == GlobalEnums.MusicTrack.NO_TRACK: + return + + if music_stream.playing and current_song != song: + var volume_tween: Tween = create_tween() + volume_tween.tween_property(music_stream, "volume_db", -100, 1) + volume_tween.tween_callback(_on_volume_fade_finished.bind(song)) + else: + _on_volume_fade_finished(song) + +func stop_music() -> void: + var volume_tween: Tween = create_tween() + volume_tween.tween_property(music_stream, "volume_db", -100, 0.25) + volume_tween.tween_callback(_on_volume_fade_stop) + +func _on_volume_fade_stop() -> void: + current_song = GlobalEnums.MusicTrack.NO_TRACK + music_stream.volume_db = 0 + music_stream.stop() + +func _on_volume_fade_finished(song: GlobalEnums.MusicTrack) -> void: + music_stream.stream = _get_music_track(song) + music_stream.volume_db = 0 + music_stream.play() + current_song = song + +func _get_music_track(song: GlobalEnums.MusicTrack) -> AudioStream: + return music_dictionary[song] + +func play_sfx(sfx: GlobalEnums.SoundEffect) -> void: + sfx_stream.stream = _get_sound_effect(sfx) + sfx_stream.volume_db = 0 + sfx_stream.play() + +func _get_sound_effect(sfx: GlobalEnums.SoundEffect) -> AudioStream: + return sfx_dictionary[sfx] diff --git a/Managers/MapManager.gd b/Managers/MapManager.gd index 74872160..a98eabc9 100644 --- a/Managers/MapManager.gd +++ b/Managers/MapManager.gd @@ -300,3 +300,11 @@ func get_map_percent_with_player_position() -> float: var number_of_floors: int = map_width_array.size() var player_y_floor: int = player_position.y return (player_y_floor as float / number_of_floors as float) * 100 + +func is_on_last_floor() -> bool: + var number_of_floors: int = map_width_array.size() + + # Add one since we want to compare the number of floors and player position is zero-index based + var player_position_y: int = PlayerManager.player_position.y + 1 + + return number_of_floors == player_position_y diff --git a/project.godot b/project.godot index 00697f93..ae65d3ef 100644 --- a/project.godot +++ b/project.godot @@ -34,6 +34,7 @@ MapManager="*res://Managers/MapManager.gd" InventoryManager="*res://Managers/InventoryManager.gd" DialogueManager="*res://addons/dialogue_manager/dialogue_manager.gd" XpManager="*res://Managers/XpManager.gd" +AudioManager="*res://Managers/AudioManager.gd" ShopManager="*res://Shop/ShopManager.tscn" [debug]