fossekleiva-ks-hackathon-demo/Music.gd
Daniel Løvbrøtte Olsen 915246cd2f inital
2019-09-25 21:35:43 +02:00

70 lines
1.7 KiB
GDScript3

extends AudioStreamPlayer
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
randomize()
change_audio()
func change_audio():
var rand = randi() % 7
if rand == 0:
var audio = load("res://Music/portalen1 - 08.09.2019, 10.21.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
elif rand == 1:
var audio = load("res://Music/portalen2 - 08.09.2019, 10.22.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
elif rand == 2:
var audio = load("res://Music/portalen3 - 08.09.2019, 14.10.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
elif rand == 3:
var audio = load("res://Music/portalen4 - 08.09.2019, 14.10.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
elif rand == 4:
var audio = load("res://Music/portalen5 + ødelagt piano - 08.09.2019, 14.09.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
elif rand == 5:
var audio = load("res://Music/portalen6 - 08.09.2019, 14.08.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
elif rand == 6:
var audio = load("res://Music/undercover.wav")
audio.set_loop_mode(audio.LOOP_DISABLED)
set_stream(audio)
play()
func _play_death_music():
var rand = randi() % 2
if rand == 0:
var audio = load("res://Music/Depressed of Happytown.ogg")
set_stream(audio)
play()
if rand == 1:
var audio = load("res://Music/herovic minority.ogg")
set_stream(audio)
play()
func _on_Player__on_death():
stop()
AudioServer.set_bus_mute(1, true)
func _on_Music_finished():
change_audio()