Optimized common data
This commit is contained in:
@@ -14,7 +14,7 @@ public partial class CommonData : Node
|
||||
// Level information
|
||||
public string CurrentLevel;
|
||||
|
||||
// Player information
|
||||
// Player stats
|
||||
public float CurrentHealth;
|
||||
public float MaxHealth = 100;
|
||||
|
||||
@@ -33,13 +33,14 @@ public partial class CommonData : Node
|
||||
GetTree().Root.CallDeferred(Node.MethodName.AddChild, inst);
|
||||
|
||||
// Start game by loading the main menu
|
||||
scene = GD.Load<PackedScene>("res://Assets/Scenes/MenusAndLevels/MainMenu.tscn");
|
||||
//scene = GD.Load<PackedScene>("res://Assets/Scenes/DEVSCENES/EnemyTest.tscn");
|
||||
//scene = GD.Load<PackedScene>("res://Assets/Scenes/MenusAndLevels/MainMenu.tscn");
|
||||
scene = GD.Load<PackedScene>("res://Assets/Scenes/DEVSCENES/EnemyTest.tscn");
|
||||
inst = scene.Instantiate();
|
||||
GetTree().Root.CallDeferred(Node.MethodName.AddChild, inst);
|
||||
PlayMusic("MainMenu");
|
||||
|
||||
// Load in saved data
|
||||
//....?
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
@@ -49,28 +50,18 @@ public partial class CommonData : Node
|
||||
GlobalTimer = NumFramesElapsed / FPS;
|
||||
GlobalTimer = (float)Convert.ToDouble(GlobalTimer.ToString("0.##")); // Truncates seconds elapsed to hundreds place (0.00)
|
||||
//GD.Print(GlobalTimer);
|
||||
if (Input.IsActionJustPressed("quit_game")){GetTree().Quit();}
|
||||
if (Input.IsActionJustPressed("quit_game")) GetTree().Quit();
|
||||
|
||||
if (Input.IsActionJustPressed("mute"))
|
||||
{
|
||||
if (Muted)
|
||||
{
|
||||
Muted = false;
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Muted = true;
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = -80;
|
||||
}
|
||||
if (Input.IsActionJustPressed("mute")){
|
||||
Muted = ! Muted;
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = (Muted) ? -80 : 0;
|
||||
}
|
||||
}
|
||||
|
||||
// BG Audio Management
|
||||
public void StopMusic(){GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stop();}// Stop whatever audio is playing\
|
||||
|
||||
public void PlayMusic(string AudioName)
|
||||
{
|
||||
public void PlayMusic(string AudioName){
|
||||
// Load target audio and play the audio
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stream = (Godot.AudioStream)GD.Load($"res://Assets/Audio/Music/{AudioName}.mp3");
|
||||
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();
|
||||
|
||||
Reference in New Issue
Block a user