Initial Android commit
This commit is contained in:
commit
1e2b80c13d
8521 changed files with 231475 additions and 0 deletions
97
scripts/BGMScene.gd
Normal file
97
scripts/BGMScene.gd
Normal file
|
@ -0,0 +1,97 @@
|
|||
extends Node
|
||||
|
||||
const defaultVolume:float = 0.0;
|
||||
|
||||
func _ready():
|
||||
StartMenuMusic();
|
||||
|
||||
func StartMenuMusic():
|
||||
var tween = $Tween;
|
||||
if tween.is_active():
|
||||
yield (tween, "tween_all_completed")
|
||||
var audioPlayer = $Tween / AudioStreamPlayer;
|
||||
|
||||
var lowVolume = - 80.0;
|
||||
var fadeMusicTime = 2.0;
|
||||
|
||||
|
||||
audioPlayer.volume_db = lowVolume;
|
||||
audioPlayer.stream = load("res://resources/audio/bgm/1.ogg");
|
||||
|
||||
tween.interpolate_property(audioPlayer, "volume_db", lowVolume, defaultVolume, fadeMusicTime, Tween.TRANS_EXPO, 0)
|
||||
audioPlayer.play(0.0);
|
||||
tween.start();
|
||||
|
||||
func StopMenuMusic():
|
||||
var tween = $Tween;
|
||||
var audioPlayer = $Tween / AudioStreamPlayer;
|
||||
|
||||
var lowVolume = - 80.0;
|
||||
var fadeMusicTime = 1.0;
|
||||
|
||||
|
||||
|
||||
|
||||
tween.interpolate_property(audioPlayer, "volume_db", defaultVolume, lowVolume, fadeMusicTime, Tween.TRANS_EXPO, 0)
|
||||
tween.start();
|
||||
yield (tween, "tween_all_completed")
|
||||
audioPlayer.stop()
|
||||
|
||||
func SetBGM(bgmIndex):
|
||||
var bgmPath = "res://resources/audio/bgm/" + bgmIndex + ".ogg"
|
||||
if bgmIndex == "Survive":
|
||||
bgmPath = "res://resources/audio/bgm/Survive.ogg"
|
||||
Dialogic.set_variable("CurrentBGM", bgmIndex)
|
||||
var bgmStreamPlaying = $TweenBGM.bgmStream.is_playing()
|
||||
if bgmPath == "res://resources/audio/bgm/99.ogg":
|
||||
$TweenBGM.StopBGM();
|
||||
elif bgmStreamPlaying:
|
||||
$TweenBGM.ChangeBGM(bgmPath)
|
||||
else :
|
||||
$TweenBGM.PlayBGM(bgmPath)
|
||||
GallerySingleton.AddMusic(bgmIndex);
|
||||
|
||||
func SetSFXforBGM(sfxPath):
|
||||
var player = $TweenBGMsfx.bgmStream;
|
||||
|
||||
if player.stream != null and player.stream.resource_path == sfxPath and not $TweenBGMsfx.isStoping:
|
||||
return ;
|
||||
|
||||
if player.is_playing():
|
||||
$TweenBGMsfx.ChangeBGM(sfxPath)
|
||||
else :
|
||||
$TweenBGMsfx.PlayBGM(sfxPath)
|
||||
|
||||
func SetSFXforBGMNoFade(sfxPath):
|
||||
var player = $TweenBGMsfx.bgmStream;
|
||||
|
||||
if player.stream != null and player.stream.resource_path == sfxPath and not $TweenBGMsfx.isStoping:
|
||||
return ;
|
||||
|
||||
if player.is_playing():
|
||||
$TweenBGMsfx.ChangeBGMNoFade(sfxPath)
|
||||
else :
|
||||
$TweenBGMsfx.PlayBGMNoFade(sfxPath)
|
||||
|
||||
func StopSFX():
|
||||
var sfxStreamPlaying = $TweenBGMsfx.bgmStream.is_playing()
|
||||
if (sfxStreamPlaying):
|
||||
$TweenBGMsfx.StopBGM()
|
||||
|
||||
|
||||
func SetTriptych(bgmName):
|
||||
var bgmPath = "res://resources/audio/bgm/" + bgmName + ".ogg"
|
||||
Dialogic.set_variable("CurrentBGM", bgmName)
|
||||
var bgmStreamPlaying = $TweenBGM.bgmStream.is_playing()
|
||||
|
||||
|
||||
|
||||
if not "tript" in $TweenBGM.bgmStream.stream.resource_path:
|
||||
$TweenBGM.PlayBGM(bgmPath)
|
||||
return ;
|
||||
|
||||
if bgmStreamPlaying:
|
||||
$TweenBGM.SetNextTriptych(bgmPath);
|
||||
else :
|
||||
$TweenBGM.PlayBGM(bgmPath)
|
||||
GallerySingleton.AddMusic("29");
|
Loading…
Add table
Add a link
Reference in a new issue