diff --git a/3d_platforma/Level.tscn b/3d_platforma/Level.tscn index 2f65bc3..de14de0 100644 --- a/3d_platforma/Level.tscn +++ b/3d_platforma/Level.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=13 format=2] +[gd_scene load_steps=18 format=2] [ext_resource path="res://3d_platforma/Player.tscn" type="PackedScene" id=1] [ext_resource path="res://scripts/Library/Actions/Snare Admiral 2.wav" type="AudioStream" id=3] @@ -7,7 +7,12 @@ [ext_resource path="res://scripts/Library/Actions/TriggerOnReady.gd" type="Script" id=6] [ext_resource path="res://scripts/Library/Actions/ActionList.gd" type="Script" id=7] [ext_resource path="res://scripts/Library/Actions/SFX BlackTiger.wav" type="AudioStream" id=8] -[ext_resource path="res://Tape/Tape.tscn" type="PackedScene" id=9] +[ext_resource path="res://Tape/TapeFast.tscn" type="PackedScene" id=9] +[ext_resource path="res://Tape/TapeNormal.tscn" type="PackedScene" id=10] +[ext_resource path="res://Tape/TapeSlow.tscn" type="PackedScene" id=11] +[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] [sub_resource type="SpatialMaterial" id=36] resource_name = "CheckerGrid" @@ -222,5 +227,20 @@ script = ExtResource( 1 ) [node name="PlaySound2" type="Node" parent="ActionList"] script = ExtResource( 1 ) -[node name="Tape" parent="." instance=ExtResource( 9 )] -transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2.1894 ) +[node name="TapeFast" parent="." instance=ExtResource( 9 )] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, -1.34058, 0, -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, 0, -1.35086 ) + +[node name="TapeSlow" parent="." instance=ExtResource( 11 )] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 2.24, 0, -1.3138 ) + +[node name="AudioStreamPlayer3DSlow" type="AudioStreamPlayer3D" parent="."] +script = ExtResource( 12 ) + +[node name="AudioStreamPlayer3DNormal" type="AudioStreamPlayer3D" parent="."] +script = ExtResource( 14 ) + +[node name="AudioStreamPlayer3DFast" type="AudioStreamPlayer3D" parent="."] +script = ExtResource( 13 ) diff --git a/Tape/TapeFast.tscn b/Tape/TapeFast.tscn new file mode 100644 index 0000000..4c3bdc8 --- /dev/null +++ b/Tape/TapeFast.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://scripts/SetFastMusic.gd" type="Script" id=1] +[ext_resource path="res://Tape/tape.obj" type="ArrayMesh" id=2] +[ext_resource path="res://scripts/Library/Actions/TriggerOnCollision.gd" type="Script" id=3] + +[sub_resource type="BoxShape" id=1] + +[node name="TapeFast" type="Spatial"] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="."] +mesh = ExtResource( 2 ) + +[node name="Area" type="Area" parent="."] + +[node name="CollisionShape" type="CollisionShape" parent="Area"] +transform = Transform( 0.240864, 0, 0, 0, 1, 0, 0, 0, 1.66505, 0, 0, 0 ) +shape = SubResource( 1 ) + +[node name="TriggerOnCollision" type="Node" parent="Area"] +script = ExtResource( 3 ) +collision_area = NodePath("..") +action = NodePath("../SetFastMusic") + +[node name="SetFastMusic" type="Node" parent="Area"] +script = ExtResource( 1 ) diff --git a/Tape/TapeNormal.tscn b/Tape/TapeNormal.tscn new file mode 100644 index 0000000..75e39b4 --- /dev/null +++ b/Tape/TapeNormal.tscn @@ -0,0 +1,27 @@ +[gd_scene load_steps=5 format=2] + +[ext_resource path="res://scripts/SetNormalMusic.gd" type="Script" id=1] +[ext_resource path="res://Tape/tape.obj" type="ArrayMesh" id=2] +[ext_resource path="res://scripts/Library/Actions/TriggerOnCollision.gd" type="Script" id=3] + +[sub_resource type="BoxShape" id=1] + +[node name="TapeNormal" type="Spatial"] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0 ) + +[node name="MeshInstance" type="MeshInstance" parent="."] +mesh = ExtResource( 2 ) + +[node name="Area" type="Area" parent="."] + +[node name="CollisionShape" type="CollisionShape" parent="Area"] +transform = Transform( 0.240864, 0, 0, 0, 1, 0, 0, 0, 1.66505, 0, 0, 0 ) +shape = SubResource( 1 ) + +[node name="TriggerOnCollision" type="Node" parent="Area"] +script = ExtResource( 3 ) +collision_area = NodePath("..") +action = NodePath("../SetNormalMusic") + +[node name="SetNormalMusic" type="Node" parent="Area"] +script = ExtResource( 1 ) diff --git a/Tape/Tape.tscn b/Tape/TapeSlow.tscn similarity index 71% rename from Tape/Tape.tscn rename to Tape/TapeSlow.tscn index 3513b02..2963995 100644 --- a/Tape/Tape.tscn +++ b/Tape/TapeSlow.tscn @@ -2,11 +2,12 @@ [ext_resource path="res://Tape/tape.obj" type="ArrayMesh" id=1] [ext_resource path="res://scripts/Library/Actions/TriggerOnCollision.gd" type="Script" id=2] -[ext_resource path="res://scripts/Library/Actions/PlaySound.gd" type="Script" id=3] +[ext_resource path="res://scripts/SetSlowMusic.gd" type="Script" id=3] [sub_resource type="BoxShape" id=1] -[node name="Tape" type="Spatial"] +[node name="TapeSlow" type="Spatial"] +transform = Transform( 0.25, 0, 0, 0, 0.25, 0, 0, 0, 0.25, 0, 0, 0 ) [node name="MeshInstance" type="MeshInstance" parent="."] mesh = ExtResource( 1 ) @@ -20,7 +21,7 @@ shape = SubResource( 1 ) [node name="TriggerOnCollision" type="Node" parent="Area"] script = ExtResource( 2 ) collision_area = NodePath("..") -action = NodePath("../PlaySound") +action = NodePath("../SetSlowMusic") -[node name="PlaySound" type="Node" parent="Area"] +[node name="SetSlowMusic" type="Node" parent="Area"] script = ExtResource( 3 ) diff --git a/project.godot b/project.godot index d787765..4c4ea7a 100644 --- a/project.godot +++ b/project.godot @@ -133,5 +133,4 @@ common/enable_pause_aware_picking=true [rendering] -quality/driver/driver_name="GLES2" environment/default_environment="res://default_env.tres" diff --git a/scripts/Library/Actions/PlaySound.gd b/scripts/Library/Actions/PlaySound.gd index 0e95e9f..38077d1 100644 --- a/scripts/Library/Actions/PlaySound.gd +++ b/scripts/Library/Actions/PlaySound.gd @@ -8,6 +8,5 @@ func _ready(): func onTrigger(): - print("OnTrigger PlaySound") -# get_node( audioStreamPlayer ).play() + get_node( audioStreamPlayer ).play() diff --git a/scripts/MusicSingleton.gd b/scripts/MusicSingleton.gd index f153759..ebd41a8 100644 --- a/scripts/MusicSingleton.gd +++ b/scripts/MusicSingleton.gd @@ -6,6 +6,10 @@ func _ready() -> void: var change_slow_actions : Array = [] var gameSpeed : float = 1; var musicType: int = 0; +var audio_player_slow : AudioStreamPlayer3D +var audio_player_normal : AudioStreamPlayer3D +var audio_player_fast : AudioStreamPlayer3D +var current_audio_player : AudioStreamPlayer3D func setSlowMusic(): setMusicType( -1 ) @@ -19,7 +23,15 @@ func setNormalMusic(): func setMusicType( type:int ): musicType = type; - gameSpeed = 0 + 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() if type == 1: gameSpeed = 2 @@ -39,3 +51,16 @@ func unregister_change_action(change_action : Node) -> void: func change_music() -> void: for change_action in change_slow_actions: change_action.execute() + +func register_audio_player_slow(audio_player : AudioStreamPlayer3D) -> void: + print("Registered audio stream player fast") + audio_player_slow = audio_player + +func register_audio_player_normal(audio_player : AudioStreamPlayer3D) -> void: + print("Registered audio stream player normal") + audio_player_normal = audio_player + +func register_audio_player_fast(audio_player : AudioStreamPlayer3D) -> void: + print("Registered audio stream player fast") + audio_player_fast = audio_player + diff --git a/scripts/RegisterAudioStreamPlayerFast.gd b/scripts/RegisterAudioStreamPlayerFast.gd new file mode 100644 index 0000000..51f51bc --- /dev/null +++ b/scripts/RegisterAudioStreamPlayerFast.gd @@ -0,0 +1,5 @@ +extends AudioStreamPlayer3D + + +func _ready(): + MusicSingleton.register_audio_player_fast(self) diff --git a/scripts/RegisterAudioStreamPlayerNormal.gd b/scripts/RegisterAudioStreamPlayerNormal.gd new file mode 100644 index 0000000..0053928 --- /dev/null +++ b/scripts/RegisterAudioStreamPlayerNormal.gd @@ -0,0 +1,5 @@ +extends AudioStreamPlayer3D + + +func _ready(): + MusicSingleton.register_audio_player_normal(self) diff --git a/scripts/RegisterAudioStreamPlayerSlow.gd b/scripts/RegisterAudioStreamPlayerSlow.gd new file mode 100644 index 0000000..224b63f --- /dev/null +++ b/scripts/RegisterAudioStreamPlayerSlow.gd @@ -0,0 +1,5 @@ +extends AudioStreamPlayer3D + + +func _ready(): + MusicSingleton.register_audio_player_slow(self)