Adaptive music and music 👍
This commit is contained in:
parent
a8ae482cbe
commit
dcffb97a3d
48 changed files with 603 additions and 24 deletions
41
scripts/MusicTransitioner.cs
Normal file
41
scripts/MusicTransitioner.cs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
using System;
|
||||
|
||||
public partial class MusicTransitioner : AudioStreamPlayer
|
||||
{
|
||||
private AudioStreamPlaybackInteractive playback;
|
||||
private Timer timer;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
RuntimeLevelData.Instance.OnLevelStateChanged += OnLevelStateChanged;
|
||||
timer = GetNode<Timer>("Timer");
|
||||
}
|
||||
|
||||
private void OnLevelStateChanged(RuntimeLevelData.LevelStates state)
|
||||
{
|
||||
if (state == RuntimeLevelData.LevelStates.Game)
|
||||
{
|
||||
Play();
|
||||
playback = (AudioStreamPlaybackInteractive)GetStreamPlayback();
|
||||
VolumeLinear = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var tween = CreateTween();
|
||||
tween.TweenProperty(this, "volume_linear", 0, 1);
|
||||
tween.TweenCallback(Callable.From(Stop));
|
||||
}
|
||||
}
|
||||
|
||||
public void OnHugeWaveApproaching()
|
||||
{
|
||||
playback.SwitchToClip(1);
|
||||
timer.Start();
|
||||
}
|
||||
public void OnTimerTimeout()
|
||||
{
|
||||
playback.SwitchToClip(0);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue