pruned scripts

This commit is contained in:
Jojackman1
2026-01-19 09:52:06 -07:00
parent 5f2df9568d
commit 9e0eed66c3
10 changed files with 399 additions and 0 deletions

View File

@@ -0,0 +1,87 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class CommonData : Node
{
public bool Muted = true;
// Level information
public string CurrentLevel;
// Level high scores
public int Level1HighScore = 0;
public int Level2HighScore = 0;
public int Level3HighScore = 0;
public int Level4HighScore = 0;
public int Level5HighScore = 0;
public int Level6HighScore = 0;
public int Level7HighScore = 0;
public int Level8HighScore = 0;
public int Level9HighScore = 0;
public int Level10HighScore = 0;
public int Level11HighScore = 0;
// Levels Completed
public HashSet<string> LevelsCompleted = new HashSet<string>();
public override void _Ready()
{
// Connect to the audio player
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Finished += LoopAudio;
GetNode<AudioStreamPlayer>("AudioStreamPlayer").VolumeDb = -80; // temporary
// Start game by loading the camera
var scene = GD.Load<PackedScene>("res://Assets/Scenes/Persistant/Camera.tscn");
var inst = scene.Instantiate();
GetTree().Root.CallDeferred(Node.MethodName.AddChild, inst);
// Start game by loading the main menu
scene = GD.Load<PackedScene>("res://Assets/Scenes/MenusAndLevels/MainMenu.tscn");
inst = scene.Instantiate();
GetTree().Root.CallDeferred(Node.MethodName.AddChild, inst);
PlayMusic("MainMenu");
// Load in saved data
}
public override void _Process(double delta)
{
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;
}
}
}
// BG Audio Management
public void StopMusic()
{
// Stop whatever audio is playing
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Stop();
}
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();
}
void LoopAudio()
{
// Find when the stream finishes playing to play it again
GetNode<AudioStreamPlayer>("AudioStreamPlayer").Play();
}
}

View File

@@ -0,0 +1,21 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class TipManager : RichTextLabel
{
string[] TipList =
{
"Example Tip 1",
"Example Tip 2",
"Example Tip 3"
};
public override void _Ready()
{
// Get random tip and change the text to that
GD.Randomize();
Text = TipList[GD.Randi() % TipList.Length];
}
}

View File

@@ -0,0 +1,10 @@
using Godot;
using System;
public partial class UI : Node2D
{
public override void _Process(double delta)
{
GlobalPosition = GetTree().Root.GetNode("Camera").GetNode<Node2D>("Camera2D").GlobalPosition;
}
}