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,3 @@
[gd_scene format=3 uid="uid://bbngncnb2xeov"]
[node name="EnemyTestLevel" type="Node2D"]

View File

@@ -0,0 +1,31 @@
[gd_scene format=3 uid="uid://c8bxl0uohy535"]
[node name="MainMenu" type="Node2D"]
[node name="RichTextLabel" type="RichTextLabel" parent="."]
offset_left = -65.0
offset_top = -21.0
offset_right = 64.0
offset_bottom = 19.0
text = "Main Menu"
scroll_active = false
autowrap_trim_flags = 0
horizontal_alignment = 1
vertical_alignment = 1
[node name="ExampleButton1" type="Button" parent="."]
offset_top = 47.0
offset_right = 8.0
offset_bottom = 55.0
[node name="ExampleButton2" type="Button" parent="."]
offset_left = 77.0
offset_top = 47.0
offset_right = 85.0
offset_bottom = 55.0
[node name="ExampleButton3" type="Button" parent="."]
offset_left = -65.0
offset_top = 47.0
offset_right = -57.0
offset_bottom = 55.0

View File

@@ -0,0 +1,20 @@
[gd_scene load_steps=2 format=3 uid="uid://bffiqliomwkmo"]
[ext_resource type="Script" uid="uid://co5myvo1u4qn7" path="res://Assets/Scripts/LevelScripts/CameraMovement.cs" id="1_by1m7"]
[node name="Camera" type="Node2D"]
metadata/CameraMode = "FIXED"
[node name="Camera2D" type="Camera2D" parent="."]
script = ExtResource("1_by1m7")
[node name="DEfaultBG" type="ColorRect" parent="Camera2D"]
self_modulate = Color(0.30980393, 0.8901961, 1, 1)
z_index = -1000
z_as_relative = false
offset_left = -320.0
offset_top = -180.0
offset_right = 320.0
offset_bottom = 180.0
[node name="CameraTarget" type="Node2D" parent="."]

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;
}
}

View File

@@ -0,0 +1,49 @@
using Godot;
using System;
public partial class ChangeMenuInitiator : Node2D
{
public void ChangeMenu(string type, string destination)
{
if (type == "SLOW")
{
// Load the menu change manager
var scene = GD.Load<PackedScene>("res://Assets/Scenes/MenusAndLevels/MenuChangeManager.tscn");
var inst = (Node2D)scene.Instantiate();
GetTree().Root.GetNode("Camera").AddChild(inst);
inst.Position = GetTree().Root.GetNode("Camera").GetNode<Node2D>("Camera2D").Position;
// Pass args to menu change manager
inst.GetNode<MenuChangeManager>("MenuChangeManager").TargetMenu = destination;
inst.GetNode<MenuChangeManager>("MenuChangeManager").TransitionDelay = TransitionDelay;
// Wait for intro animation to finish before freeing the scene
inst.GetNode<AnimationPlayer>("AnimationPlayer").AnimationFinished += DeleteMenu;
}
if (type == "FAST")
{
var scene = GD.Load<PackedScene>($"res://Assets/Scenes/MenusAndLevels/{destination}.tscn");
var inst = (Node2D)scene.Instantiate();
GetTree().Root.AddChild(inst);
//reset camera
GetTree().Root.GetNode("Camera").GetNode<CameraMovement>("Camera2D").TeleportCamera(Vector2.Zero);
GetTree().Root.GetNode("Camera").GetNode<CameraMovement>("Camera2D").FixedPosition = GetTree().Root.GetNode("Camera").GetNode<Node2D>("Camera2D").Position;
GetTree().Root.GetNode("Camera").SetMeta("CameraMode", "FIXED");
DeleteMenu("LoadIn");
}
}
void DeleteMenu(StringName arg)
{
if (arg == "LoadIn")
{
// Delete current scene (MAKE SURE THE PARENT OF THE PARENT OF THIS SCRIPT IS THE SCENE YOU CAME FROM)
GetParent().GetParent().QueueFree();
}
}
}

View File

