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