diff --git a/#Scenes/SceneScripts/MainMenu.gd b/#Scenes/SceneScripts/MainMenu.gd index 59ca0b78..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() @@ -55,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/TestingScene.gd b/#Scenes/SceneScripts/TestingScene.gd index 60443a74..c21961f2 100644 --- a/#Scenes/SceneScripts/TestingScene.gd +++ b/#Scenes/SceneScripts/TestingScene.gd @@ -10,20 +10,15 @@ func _ready() -> void: PhaseManager.initialize_game() func _play_music() -> void: - var number_of_floors: float = MapManager.get_floors() - - # Offset by 1 since it's reading from an array - var current_player_floor: float = PlayerManager.player_position.y + 1 - - var percentage_complete: float = (current_player_floor / number_of_floors) * 100 + var percentage_complete: float = MapManager.get_map_percent_with_player_position() var music_track: GlobalEnums.MusicTrack - if percentage_complete <= 33: + 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 - else: - music_track = GlobalEnums.MusicTrack.BOSS AudioManager.start_music(music_track) diff --git a/Audio/Battle/area_1.wav.import b/Audio/Battle/area_1.wav.import index bcf986d3..3185c68a 100644 --- a/Audio/Battle/area_1.wav.import +++ b/Audio/Battle/area_1.wav.import @@ -18,7 +18,7 @@ force/max_rate=false force/max_rate_hz=44100 edit/trim=false edit/normalize=false -edit/loop_mode=0 +edit/loop_mode=2 edit/loop_begin=0 edit/loop_end=-1 compress/mode=0 diff --git a/Audio/Battle/area_2.wav.import b/Audio/Battle/area_2.wav.import index e8140b57..e47b2548 100644 --- a/Audio/Battle/area_2.wav.import +++ b/Audio/Battle/area_2.wav.import @@ -18,7 +18,7 @@ force/max_rate=false force/max_rate_hz=44100 edit/trim=false edit/normalize=false -edit/loop_mode=0 +edit/loop_mode=2 edit/loop_begin=0 edit/loop_end=-1 compress/mode=0 diff --git a/Audio/Battle/area_3.wav.import b/Audio/Battle/area_3.wav.import index e5032b0b..57705cfe 100644 --- a/Audio/Battle/area_3.wav.import +++ b/Audio/Battle/area_3.wav.import @@ -18,7 +18,7 @@ force/max_rate=false force/max_rate_hz=44100 edit/trim=false edit/normalize=false -edit/loop_mode=0 +edit/loop_mode=2 edit/loop_begin=0 edit/loop_end=-1 compress/mode=0 diff --git a/Audio/Battle/boss_1.wav.import b/Audio/Battle/boss_1.wav.import index a6a44272..d2824efc 100644 --- a/Audio/Battle/boss_1.wav.import +++ b/Audio/Battle/boss_1.wav.import @@ -18,7 +18,7 @@ force/max_rate=false force/max_rate_hz=44100 edit/trim=false edit/normalize=false -edit/loop_mode=0 +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.import b/Audio/World/heal.wav.import index 174f3da5..57bc7721 100644 --- a/Audio/World/heal.wav.import +++ b/Audio/World/heal.wav.import @@ -18,7 +18,7 @@ force/max_rate=false force/max_rate_hz=44100 edit/trim=false edit/normalize=false -edit/loop_mode=0 +edit/loop_mode=2 edit/loop_begin=0 edit/loop_end=-1 compress/mode=0 diff --git a/Audio/World/shop.wav.import b/Audio/World/shop.wav.import index 48c609da..9bcfdf77 100644 --- a/Audio/World/shop.wav.import +++ b/Audio/World/shop.wav.import @@ -18,7 +18,7 @@ force/max_rate=false force/max_rate_hz=44100 edit/trim=false edit/normalize=false -edit/loop_mode=0 +edit/loop_mode=2 edit/loop_begin=0 edit/loop_end=-1 compress/mode=0 diff --git a/Global/Global_Enums.gd b/Global/Global_Enums.gd index 923507af..463643a5 100644 --- a/Global/Global_Enums.gd +++ b/Global/Global_Enums.gd @@ -192,6 +192,7 @@ enum MusicTrack { BOSS, HEAL, SHOP, + MAIN_MENU, NO_TRACK } diff --git a/Managers/AudioManager.gd b/Managers/AudioManager.gd index 4fc846e2..9eba87c0 100644 --- a/Managers/AudioManager.gd +++ b/Managers/AudioManager.gd @@ -8,6 +8,7 @@ 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, @@ -15,7 +16,8 @@ var music_dictionary: Dictionary = { GlobalEnums.MusicTrack.AREA_THREE: battle_area_3, GlobalEnums.MusicTrack.BOSS: boss, GlobalEnums.MusicTrack.HEAL: heal_event, - GlobalEnums.MusicTrack.SHOP: shop_event + GlobalEnums.MusicTrack.SHOP: shop_event, + GlobalEnums.MusicTrack.MAIN_MENU: main_menu } # SFX @@ -31,6 +33,7 @@ var sfx_stream: AudioStreamPlayer2D = AudioStreamPlayer2D.new() var current_song: GlobalEnums.MusicTrack = GlobalEnums.MusicTrack.NO_TRACK func _ready() -> void: + music_stream add_child(music_stream) add_child(sfx_stream) diff --git a/Managers/MapManager.gd b/Managers/MapManager.gd index 9ce8be97..a98eabc9 100644 --- a/Managers/MapManager.gd +++ b/Managers/MapManager.gd @@ -301,5 +301,10 @@ func get_map_percent_with_player_position() -> float: var player_y_floor: int = player_position.y return (player_y_floor as float / number_of_floors as float) * 100 -func get_floors() -> int: - return map_width_array.size() +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