mirror of
https://github.com/thelastflapjack/godot_open_target_shooter.git
synced 2026-07-17 16:45:39 +00:00
Merge pull request #5 from thelastflapjack/add_music_manager
Created initial implementation of MusicManager.
This commit is contained in:
commit
595192383e
15 changed files with 213 additions and 20 deletions
|
|
@ -182,6 +182,7 @@ default_bus_layout="res://audio_bus_layout.tres"
|
|||
|
||||
UserPreferences="*res://src/autoloads/user_preferences.gd"
|
||||
Groups="*res://src/autoloads/groups.gd"
|
||||
MusicManager="*res://src/autoloads/music/music_manager.tscn"
|
||||
|
||||
[display]
|
||||
|
||||
|
|
|
|||
12
raw_assets/music/menu/LICENSE.txt
Normal file
12
raw_assets/music/menu/LICENSE.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Late Night Radio
|
||||
Created by: Kevin MacLeod (incompetech.com)
|
||||
Available at: https://incompetech.com/music/royalty-free/music.html
|
||||
|
||||
---------------------------
|
||||
|
||||
Licensed under Creative Commons: By Attribution 4.0 License
|
||||
http://creativecommons.org/licenses/by/4.0/
|
||||
|
||||
---------------------------
|
||||
|
||||
This is not the original file. The original is stereo but this version has been mixed down to mono.
|
||||
BIN
raw_assets/music/menu/Late Night Radio.mp3
Normal file
BIN
raw_assets/music/menu/Late Night Radio.mp3
Normal file
Binary file not shown.
15
raw_assets/music/menu/Late Night Radio.mp3.import
Normal file
15
raw_assets/music/menu/Late Night Radio.mp3.import
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
path="res://.import/Late Night Radio.mp3-c68095933942029e5a2c5ad928b65fb0.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/menu/Late Night Radio.mp3"
|
||||
dest_files=[ "res://.import/Late Night Radio.mp3-c68095933942029e5a2c5ad928b65fb0.mp3str" ]
|
||||
|
||||
[params]
|
||||
|
||||
loop=true
|
||||
loop_offset=0
|
||||
BIN
raw_assets/music/off_range/Electro Sketch.mp3
Normal file
BIN
raw_assets/music/off_range/Electro Sketch.mp3
Normal file
Binary file not shown.
15
raw_assets/music/off_range/Electro Sketch.mp3.import
Normal file
15
raw_assets/music/off_range/Electro Sketch.mp3.import
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
path="res://.import/Electro Sketch.mp3-2c37310d0e0a68d9b3dd1e3569a05816.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/off_range/Electro Sketch.mp3"
|
||||
dest_files=[ "res://.import/Electro Sketch.mp3-2c37310d0e0a68d9b3dd1e3569a05816.mp3str" ]
|
||||
|
||||
[params]
|
||||
|
||||
loop=true
|
||||
loop_offset=0
|
||||
14
raw_assets/music/off_range/LICENSE.txt
Normal file
14
raw_assets/music/off_range/LICENSE.txt
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
Electro (Sketch)
|
||||
Created by: Kevin MacLeod (incompetech.com)
|
||||
Available at: https://incompetech.com/music/royalty-free/music.html
|
||||
|
||||
---------------------------
|
||||
|
||||
Licensed under Creative Commons: By Attribution 4.0 License
|
||||
http://creativecommons.org/licenses/by/4.0/
|
||||
|
||||
---------------------------
|
||||
|
||||
This is not the original file.
|
||||
The original is stereo but this version has been mixed down to mono.
|
||||
This version is roughly only the first half of the original audio.
|
||||
BIN
raw_assets/music/on_range/Cybermatic pulse (LOOP).mp3
Normal file
BIN
raw_assets/music/on_range/Cybermatic pulse (LOOP).mp3
Normal file
Binary file not shown.
15
raw_assets/music/on_range/Cybermatic pulse (LOOP).mp3.import
Normal file
15
raw_assets/music/on_range/Cybermatic pulse (LOOP).mp3.import
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
[remap]
|
||||
|
||||
importer="mp3"
|
||||
type="AudioStreamMP3"
|
||||
path="res://.import/Cybermatic pulse (LOOP).mp3-e314213aa43639f1c17194102fca4df1.mp3str"
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://raw_assets/music/on_range/Cybermatic pulse (LOOP).mp3"
|
||||
dest_files=[ "res://.import/Cybermatic pulse (LOOP).mp3-e314213aa43639f1c17194102fca4df1.mp3str" ]
|
||||
|
||||
[params]
|
||||
|
||||
loop=true
|
||||
loop_offset=0
|
||||
12
raw_assets/music/on_range/LICENSE.txt
Normal file
12
raw_assets/music/on_range/LICENSE.txt
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
Cybermatic pulse (LOOP)
|
||||
Created by: Alexandr Zhelanov (https://opengameart.org/users/alexandr-zhelanov)
|
||||
Available at: https://opengameart.org/content/cybermatic-pulse
|
||||
|
||||
---------------------------
|
||||
|
||||
Licensed under Creative Commons: By Attribution 4.0 License
|
||||
http://creativecommons.org/licenses/by/4.0/
|
||||
|
||||
---------------------------
|
||||
|
||||
This is not the original file. The original is stereo but this version has been mixed down to mono.
|
||||
67
src/autoloads/music/music_manager.gd
Normal file
67
src/autoloads/music/music_manager.gd
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
extends Node
|
||||
# Docstring
|
||||
|
||||
|
||||
### Signals ###
|
||||
|
||||
### Enums ###
|
||||
enum Tracks {
|
||||
NONE,
|
||||
MAIN_MENU,
|
||||
ON_RANGE,
|
||||
OFF_RANGE,
|
||||
}
|
||||
|
||||
|
||||
### Private variables ###
|
||||
var _current_track_id: int = Tracks.NONE
|
||||
|
||||
|
||||
### Onready variables ###
|
||||
onready var _track_stream_players: Dictionary = {
|
||||
Tracks.MAIN_MENU: $TrackMainMenu,
|
||||
Tracks.ON_RANGE: $TrackOnRange,
|
||||
Tracks.OFF_RANGE: $TrackOffRange,
|
||||
}
|
||||
|
||||
|
||||
############################
|
||||
# Public Methods #
|
||||
############################
|
||||
|
||||
func transition_to_track(new_track_id: int, fade_time: float=1.5, transition_delay: float=0.0) -> void:
|
||||
assert(
|
||||
_track_stream_players.keys().has(new_track_id),
|
||||
"MusicManager Error: Tried to transition to non-existent track."
|
||||
)
|
||||
|
||||
if _current_track_id != Tracks.NONE:
|
||||
_track_fade(_current_track_id, false, fade_time)
|
||||
if transition_delay > 0.0:
|
||||
yield(get_tree().create_timer(transition_delay), "timeout")
|
||||
_track_fade(new_track_id, true, fade_time)
|
||||
_current_track_id = new_track_id
|
||||
|
||||
|
||||
############################
|
||||
# Private Methods #
|
||||
############################
|
||||
|
||||
func _track_fade(track_id: int, fade_in: bool, fade_time: float) -> void:
|
||||
var track_stream_player: AudioStreamPlayer = _track_stream_players[track_id]
|
||||
var tween: SceneTreeTween = create_tween().set_trans(Tween.TRANS_SINE)
|
||||
|
||||
if fade_in:
|
||||
tween.tween_callback(track_stream_player, "play")
|
||||
tween.tween_property(
|
||||
track_stream_player, "volume_db", 0.0, fade_time
|
||||
).from(-20.0).set_ease(Tween.EASE_IN)
|
||||
|
||||
else:
|
||||
tween.tween_property(
|
||||
track_stream_player, "volume_db", -20.0, fade_time
|
||||
).from(0.0).set_ease(Tween.EASE_OUT)
|
||||
tween.tween_callback(track_stream_player, "stop")
|
||||
|
||||
tween.play()
|
||||
|
||||
28
src/autoloads/music/music_manager.tscn
Normal file
28
src/autoloads/music/music_manager.tscn
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
|
||||
[ext_resource path="res://src/autoloads/music/music_manager.gd" type="Script" id=1]
|
||||
[ext_resource path="res://raw_assets/music/menu/Late Night Radio.mp3" type="AudioStream" id=2]
|
||||
[ext_resource path="res://raw_assets/music/off_range/Electro Sketch.mp3" type="AudioStream" id=3]
|
||||
[ext_resource path="res://raw_assets/music/on_range/Cybermatic pulse (LOOP).mp3" type="AudioStream" id=4]
|
||||
|
||||
[node name="MusicManager" type="Node"]
|
||||
pause_mode = 2
|
||||
script = ExtResource( 1 )
|
||||
|
||||
[node name="TrackMainMenu" type="AudioStreamPlayer" parent="."]
|
||||
pause_mode = 2
|
||||
stream = ExtResource( 2 )
|
||||
volume_db = -80.0
|
||||
bus = "Music"
|
||||
|
||||
[node name="TrackOnRange" type="AudioStreamPlayer" parent="."]
|
||||
pause_mode = 2
|
||||
stream = ExtResource( 4 )
|
||||
volume_db = -80.0
|
||||
bus = "Music"
|
||||
|
||||
[node name="TrackOffRange" type="AudioStreamPlayer" parent="."]
|
||||
pause_mode = 2
|
||||
stream = ExtResource( 3 )
|
||||
volume_db = -80.0
|
||||
bus = "Music"
|
||||
|
|
@ -41,6 +41,9 @@ onready var _audio_player_run_end: AudioStreamPlayer = $AudioStreamRunEnd
|
|||
# Engine Callback Methods #
|
||||
############################
|
||||
func _ready() -> void:
|
||||
MusicManager.transition_to_track(
|
||||
MusicManager.Tracks.OFF_RANGE, 3
|
||||
)
|
||||
_player.camera_system = _camera_system
|
||||
|
||||
_par_time = SaveLoad.load_level_par_time(_level_name)
|
||||
|
|
@ -160,6 +163,9 @@ func _connect_signals() -> void:
|
|||
|
||||
|
||||
func _start_run() -> void:
|
||||
MusicManager.transition_to_track(
|
||||
MusicManager.Tracks.ON_RANGE, 1
|
||||
)
|
||||
_audio_player_run_start.play()
|
||||
_is_player_on_range = true
|
||||
_run_time_raw = 0
|
||||
|
|
@ -188,6 +194,9 @@ func _update_and_show_run_summary(missed_enemy_penalty_time_total: float, hit_fr
|
|||
|
||||
|
||||
func _finish_run() -> void:
|
||||
MusicManager.transition_to_track(
|
||||
MusicManager.Tracks.OFF_RANGE, 3
|
||||
)
|
||||
_audio_player_run_end.play()
|
||||
_is_player_on_range = false
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,12 @@
|
|||
extends MultiPageUIPage
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
MusicManager.transition_to_track(
|
||||
MusicManager.Tracks.MAIN_MENU, 3
|
||||
)
|
||||
|
||||
|
||||
func _on_btn_level_pressed() -> void:
|
||||
if active:
|
||||
emit_signal("change_page_request", "LevelSelect")
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ custom_constants/separation = 50
|
|||
alignment = 1
|
||||
|
||||
[node name="Audio" type="GridContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
margin_top = 136.0
|
||||
margin_top = 110.0
|
||||
margin_right = 765.0
|
||||
margin_bottom = 275.0
|
||||
margin_bottom = 302.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
custom_constants/vseparation = 20
|
||||
|
|
@ -147,7 +147,6 @@ margin_bottom = 33.0
|
|||
text = "100"
|
||||
|
||||
[node name="Label3" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio"]
|
||||
visible = false
|
||||
margin_top = 106.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 139.0
|
||||
|
|
@ -156,9 +155,9 @@ align = 2
|
|||
valign = 1
|
||||
|
||||
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio"]
|
||||
visible = false
|
||||
margin_left = 250.0
|
||||
margin_top = 106.0
|
||||
margin_right = 358.0
|
||||
margin_right = 765.0
|
||||
margin_bottom = 139.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
|
|
@ -170,7 +169,7 @@ text = "0"
|
|||
[node name="SliderAudioMusic" type="HSlider" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio/HBoxContainer3"]
|
||||
margin_left = 25.0
|
||||
margin_top = 8.0
|
||||
margin_right = 302.0
|
||||
margin_right = 459.0
|
||||
margin_bottom = 24.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
|
|
@ -180,24 +179,24 @@ tick_count = 5
|
|||
ticks_on_borders = true
|
||||
|
||||
[node name="Label2" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio/HBoxContainer3"]
|
||||
margin_left = 306.0
|
||||
margin_right = 358.0
|
||||
margin_left = 463.0
|
||||
margin_right = 515.0
|
||||
margin_bottom = 33.0
|
||||
text = "100"
|
||||
|
||||
[node name="Label4" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio"]
|
||||
margin_top = 106.0
|
||||
margin_top = 159.0
|
||||
margin_right = 200.0
|
||||
margin_bottom = 139.0
|
||||
margin_bottom = 192.0
|
||||
text = "UI"
|
||||
align = 2
|
||||
valign = 1
|
||||
|
||||
[node name="HBoxContainer4" type="HBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio"]
|
||||
margin_left = 250.0
|
||||
margin_top = 106.0
|
||||
margin_top = 159.0
|
||||
margin_right = 765.0
|
||||
margin_bottom = 139.0
|
||||
margin_bottom = 192.0
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/Audio/HBoxContainer4"]
|
||||
|
|
@ -224,14 +223,14 @@ margin_bottom = 33.0
|
|||
text = "100"
|
||||
|
||||
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
margin_top = 325.0
|
||||
margin_top = 352.0
|
||||
margin_right = 765.0
|
||||
margin_bottom = 329.0
|
||||
margin_bottom = 356.0
|
||||
|
||||
[node name="Gameplay" type="GridContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
margin_top = 379.0
|
||||
margin_top = 406.0
|
||||
margin_right = 765.0
|
||||
margin_bottom = 554.0
|
||||
margin_bottom = 581.0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
custom_constants/vseparation = 20
|
||||
|
|
@ -311,15 +310,15 @@ margin_bottom = 175.0
|
|||
size_flags_horizontal = 0
|
||||
|
||||
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
margin_top = 604.0
|
||||
margin_top = 631.0
|
||||
margin_right = 765.0
|
||||
margin_bottom = 608.0
|
||||
margin_bottom = 635.0
|
||||
|
||||
[node name="Video" type="GridContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
|
||||
margin_left = 161.0
|
||||
margin_top = 658.0
|
||||
margin_top = 685.0
|
||||
margin_right = 603.0
|
||||
margin_bottom = 765.0
|
||||
margin_bottom = 792.0
|
||||
size_flags_horizontal = 4
|
||||
size_flags_vertical = 4
|
||||
custom_constants/vseparation = 20
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue