Optimized common data

This commit is contained in:
Jojackman1
2026-01-29 06:36:26 -07:00
parent b58f4412f2
commit 1c4f90fa96
4 changed files with 22 additions and 20 deletions

View File

@@ -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();