pruned scripts
This commit is contained in:
59
Assets/Scripts/LevelScripts/LevelManager.cs
Normal file
59
Assets/Scripts/LevelScripts/LevelManager.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user