diff --git a/3d_platforma/Level.tscn b/3d_platforma/Level.tscn index 58cf085..f0cf704 100644 --- a/3d_platforma/Level.tscn +++ b/3d_platforma/Level.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=22 format=2] +[gd_scene load_steps=24 format=2] [ext_resource path="res://3d_platforma/Player.tscn" type="PackedScene" id=1] +[ext_resource path="res://Music/slow track.wav" type="AudioStream" id=2] [ext_resource path="res://scripts/Library/Actions/Snare Admiral 2.wav" type="AudioStream" id=3] [ext_resource path="res://3d_platforma/sqare_norm.png" type="Texture" id=4] [ext_resource path="res://3d_platforma/texture_08.png" type="Texture" id=5] @@ -13,6 +14,7 @@ [ext_resource path="res://scripts/RegisterAudioStreamPlayerSlow.gd" type="Script" id=12] [ext_resource path="res://scripts/RegisterAudioStreamPlayerFast.gd" type="Script" id=13] [ext_resource path="res://scripts/RegisterAudioStreamPlayerNormal.gd" type="Script" id=14] +[ext_resource path="res://Music/godot-project-hiphop.wav" type="AudioStream" id=15] [sub_resource type="SpatialMaterial" id=36] resource_name = "CheckerGrid" @@ -215,7 +217,7 @@ autoplay = "move" anims/move = SubResource( 37 ) [node name="DirectionalLight" type="DirectionalLight" parent="."] -transform = Transform( 0.707107, -0.5, 0.5, 0, 0.707107, 0.707107, -0.707107, -0.5, 0.5, 0, 5, 0 ) +transform = Transform( 0.707107, -0.5, 0.5, 0.00134521, 0.708057, 0.706154, -0.707106, -0.498654, 0.501344, 0, 5, 0 ) light_energy = 0.65 [node name="WorldEnvironment" type="WorldEnvironment" parent="."] @@ -241,18 +243,20 @@ script = ExtResource( 1 ) script = ExtResource( 1 ) [node name="TapeFast" parent="." instance=ExtResource( 9 )] -transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, -1.34058, 6, -1.25926 ) +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, -1.34058, 0.785612, -1.25926 ) [node name="TapeNormal" parent="." instance=ExtResource( 10 )] -transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0.518271, 6, -1.35086 ) +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0.518271, 0.785612, -1.35086 ) [node name="TapeSlow" parent="." instance=ExtResource( 11 )] transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, -0.06, 0.7, -6.3138 ) [node name="AudioStreamPlayer3DSlow" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource( 2 ) script = ExtResource( 12 ) [node name="AudioStreamPlayer3DNormal" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource( 15 ) script = ExtResource( 14 ) [node name="AudioStreamPlayer3DFast" type="AudioStreamPlayer3D" parent="."] diff --git a/Music/slow track.wav b/Music/slow track.wav new file mode 100644 index 0000000..f9ffb8c Binary files /dev/null and b/Music/slow track.wav differ diff --git a/project.godot b/project.godot index d8ccedf..d68c2e5 100644 --- a/project.godot +++ b/project.godot @@ -19,6 +19,11 @@ _global_script_classes=[ { "language": "GDScript", "path": "res://scripts/Library/Actions/ActionList.gd" }, { +"base": "Node", +"class": "MusicChangedSlowAction", +"language": "GDScript", +"path": "res://scripts/Library/Actions/MusicChangedSlowAction.gd" +}, { "base": "Action", "class": "PlaySound", "language": "GDScript", @@ -45,6 +50,11 @@ _global_script_classes=[ { "path": "res://scripts/Library/Actions/TriggerBase.gd" }, { "base": "TriggerBase", +"class": "TriggerOnCollision", +"language": "GDScript", +"path": "res://scripts/Library/Actions/TriggerOnCollision.gd" +}, { +"base": "TriggerBase", "class": "TriggerOnReady", "language": "GDScript", "path": "res://scripts/Library/Actions/TriggerOnReady.gd" @@ -52,11 +62,13 @@ _global_script_classes=[ { _global_script_class_icons={ "Action": "", "ActionList": "", +"MusicChangedSlowAction": "", "PlaySound": "", "SetFastMusic": "", "SetNormalMusic": "", "SetSlowMusic": "", "TriggerBase": "", +"TriggerOnCollision": "", "TriggerOnReady": "" } diff --git a/scripts/Library/Actions/MusicChangedSlowAction.gd b/scripts/Library/Actions/MusicChangedSlowAction.gd new file mode 100644 index 0000000..fae4c25 --- /dev/null +++ b/scripts/Library/Actions/MusicChangedSlowAction.gd @@ -0,0 +1,10 @@ +class_name MusicChangedSlowAction extends Node + +func _ready(): + MusicSingleton.register_change_action(self) + +func _exit_tree(): + MusicSingleton.unregister_change_action(self) + +func execute() -> void: + print("Executed OnMusicChangedSlowAction") diff --git a/scripts/MusicSingleton.gd b/scripts/MusicSingleton.gd index ebd41a8..31b7a10 100644 --- a/scripts/MusicSingleton.gd +++ b/scripts/MusicSingleton.gd @@ -21,24 +21,49 @@ func setNormalMusic(): setMusicType( 0 ) func setMusicType( type:int ): + print("Set Music type") musicType = type; if type == 0: gameSpeed = 0 -# current_playback_position : float = 0.0 -# if current_audio_player: -# current_audio_player.stop() -# current_playback_position = current_audio_player.get_playback_position() -# current_playback_position = current_audio_player.get_playback_position() -# current_playback_position = current_audio_player.get_playback_position() + var current_playback_position : float = 0.0 + print("Set Music type normal") + + if current_audio_player: + current_playback_position = current_audio_player.get_playback_position() + current_audio_player.stop() + + current_audio_player = audio_player_normal + current_audio_player.play(current_playback_position) if type == 1: + gameSpeed = 2 + + var current_playback_position : float = 0.0 + + if current_audio_player: + current_playback_position = current_audio_player.get_playback_position() + current_audio_player.stop() + + current_audio_player = audio_player_fast + current_audio_player.play(current_playback_position) if type == -1: + print("Set Music type slow") + gameSpeed = 0.5 + var current_playback_position : float = 0.0 + + if current_audio_player: + current_playback_position = current_audio_player.get_playback_position() + current_audio_player.stop() + + current_audio_player = audio_player_slow + current_audio_player.play(current_playback_position) + func register_change_action(change_action : Node) -> void: print("Registered change action")