Fixed merge errors

This commit is contained in:
Jojackman1
2026-01-19 10:41:03 -07:00
parent 9e0eed66c3
commit 985a975577
50 changed files with 1622 additions and 81 deletions

View File

@@ -1,11 +1,14 @@
using Godot;
using System;
public partial class ChangeMenuInitiator : Node2D
public partial class ChangeMenuInitiator : Node
{
float TransitionDelay = 0; // seconds
Node cameFrom;
public void ChangeMenu(string type, string destination)
public void ChangeMenu(string type, string destination, Node cameFromInput)
{
cameFromInput = cameFrom;
if (type == "SLOW")
{
// Load the menu change manager
@@ -41,8 +44,8 @@ public partial class ChangeMenuInitiator : Node2D
{
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();
// Delete current scene (MAKE SURE THE PARENT OF THE PARENT OF THIS SCRIPT IS THE SCENE)
cameFrom.QueueFree();
}
}

View File

@@ -0,0 +1 @@
uid://b28bv2l2asbpy

View File

@@ -9,19 +9,9 @@ public partial class CommonData : Node
// 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;
// Player information
public float CurrentHealth;
public float MaxHealth = 100;
// Levels Completed
public HashSet<string> LevelsCompleted = new HashSet<string>();

View File

@@ -0,0 +1 @@
uid://nc2lwwjistrq

View File

@@ -0,0 +1,37 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class LevelSelectionManager : Node2D
{
Dictionary<string, string> ConnectionRef = new Dictionary<string, string>();
public override void _Ready()
{
// Create Dictionary
ConnectionRef.Add("Level1", "Level2");
ConnectionRef.Add("Level2", "Level3");
ConnectionRef.Add("Level3", "Level4");
ConnectionRef.Add("Level4", "Level5");
// Disable all levels but the first
foreach (Node2D arg in GetNode("UISelector").GetChildren())
{
if (ConnectionRef.ContainsValue(arg.Name))
arg.SetProcess(false);
}
// Edit buttons according to what is completed
foreach (string arg in GetTree().Root.GetNode<CommonData>("CommonData").LevelsCompleted)
{
if (ConnectionRef.ContainsKey(arg))
{
// Remove fake button
GetNode("FakeButtons").GetNode<Node2D>(ConnectionRef[arg]).Visible = false;
// Add real button
GetNode("UISelector").GetNode<Node2D>(ConnectionRef[arg]).Visible = true;
GetNode("UISelector").GetNode<Node2D>(ConnectionRef[arg]).SetProcess(true);
}
}
}
}

View File

@@ -0,0 +1 @@
uid://bqqpex5a35ttm

View File

@@ -0,0 +1,80 @@
using Godot;
using System;
public partial class MenuChangeManager : Node
{
public string TargetMenu;
public float TransitionDelay = 10;
bool TimerLock = true;
public override void _Ready()
{
// Setup timer
if (TransitionDelay == 10)
{
GD.Randomize();
TransitionDelay += GD.Randf() * 7; // seconds maximum - 10
}
// Connect to signal
GetParent().GetNode<AnimationPlayer>("AnimationPlayer").AnimationFinished += TimerUnlock;
// Stop audio
GetTree().Root.GetNode<CommonData>("CommonData").StopMusic();
}
public override void _Process(double delta)
{
if (TransitionDelay < 0.0f) // Manage waiting
{
TransitionDelay = 1;
TimerLock = true;
SecondHalf();
}
if (TimerLock == false) // Dectiment timer
{
TransitionDelay -= (float)delta;
}
}
void TimerUnlock(StringName arg)
{
if (arg == "LoadIn")
{
TimerLock = false;
}
}
void SecondHalf()
{
//GetTree().Root.GetNode("Camera").GetNode<CameraMovement>("Camera2D").FixedPosition = GetTree().Root.GetNode("Camera").GetNode<Node2D>("Camera2D").Position;
GetTree().Root.GetNode("Camera").GetNode<CameraMovement>("Camera2D").TeleportCamera(Vector2.Zero);
// Load the target menu
var scene = GD.Load<PackedScene>($"res://Assets/Scenes/MenusAndLevels/{TargetMenu}.tscn");
var inst = scene.Instantiate();
GetTree().Root.AddChild(inst);
// Play audio (AUDIO NAME NEEDS TO BE THE SAME NAME AS THE SCENE)
if (ResourceLoader.Exists($"res://Assets/Audio/Music/{TargetMenu}.mp3"))
GetTree().Root.GetNode<CommonData>("CommonData").PlayMusic(TargetMenu);
// Check if the player is there and if it is not then make the camera mode FIXED
var RootChildren = GetTree().Root.GetChildren();
if (RootChildren[2].HasNode("Player") == false)
GetTree().Root.GetNode("Camera").SetMeta("CameraMode", "FIXED");
GetParent().GetNode<AnimationPlayer>("AnimationPlayer").CurrentAnimation = "LoadOut";
// Check when animation is finished
GetParent().GetNode<AnimationPlayer>("AnimationPlayer").AnimationFinished += DeleteMenu;
}
void DeleteMenu(StringName arg)
{
if (arg == "LoadOut")
{
// Delete change manager
GetParent().QueueFree();
}
}
}

View File

@@ -0,0 +1 @@
uid://dedv5j5tvb2gk

View File

@@ -0,0 +1,10 @@
using Godot;
using System;
public partial class SceneChangeButton : Button
{
void _on_pressed()
{
GetTree().Root.GetNode("CommonData").GetNode<ChangeMenuInitiator>("ChangeMenuInitiator").ChangeMenu("HTP", "slow",GetParent());
}
}

View File

@@ -0,0 +1 @@
uid://c8ibbithifum2

View File

@@ -7,9 +7,7 @@ public partial class TipManager : RichTextLabel
string[] TipList =
{
"Example Tip 1",
"Example Tip 2",
"Example Tip 3"
"Example Tip"
};
public override void _Ready()

View File

@@ -0,0 +1 @@
uid://cugofqkikepb2

View File

@@ -3,6 +3,7 @@ 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 @@
uid://ddyi5usr6poda

View File

@@ -0,0 +1,46 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class UISelector : Node2D
{
List<Node2D> AvailableOptions = new List<Node2D>();
public Node2D SelectedOption;
int SelectedKey = 0;
Node2D SelectionIndicator;
public override void _Ready()
{
// Set up selection indicator
SelectionIndicator = GetNode<Node2D>("SelectionIndicator");
// Set up list of options
foreach (Node2D option in GetChildren())
{
if (option != SelectionIndicator)
AvailableOptions.Add(option);
}
// Set defaults
SelectedOption = AvailableOptions[SelectedKey];
SelectionIndicator.Position = SelectedOption.Position;
}
public override void _Process(double delta)
{
// Select next option
if(Input.IsActionJustPressed("menu_right") && SelectedKey < AvailableOptions.Count - 1)
{
SelectedKey += 1;
}
// Select previous option
if(Input.IsActionJustPressed("menu_left") && SelectedKey != 0)
{
SelectedKey -= 1;
}
SelectedOption = AvailableOptions[SelectedKey];
SelectionIndicator.Position = SelectedOption.Position;
}
}

View File

@@ -0,0 +1 @@
uid://b02hgywj3kck

View File

@@ -0,0 +1,116 @@
using Godot;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
public partial class CameraMovement : Camera2D
{
// Node Refrence
Node2D Target;
Node2D Player;
// Player Info
Vector2 PreviousPlayerPosition;
// Camera Properties
float CameraVerticalOffset = -20;
float CameraHorizontalOffset = 20;
float CameraMovementSpeed = 4;
// Tweening
float CameraTweenRate;
float MaxCameraTweenRate = 150f;
float MinCameraTweenRate = 0.5f;
//float MaxCameraDistance = 15f;
// Mode
public string CameraMode; // "FOLLOW" (Follows player), "FIXED" (Stay at fixed position)
public Vector2 FixedPosition;
public override void _Ready()
{
// Find Nodes
Target = this.GetParent().GetNode<Node2D>("CameraTarget");
// Set initial camera position
CameraMode = (string)GetParent().GetMeta("CameraMode");
Position = Target.Position;
FixedPosition = new Vector2(0,0);
PreviousPlayerPosition = new Vector2(0,0);
}
public override void _Process(double delta)
{
// Update Mode
CameraMode = (string)GetParent().GetMeta("CameraMode");
// Change Target position depending on current mode
switch (CameraMode)
{
case "FOLLOW":
// Set the player variable if it equals null
var RootChildren = GetTree().Root.GetChildren();
if (Player == null)
{
if (RootChildren[2].HasNode("Player"))
Player = RootChildren[2].GetNode<Node2D>("Player");
}
else // If player exists
{
// Calculate the player's change in position
float DeltaPosition = Player.Position[0] - PreviousPlayerPosition.X;
// Place target in the direction the player is moving for enhanced visibility
if (DeltaPosition > 0) // Right side of player
{
Target.Position = new Vector2(Player.Position[0] + CameraHorizontalOffset, Player.Position[1] + CameraVerticalOffset);
}
if (DeltaPosition < 0) // Left side of player
{
Target.Position = new Vector2(Player.Position[0] - CameraHorizontalOffset, Player.Position[1] + CameraVerticalOffset);
}
if (DeltaPosition == 0) // Center on player when not moving
{
Target.Position = new Vector2(Player.Position[0], Player.Position[1] + CameraVerticalOffset);
}
PreviousPlayerPosition = Player.Position;
}
break;
case "FIXED":
// Change position of Camera Target if it is not at the desired fixed position
if (Target.Position != FixedPosition)
{
Target.Position = FixedPosition;
}
Player = null;
break;
default: // Does nothing just required
break;
}
// Tween camera to Camera Target's position
CameraTweenRate = (float)Math.Pow(Position.DistanceTo(Target.Position), 2) / 10f;
// Ensure the Tween Rate stays between the Max and Min values
if (CameraTweenRate > MaxCameraTweenRate)
{
CameraTweenRate = MaxCameraTweenRate;
}
if (CameraTweenRate < MinCameraTweenRate)
{
CameraTweenRate = MinCameraTweenRate;
}
// Move Camera
Vector2 MovementDirection = (Target.Position - Position).Normalized();
Position += MovementDirection * CameraMovementSpeed * CameraTweenRate * (float)delta;
}
public void TeleportCamera(Vector2 TargetPosition)
{
GetParent().GetNode<Node2D>("CameraTarget").Position = TargetPosition;
Position = TargetPosition;
FixedPosition = TargetPosition;
}
}

View File

@@ -0,0 +1 @@
uid://co5myvo1u4qn7

View File

@@ -3,7 +3,7 @@ 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."
// arg contains the speaker and the sentance for example "Sign|This is a test."
public partial class Dialogue : Node2D
{

View File

@@ -0,0 +1 @@
uid://b7a4ty2lbfxan

View File

@@ -0,0 +1,35 @@
using Godot;
using System;
public partial class LevelDialogueInitiator : Node2D
{
string[] Dialogue; // Each element in the array is the name of the speaker and the dialogue seperated by a | (ex "Sign|This is a test message.")
float MaxInteractDistance = 30;
public override void _Ready()
{
// Get dialogue from the metadata
Dialogue = (string[])GetMeta("Dialogue");
}
public override void _Process(double delta)
{
if (GetParent().GetParent().HasNode("Player"))
{
if (Position.DistanceTo(GetParent().GetParent().GetNode<Node2D>("Player").Position) <= MaxInteractDistance)
GetNode<AnimatedSprite2D>("InteractionIndicator").Visible = true;
else
GetNode<AnimatedSprite2D>("InteractionIndicator").Visible = false;
}
if (Input.IsActionJustPressed("interact") && GetTree().Root.GetNode("Camera").GetNode("Camera2D").HasNode("Dialogue") == false && Position.DistanceTo(GetParent().GetParent().GetNode<Node2D>("Player").Position) <= MaxInteractDistance)
{
// Instantiate scene
var scene = GD.Load<PackedScene>($"res://Assets/Scenes/Dialogue.tscn");
var inst = scene.Instantiate();
GetTree().Root.GetNode("Camera").GetNode("Camera2D").AddChild(inst);
// Send Data
GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode<Dialogue>("Dialogue").SetupDialogue(Dialogue);
}
}
}

View File

@@ -0,0 +1 @@
uid://cl8sq2b2lp4a5

View File

@@ -1,8 +1,6 @@
using Godot;
using System;
// Designed by Jojackman1
public partial class LevelManager : Node
{
Node2D StartNode;
@@ -12,6 +10,8 @@ public partial class LevelManager : Node
public override void _Ready()
{
GetTree().Root.GetNode<CommonData>("CommonData").CurrentHealth = GetTree().Root.GetNode<CommonData>("CommonData").MaxHealth;
StartNode = GetParent().GetNode<Node2D>("StartNode");
EndNode = GetParent().GetNode<Node2D>("EndNode");
Player = GetParent().GetNode<Node2D>("Player");
@@ -30,7 +30,7 @@ public partial class LevelManager : Node
if (EndType == "nothing")
{
// Death
if ()
if (GetTree().Root.GetNode<CommonData>("CommonData").CurrentHealth <= 0)
{
EndManager("Death");
EndType = "Death";
@@ -48,9 +48,25 @@ public partial class LevelManager : Node
{
switch (EndType)
{
case "Death": // Player Dies
case "Death": // Player Died
//Player.QueueFree();
// Go back to main menu (Replace with proper ending screen and then send back to main menu)
GetNode<ChangeMenuInitiator>("ChangeMenuInitiator").ChangeMenu("FAST", "MainMenu", GetParent());
break;
case "Success": // Successfully make it to the end of the levels
case "Success": // Success
// Remove the player to stop checking
//Player.QueueFree();
// Add level completed to the hash set
GetTree().Root.GetNode<CommonData>("CommonData").LevelsCompleted.Add(GetParent().Name);
// Play exit animation
GetParent().GetNode("ScreenAnimations").GetNode("LevelCompleteAssets").GetNode<AnimationPlayer>("LevelComplete").CurrentAnimation = "default";
GetParent().GetNode("ScreenAnimations").GetNode<Node2D>("LevelCompleteAssets").Reparent(GetTree().Root.GetNode("Camera").GetNode("Camera2D"));
GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode<Node2D>("LevelCompleteAssets").GlobalPosition = GetTree().Root.GetNode("Camera").GetNode<Node2D>("Camera2D").GlobalPosition;
GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode<Node2D>("LevelCompleteAssets").Visible = true;
// Go to exit cutscene after exit animation is complete
var LevelName = (string)GetParent().Name;
var LevelNumber = LevelName.Split("Level");
GetNode<ChangeMenuInitiator>("ChangeMenuInitiator").ChangeMenu("SLOW", $"Cutscenes/ExitCutscene{LevelNumber[0]}", GetParent());
break;
default:
break;

View File

@@ -0,0 +1 @@
uid://i8yvg41jip3n

View File

@@ -0,0 +1,87 @@
using Godot;
using System;
using System.Linq;
public partial class PlayerMover : CharacterBody2D
{
// Movement Variables
public float Speed = 80.0f;
public float JumpVelocity = -250.0f;
// Animation Refrences
AnimatedSprite2D WalkingAnimation;
public override void _Ready()
{
// Object refrences
WalkingAnimation = GetNode<AnimatedSprite2D>("WalkingAnimation");
// Entering/Exiting various area 2D's
GetNode<Area2D>("AreaDetector").AreaEntered += AreaEnteredHandler;
GetNode<Area2D>("AreaDetector").AreaExited += AreaExitedHandler;
// Change camera
GetTree().Root.GetNode("Camera").SetMeta("CameraMode", "FOLLOW");
}
public override void _PhysicsProcess(double delta)
{
Vector2 velocity = Velocity;
// Add gravity.
if (!IsOnFloor())
{
velocity += GetGravity() * (float)delta * 0.8f;
}
// Handle Jump.
if (Input.IsActionJustPressed("jump") && IsOnFloor())
{
velocity.Y = JumpVelocity;
}
// Get the input direction and set velocity
if (Input.IsActionPressed("move_left")) // move left
{
velocity.X = -Speed;
WalkingAnimation.FlipH = true;
if (WalkingAnimation.IsPlaying() == false) // Play Animation
WalkingAnimation.Play();
}
else if (Input.IsActionPressed("move_right")) // move right
{
velocity.X = Speed;
WalkingAnimation.FlipH = false;
if (WalkingAnimation.IsPlaying() == false) // Play Animation
WalkingAnimation.Play();
}
else
{
velocity.X = 0;
WalkingAnimation.Stop();
}
Velocity = velocity;
MoveAndSlide();
}
void AreaEnteredHandler(Area2D arg)
{
string name = arg.Name;
if (name.Contains("SlowField"))
{
Speed = 20.0f;
JumpVelocity = -180.0f;
}
}
void AreaExitedHandler(Area2D arg)
{
string name = arg.Name;
if (name.Contains("SlowField"))
{
Speed = 80.0f;
JumpVelocity = -250.0f;
}
}
}

View File

@@ -0,0 +1 @@
uid://batcpr6rxhyb2