Add factory music (reacts to lever machine start)

This commit is contained in:
karl 2020-01-27 14:46:52 +01:00
parent 791094c0a7
commit 1c79e4cfad
4 changed files with 51 additions and 12 deletions

View File

@ -0,0 +1,22 @@
extends Node
onready var inactive_music = get_node("InactiveMusic")
onready var active_music = get_node("ActiveMusic")
export(NodePath) var path_to_pipegame
var pipegame
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
inactive_music.play()
pipegame = get_node(path_to_pipegame)
pipegame.get_node("Lever").connect("start_machine", self, "activate_active_music")
func activate_active_music():
active_music.play(inactive_music.get_playback_position())
inactive_music.stop()

View File

@ -1,16 +1,19 @@
[gd_scene load_steps=11 format=2] [gd_scene load_steps=14 format=2]
[ext_resource path="res://Level/Buildings/DoubleDoorWall.tscn" type="PackedScene" id=1] [ext_resource path="res://Level/Buildings/DoubleDoorWall.tscn" type="PackedScene" id=1]
[ext_resource path="res://Level/Buildings/DoorWall.tscn" type="PackedScene" id=2] [ext_resource path="res://Level/Buildings/DoorWall.tscn" type="PackedScene" id=2]
[ext_resource path="res://Level/Interactables/FactoryMachines/FactoryGameplay.tscn" type="PackedScene" id=3] [ext_resource path="res://Level/Interactables/FactoryMachines/FactoryGameplay.tscn" type="PackedScene" id=3]
[ext_resource path="res://Level/Decoration/Statue.tscn" type="PackedScene" id=4] [ext_resource path="res://Level/Decoration/Statue.tscn" type="PackedScene" id=4]
[ext_resource path="res://Characters/Player/Player.tscn" type="PackedScene" id=5] [ext_resource path="res://Characters/Player/Player.tscn" type="PackedScene" id=5]
[ext_resource path="res://Level/FactoryMusicHandler.gd" type="Script" id=6]
[sub_resource type="BoxShape" id=3] [ext_resource path="res://Resources/Audio/FactoryMusic/inactive.wav" type="AudioStream" id=7]
[ext_resource path="res://Resources/Audio/FactoryMusic/active.wav" type="AudioStream" id=8]
[sub_resource type="BoxShape" id=1] [sub_resource type="BoxShape" id=1]
[sub_resource type="CubeMesh" id=2] [sub_resource type="BoxShape" id=2]
[sub_resource type="CubeMesh" id=3]
[sub_resource type="CubeMesh" id=4] [sub_resource type="CubeMesh" id=4]
@ -26,25 +29,25 @@
[node name="CollisionShape" type="CollisionShape" parent="Architecture/OutsideEntry"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/OutsideEntry"]
transform = Transform( 6.4742, 0, 0, 0, 1, 0, 0, 0, 4.02915, -24.461, 0, 2.21844 ) transform = Transform( 6.4742, 0, 0, 0, 1, 0, 0, 0, 4.02915, -24.461, 0, 2.21844 )
shape = SubResource( 3 ) shape = SubResource( 1 )
[node name="Floor" type="StaticBody" parent="Architecture"] [node name="Floor" type="StaticBody" parent="Architecture"]
transform = Transform( 100, 0, 0, 0, 1, 0, 0, 0, 100, 0, -1, 0 ) transform = Transform( 100, 0, 0, 0, 1, 0, 0, 0, 100, 0, -1, 0 )
collision_layer = 3 collision_layer = 3
[node name="CollisionShape" type="CollisionShape" parent="Architecture/Floor"] [node name="CollisionShape" type="CollisionShape" parent="Architecture/Floor"]
shape = SubResource( 1 ) shape = SubResource( 2 )
[node name="MeshInstance" type="MeshInstance" parent="Architecture/Floor"] [node name="MeshInstance" type="MeshInstance" parent="Architecture/Floor"]
layers = 3 layers = 3
mesh = SubResource( 2 ) mesh = SubResource( 3 )
material/0 = null material/0 = null
[node name="EntryHall" type="Spatial" parent="Architecture"] [node name="EntryHall" type="Spatial" parent="Architecture"]
editor/display_folded = true editor/display_folded = true
[node name="DoubleDoorWall" parent="Architecture/EntryHall" instance=ExtResource( 1 )] [node name="DoubleDoorWall" parent="Architecture/EntryHall" instance=ExtResource( 1 )]
transform = Transform( -1, 0, -8.74228e-008, 0, 1, 0, 8.74228e-008, 0, -1, 0, 0, 1.8 ) transform = Transform( -1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 1.8 )
[node name="DoorWall" parent="Architecture/EntryHall" instance=ExtResource( 2 )] [node name="DoorWall" parent="Architecture/EntryHall" instance=ExtResource( 2 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, 2 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, -12, 0, 2 )
@ -186,7 +189,7 @@ shape = SubResource( 5 )
[node name="FactoryRoomInterior" type="Spatial" parent="Architecture"] [node name="FactoryRoomInterior" type="Spatial" parent="Architecture"]
[node name="PipeGame" parent="Architecture/FactoryRoomInterior" instance=ExtResource( 3 )] [node name="PipeGame" parent="Architecture/FactoryRoomInterior" instance=ExtResource( 3 )]
transform = Transform( 1, 0, 0, 0, -4.37114e-008, -1, 0, 1, -4.37114e-008, 0, 2, -34.4 ) transform = Transform( 1, 0, 0, 0, -4.37114e-08, -1, 0, 1, -4.37114e-08, 0, 2, -34.4 )
[node name="StatueBlock" type="StaticBody" parent="Architecture/FactoryRoomInterior"] [node name="StatueBlock" type="StaticBody" parent="Architecture/FactoryRoomInterior"]
editor/display_folded = true editor/display_folded = true
@ -202,7 +205,21 @@ material/0 = null
shape = SubResource( 5 ) shape = SubResource( 5 )
[node name="Statue" parent="Architecture/FactoryRoomInterior" instance=ExtResource( 4 )] [node name="Statue" parent="Architecture/FactoryRoomInterior" instance=ExtResource( 4 )]
transform = Transform( -7.86805e-008, 0, -2.5, 0, 1.8, 0, 1.8, 0, -1.09278e-007, 9.5, 0.5, -25.8 ) transform = Transform( -7.86805e-08, 0, -2.5, 0, 1.8, 0, 1.8, 0, -1.09278e-07, 9.5, 0.5, -25.8 )
[node name="Player" parent="." instance=ExtResource( 5 )] [node name="Player" parent="." instance=ExtResource( 5 )]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0 ) transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4, 0 )
[node name="FactoryMusicHandler" type="Node" parent="."]
script = ExtResource( 6 )
path_to_pipegame = NodePath("../Architecture/FactoryRoomInterior/PipeGame")
[node name="InactiveMusic" type="AudioStreamPlayer" parent="FactoryMusicHandler"]
stream = ExtResource( 7 )
bus = "Masked"
[node name="ActiveMusic" type="AudioStreamPlayer" parent="FactoryMusicHandler"]
stream = ExtResource( 8 )
bus = "Masked"
[node name="TrueMusic" type="AudioStreamPlayer" parent="FactoryMusicHandler"]

View File

@ -17,5 +17,5 @@ force/max_rate=false
force/max_rate_hz=44100 force/max_rate_hz=44100
edit/trim=true edit/trim=true
edit/normalize=true edit/normalize=true
edit/loop=false edit/loop=true
compress/mode=0 compress/mode=0

View File

@ -17,5 +17,5 @@ force/max_rate=false
force/max_rate_hz=44100 force/max_rate_hz=44100
edit/trim=true edit/trim=true
edit/normalize=true edit/normalize=true
edit/loop=false edit/loop=true
compress/mode=0 compress/mode=0