diff --git a/3d_platforma/Level.tscn b/3d_platforma/Level.tscn index e708858..3227a64 100644 --- a/3d_platforma/Level.tscn +++ b/3d_platforma/Level.tscn @@ -1,9 +1,13 @@ -[gd_scene load_steps=35 format=2] +[gd_scene load_steps=39 format=2] -[ext_resource path="res://scripts/OnMusicChangedSlowTrigger.gd" type="Script" id=1] +[ext_resource path="res://Scripts/Library/Actions/PlaySound.gd" type="Script" id=1] [ext_resource path="res://3d_platforma/golden_bay_512.hdr" type="Texture" 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] +[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] [sub_resource type="CubeMesh" id=1] @@ -565,5 +569,23 @@ light_energy = 0.65 [node name="WorldEnvironment" type="WorldEnvironment" parent="."] environment = SubResource( 24 ) -[node name="MusicChangedSlowAction" type="Node" parent="."] +[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource( 3 ) + +[node name="AudioStreamPlayer3D2" type="AudioStreamPlayer3D" parent="."] +stream = ExtResource( 8 ) + +[node name="TriggerOnReady" type="Node" parent="."] +script = ExtResource( 6 ) +action = NodePath("../ActionList") + +[node name="ActionList" type="Node" parent="."] +script = ExtResource( 7 ) + +[node name="PlaySound" type="Node" parent="ActionList"] script = ExtResource( 1 ) +audioStreamPlayer = NodePath("../../AudioStreamPlayer3D") + +[node name="PlaySound2" type="Node" parent="ActionList"] +script = ExtResource( 1 ) +audioStreamPlayer = NodePath("../../AudioStreamPlayer3D2") diff --git a/project.godot b/project.godot index 12072ed..d300eb8 100644 --- a/project.godot +++ b/project.godot @@ -10,12 +10,42 @@ config_version=4 _global_script_classes=[ { "base": "Node", +"class": "Action", +"language": "GDScript", +"path": "res://Scripts/Library/Actions/Action.gd" +}, { +"base": "Action", +"class": "ActionList", +"language": "GDScript", +"path": "res://Scripts/Library/Actions/ActionList.gd" +}, { +"base": "Node", "class": "MusicChangedSlowAction", "language": "GDScript", -"path": "res://scripts/OnMusicChangedSlowTrigger.gd" +"path": "res://Scripts/OnMusicChangedSlowTrigger.gd" +}, { +"base": "Action", +"class": "PlaySound", +"language": "GDScript", +"path": "res://Scripts/Library/Actions/PlaySound.gd" +}, { +"base": "Node", +"class": "TriggerBase", +"language": "GDScript", +"path": "res://Scripts/Library/Actions/TriggerBase.gd" +}, { +"base": "TriggerBase", +"class": "TriggerOnReady", +"language": "GDScript", +"path": "res://Scripts/Library/Actions/TriggerOnReady.gd" } ] _global_script_class_icons={ -"MusicChangedSlowAction": "" +"Action": "", +"ActionList": "", +"MusicChangedSlowAction": "", +"PlaySound": "", +"TriggerBase": "", +"TriggerOnReady": "" } [application] @@ -24,10 +54,6 @@ config/name="first_anniversary_godot_jam" run/main_scene="res://3d_platforma/Level.tscn" config/icon="res://icon.png" -[autoload] - -MusicSingleton="*res://scripts/MusicSingleton.gd" - [display] window/size/width=480 diff --git a/scripts/Library/Actions/Action.gd b/scripts/Library/Actions/Action.gd new file mode 100644 index 0000000..599569d --- /dev/null +++ b/scripts/Library/Actions/Action.gd @@ -0,0 +1,18 @@ +class_name Action +extends Node + +func triggerNodePath( nodePath:NodePath ): + + var a:Action = get_node( nodePath ); + triggerAction( a ) + + +func triggerAction( a:Action ): + + if a == null: + return + + a.onTrigger() + +func onTrigger(): + pass diff --git a/scripts/Library/Actions/ActionList.gd b/scripts/Library/Actions/ActionList.gd new file mode 100644 index 0000000..cad7e65 --- /dev/null +++ b/scripts/Library/Actions/ActionList.gd @@ -0,0 +1,12 @@ +class_name ActionList +extends Action + + +func onTrigger(): + var children = get_children() + + for c in children: + triggerAction( c ) + + + diff --git a/scripts/Library/Actions/PlaySound.gd b/scripts/Library/Actions/PlaySound.gd new file mode 100644 index 0000000..38077d1 --- /dev/null +++ b/scripts/Library/Actions/PlaySound.gd @@ -0,0 +1,12 @@ +class_name PlaySound +extends Action + +export(NodePath) var audioStreamPlayer + +func _ready(): + onTrigger() + + +func onTrigger(): + get_node( audioStreamPlayer ).play() + diff --git a/scripts/Library/Actions/SFX BlackTiger.wav b/scripts/Library/Actions/SFX BlackTiger.wav new file mode 100644 index 0000000..d67cc44 Binary files /dev/null and b/scripts/Library/Actions/SFX BlackTiger.wav differ diff --git a/scripts/Library/Actions/Snare Admiral 2.wav b/scripts/Library/Actions/Snare Admiral 2.wav new file mode 100644 index 0000000..9e1650b Binary files /dev/null and b/scripts/Library/Actions/Snare Admiral 2.wav differ diff --git a/scripts/Library/Actions/TriggerBase.gd b/scripts/Library/Actions/TriggerBase.gd new file mode 100644 index 0000000..fc87b22 --- /dev/null +++ b/scripts/Library/Actions/TriggerBase.gd @@ -0,0 +1,18 @@ +class_name TriggerBase +extends Node + + +func triggerNodePath( nodePath:NodePath ): + + var a:Action = get_node( nodePath ); + + triggerAction( a ) + + + +func triggerAction( a:Action ): + + if a == null: + return + + a.onTrigger() diff --git a/scripts/Library/Actions/TriggerOnReady.gd b/scripts/Library/Actions/TriggerOnReady.gd new file mode 100644 index 0000000..1bb1e88 --- /dev/null +++ b/scripts/Library/Actions/TriggerOnReady.gd @@ -0,0 +1,13 @@ +class_name TriggerOnReady +extends TriggerBase + + +export(NodePath) var action + +func _ready(): + triggerNodePath( action ) + + + + +