@@ -0,0 +1,91 @@
using Godot;
using System;
using System.Collections.Generic;
// Instantiate this scene and send all data to SetupDailogue()
// arg contains the speaker, speaker icon, and the sentance for example "Sign|GruntCalm|This is a test."
public partial class Dialogue : Node2D
{
string SpeakerName = null;
string SpeakerImage = null;
string Sentance = null;
Queue<string> Data = new Queue<string>();
float ScrollTimer = 0.05f; // Sec
float ScrollTimerReset = 0.05f;
public override void _Process(double delta)
{
if (Input.IsActionJustPressed("interact")) // Advance dialogue
{
AdvanceDialogue();
}
// Scroll text
ScrollTimer -= (float)delta;
if (Sentance != null && ScrollTimer <= 0)
{
ScrollTimer = ScrollTimerReset;
GetNode<RichTextLabel>("Dialogue").VisibleCharacters += 1;
}
}
public void SetupDialogue(string[] arg)
{
GetNode<RichTextLabel>("Dialogue").VisibleCharacters = 0;
// Set up data
foreach (string value in arg)
{
Data.Enqueue(value);
}
// Set up visuals & first dialogue option
if (Data.Count > 0)
{
// Get data
string[] OperatingData = Data.Dequeue().Split("|");
SpeakerName = OperatingData[0];
SpeakerImage = OperatingData[1];
Sentance = OperatingData[2];
//Display data
GetNode<Sprite2D>("Icon").Texture = (Godot.Texture2D)GD.Load($"res://Assets/Sprites/DialogueIcons/{SpeakerImage}.png");
GetNode<RichTextLabel>("SpeakerName").Text = SpeakerName;
GetNode<RichTextLabel>("Dialogue").Text = Sentance;
}
else // If there is nothing left delete the scene
{
QueueFree();
}
}
public void AdvanceDialogue()
{
// Determine wether to skip to the end or display the next sentance
if (GetNode<RichTextLabel>("Dialogue").GetTotalCharacterCount() > GetNode<RichTextLabel>("Dialogue").VisibleCharacters)
{
GetNode<RichTextLabel>("Dialogue").VisibleCharacters = GetNode<RichTextLabel>("Dialogue").GetTotalCharacterCount();
}
else
{
if (Data.Count > 0)
{
GetNode<RichTextLabel>("Dialogue").VisibleCharacters = 0;
// Get data
string[] OperatingData = Data.Dequeue().Split("|");
SpeakerName = OperatingData[0];
SpeakerImage = OperatingData[1];
Sentance = OperatingData[2];
//Display data
GetNode<Sprite2D>("Icon").Texture = (Godot.Texture2D)GD.Load($"res://Assets/Sprites/DialogueIcons/{SpeakerImage}.png");
GetNode<RichTextLabel>("SpeakerName").Text = SpeakerName;
GetNode<RichTextLabel>("Dialogue").Text = Sentance;
}
else // If there is nothing left delete the scene
{
QueueFree();
}
}
}
}

View File

@@ -0,0 +1,59 @@
using Godot;
using System;
// Designed by Jojackman1
public partial class LevelManager : Node
{
Node2D StartNode;
Node2D EndNode;
Node2D Player;
string EndType = "nothing";
public override void _Ready()
{
StartNode = GetParent().GetNode<Node2D>("StartNode");
EndNode = GetParent().GetNode<Node2D>("EndNode");
Player = GetParent().GetNode<Node2D>("Player");
// Play into animation
GetParent().GetNode("ScreenAnimations").GetNode("LevelStartAssets").GetNode<AnimationPlayer>("LevelStart").CurrentAnimation = "default";
GetParent().GetNode("ScreenAnimations").GetNode<Node2D>("LevelStartAssets").Reparent(GetTree().Root.GetNode("Camera").GetNode("Camera2D"));
GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode<Node2D>("LevelStartAssets").GlobalPosition = GetTree().Root.GetNode("Camera").GetNode<Node2D>("Camera2D").GlobalPosition;
GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode<Node2D>("LevelStartAssets").Visible = true;
}
public override void _Process(double delta)
{
// Manage conditions to end the level
if (EndType == "nothing")
{
// Death
if ()
{
EndManager("Death");
EndType = "Death";
}
// Success
if (GetParent().HasNode("Player") && Player.GlobalPosition.DistanceTo(EndNode.GlobalPosition) <= 16)
{
EndManager("Success");
EndType = "Success";
}
}
}
public void EndManager(string EndType)
{
switch (EndType)
{
case "Death": // Player Dies
break;
case "Success": // Successfully make it to the end of the levels
break;
default:
break;
}
}
}

View File

@@ -18,6 +18,34 @@ config/icon="res://icon.svg"
project/assembly_name="FRACTUREPOINT"
[input]
quit_game={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194305,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
]
}
mute={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":77,"key_label":0,"unicode":109,"location":0,"echo":false,"script":null)
]
}
jump={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":119,"location":0,"echo":false,"script":null)
]
}
move_left={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
]
}
move_right={
"deadzone": 0.2,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":100,"location":0,"echo":false,"script":null)
]
}
[rendering]
renderer/rendering_method="gl_compatibility"