Adaptive music and music 👍
This commit is contained in:
parent
a8ae482cbe
commit
dcffb97a3d
48 changed files with 603 additions and 24 deletions
24
scripts/ChooseYourSeedsMusic.cs
Normal file
24
scripts/ChooseYourSeedsMusic.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Godot;
|
||||
using Newlon.Components.Level;
|
||||
|
||||
public partial class ChooseYourSeedsMusic : AudioStreamPlayer
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
RuntimeLevelData.Instance.OnLevelStateChanged += OnLevelStateChanged;
|
||||
}
|
||||
|
||||
private void OnLevelStateChanged(RuntimeLevelData.LevelStates state)
|
||||
{
|
||||
if (state == RuntimeLevelData.LevelStates.ChooseYourSeeds)
|
||||
{
|
||||
Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
var tween = CreateTween();
|
||||
tween.TweenProperty(this, "volume_linear", 0, 1);
|
||||
tween.TweenCallback(Callable.From(Stop));
|
||||
}
|
||||
}
|
||||
}
|
||||
1
scripts/ChooseYourSeedsMusic.cs.uid
Normal file
1
scripts/ChooseYourSeedsMusic.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://b4ysi1iutmju3
|
||||
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);
|
||||
}
|
||||
}
|
||||
1
scripts/MusicTransitioner.cs.uid
Normal file
1
scripts/MusicTransitioner.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://bnj5tlcpmep2o
|
||||
|
|
@ -63,8 +63,8 @@ public partial class SaveSerializer : Node
|
|||
Settings.Music = parsed.MusicVolume;
|
||||
Settings.Splash = parsed.SplashSeen;
|
||||
|
||||
AudioServer.SetBusVolumeDb(1, Mathf.LinearToDb((float)Settings.SFX));
|
||||
AudioServer.SetBusVolumeDb(2, Mathf.LinearToDb((float)Settings.Music));
|
||||
AudioServer.SetBusVolumeDb(2, Mathf.LinearToDb(Mathf.Exp((float)Settings.SFX) - 1));
|
||||
AudioServer.SetBusVolumeDb(1, Mathf.LinearToDb(Mathf.Exp((float)Settings.Music) - 1));
|
||||
|
||||
var playerProgress = PlayerProgress.Instance;
|
||||
playerProgress.MaxSeedpackets = parsed.SeedpacketSlots;
|
||||
|
|
|
|||
12
scripts/ScalableAudioPlayer.cs
Normal file
12
scripts/ScalableAudioPlayer.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class ScalableAudioPlayer : AudioStreamPlayer
|
||||
{
|
||||
// Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
if(PitchScale != (float)Engine.TimeScale)
|
||||
PitchScale = (float)Engine.TimeScale * (float)Engine.TimeScale;
|
||||
}
|
||||
}
|
||||
1
scripts/ScalableAudioPlayer.cs.uid
Normal file
1
scripts/ScalableAudioPlayer.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://wfjsgbg3fekl
|
||||
|
|
@ -12,7 +12,7 @@ public partial class AudioSlider : HSlider
|
|||
[Export] private TYPE affects;
|
||||
public override void _Ready()
|
||||
{
|
||||
DragEnded += OnDragEnded;
|
||||
ValueChanged += OnValueChanged;
|
||||
if (affects == TYPE.SFX)
|
||||
{
|
||||
SetValueNoSignal(Settings.SFX);
|
||||
|
|
@ -23,20 +23,19 @@ public partial class AudioSlider : HSlider
|
|||
}
|
||||
}
|
||||
|
||||
private void OnDragEnded(bool hasChanged)
|
||||
private void OnValueChanged(double value)
|
||||
{
|
||||
if (hasChanged)
|
||||
if (affects == TYPE.SFX)
|
||||
{
|
||||
if (affects == TYPE.SFX)
|
||||
{
|
||||
Settings.SFX = Value;
|
||||
AudioServer.SetBusVolumeDb(2, Mathf.LinearToDb((float)Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
Settings.Music = Value;
|
||||
AudioServer.SetBusVolumeDb(1, Mathf.LinearToDb((float)Value));
|
||||
}
|
||||
var volume = Mathf.LinearToDb(Mathf.Exp((float)value) - 1); ;
|
||||
Settings.SFX = value;
|
||||
AudioServer.SetBusVolumeDb(2, volume);
|
||||
}
|
||||
else
|
||||
{
|
||||
var volume = Mathf.LinearToDb(Mathf.Exp((float)value) - 1); ;
|
||||
Settings.Music = value;
|
||||
AudioServer.SetBusVolumeDb(1, volume);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,5 +53,6 @@ public partial class FastForwardButton : Button
|
|||
}
|
||||
|
||||
Engine.TimeScale = speed;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ extends Node
|
|||
|
||||
|
||||
func _on_play_button_pressed() -> void:
|
||||
LevelController.call("StartLevel",preload("uid://dd3yegl1xo44m"),preload("uid://ds2js2vylygvy"))
|
||||
LevelController.call("StartLevel",preload("uid://dd3yegl1xo44m"),preload("uid://ctbue7dex4umy"))
|
||||
$ChannelPlayer.call("Play")
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ public partial class LevelRunner : Node
|
|||
[Export] private float approachNotificationTime;
|
||||
[Export] private AnimationPlayer player;
|
||||
[Export] private Node rewardParent;
|
||||
[Export] private AudioStream firstWaveSound;
|
||||
[Signal] public delegate void ResourceChangedEventHandler(AdventureLevelResource resource);
|
||||
[Signal] public delegate void WaveChangedEventHandler(int to);
|
||||
[Signal] public delegate void HugeWaveApproachingCallbackEventHandler();
|
||||
|
|
@ -68,6 +69,10 @@ public partial class LevelRunner : Node
|
|||
EmitSignal(SignalName.FinalWaveInitiated);
|
||||
return;
|
||||
}
|
||||
if (waveIndex == 0)
|
||||
{
|
||||
AudioSequencer.Play("fl_wave",firstWaveSound);
|
||||
}
|
||||
|
||||
waveTimer.WaitTime = resource.waves[waveIndex].customWaveDelay > 0 ? resource.waves[waveIndex].customWaveDelay : resource.standardWaveDelay;
|
||||
waveTimer.Start();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue