diff --git a/Assets/Scenes/MenusAndLevels/EnemyTestLevel.tscn b/Assets/Scenes/MenusAndLevels/EnemyTestLevel.tscn new file mode 100644 index 0000000..aaade4e --- /dev/null +++ b/Assets/Scenes/MenusAndLevels/EnemyTestLevel.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://bbngncnb2xeov"] + +[node name="EnemyTestLevel" type="Node2D"] diff --git a/Assets/Scenes/MenusAndLevels/MainMenu.tscn b/Assets/Scenes/MenusAndLevels/MainMenu.tscn new file mode 100644 index 0000000..de73350 --- /dev/null +++ b/Assets/Scenes/MenusAndLevels/MainMenu.tscn @@ -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 diff --git a/Assets/Scenes/Persistant/Camera.tscn b/Assets/Scenes/Persistant/Camera.tscn new file mode 100644 index 0000000..9ea4cc0 --- /dev/null +++ b/Assets/Scenes/Persistant/Camera.tscn @@ -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="."] diff --git a/Assets/Scripts/CommonScripts/CommonData.cs b/Assets/Scripts/CommonScripts/CommonData.cs new file mode 100644 index 0000000..b97bcda --- /dev/null +++ b/Assets/Scripts/CommonScripts/CommonData.cs @@ -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 LevelsCompleted = new HashSet(); + + public override void _Ready() + { + // Connect to the audio player + GetNode("AudioStreamPlayer").Finished += LoopAudio; + GetNode("AudioStreamPlayer").VolumeDb = -80; // temporary + + // Start game by loading the camera + var scene = GD.Load("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("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").VolumeDb = 0; + } + else + { + Muted = true; + GetNode("AudioStreamPlayer").VolumeDb = -80; + } + } + } + + // BG Audio Management + public void StopMusic() + { + // Stop whatever audio is playing + GetNode("AudioStreamPlayer").Stop(); + } + public void PlayMusic(string AudioName) + { + // Load target audio and play the audio + GetNode("AudioStreamPlayer").Stream = (Godot.AudioStream)GD.Load($"res://Assets/Audio/Music/{AudioName}.mp3"); + GetNode("AudioStreamPlayer").Play(); + } + void LoopAudio() + { + // Find when the stream finishes playing to play it again + GetNode("AudioStreamPlayer").Play(); + } +} diff --git a/Assets/Scripts/CommonScripts/TipManager.cs b/Assets/Scripts/CommonScripts/TipManager.cs new file mode 100644 index 0000000..04dde63 --- /dev/null +++ b/Assets/Scripts/CommonScripts/TipManager.cs @@ -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]; + } +} diff --git a/Assets/Scripts/CommonScripts/UI.cs b/Assets/Scripts/CommonScripts/UI.cs new file mode 100644 index 0000000..7cc7641 --- /dev/null +++ b/Assets/Scripts/CommonScripts/UI.cs @@ -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("Camera2D").GlobalPosition; + } +} diff --git a/Assets/Scripts/LevelScripts/ChangeMenuInitiator.cs b/Assets/Scripts/LevelScripts/ChangeMenuInitiator.cs new file mode 100644 index 0000000..ed3689a --- /dev/null +++ b/Assets/Scripts/LevelScripts/ChangeMenuInitiator.cs @@ -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("res://Assets/Scenes/MenusAndLevels/MenuChangeManager.tscn"); + var inst = (Node2D)scene.Instantiate(); + GetTree().Root.GetNode("Camera").AddChild(inst); + + inst.Position = GetTree().Root.GetNode("Camera").GetNode("Camera2D").Position; + + // Pass args to menu change manager + inst.GetNode("MenuChangeManager").TargetMenu = destination; + inst.GetNode("MenuChangeManager").TransitionDelay = TransitionDelay; + + // Wait for intro animation to finish before freeing the scene + inst.GetNode("AnimationPlayer").AnimationFinished += DeleteMenu; + } + if (type == "FAST") + { + var scene = GD.Load($"res://Assets/Scenes/MenusAndLevels/{destination}.tscn"); + var inst = (Node2D)scene.Instantiate(); + GetTree().Root.AddChild(inst); + + //reset camera + GetTree().Root.GetNode("Camera").GetNode("Camera2D").TeleportCamera(Vector2.Zero); + GetTree().Root.GetNode("Camera").GetNode("Camera2D").FixedPosition = GetTree().Root.GetNode("Camera").GetNode("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(); + } + } + +} diff --git a/Assets/Scripts/LevelScripts/Dialogue.cs b/Assets/Scripts/LevelScripts/Dialogue.cs new file mode 100644 index 0000000..b34cd01 --- /dev/null +++ b/Assets/Scripts/LevelScripts/Dialogue.cs @@ -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 Data = new Queue(); + + 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("Dialogue").VisibleCharacters += 1; + } + } + + public void SetupDialogue(string[] arg) + { + GetNode("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("Icon").Texture = (Godot.Texture2D)GD.Load($"res://Assets/Sprites/DialogueIcons/{SpeakerImage}.png"); + GetNode("SpeakerName").Text = SpeakerName; + GetNode("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("Dialogue").GetTotalCharacterCount() > GetNode("Dialogue").VisibleCharacters) + { + GetNode("Dialogue").VisibleCharacters = GetNode("Dialogue").GetTotalCharacterCount(); + } + else + { + if (Data.Count > 0) + { + GetNode("Dialogue").VisibleCharacters = 0; + // Get data + string[] OperatingData = Data.Dequeue().Split("|"); + SpeakerName = OperatingData[0]; + SpeakerImage = OperatingData[1]; + Sentance = OperatingData[2]; + //Display data + GetNode("Icon").Texture = (Godot.Texture2D)GD.Load($"res://Assets/Sprites/DialogueIcons/{SpeakerImage}.png"); + GetNode("SpeakerName").Text = SpeakerName; + GetNode("Dialogue").Text = Sentance; + } + else // If there is nothing left delete the scene + { + QueueFree(); + } + } + } +} diff --git a/Assets/Scripts/LevelScripts/LevelManager.cs b/Assets/Scripts/LevelScripts/LevelManager.cs new file mode 100644 index 0000000..069f36f --- /dev/null +++ b/Assets/Scripts/LevelScripts/LevelManager.cs @@ -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("StartNode"); + EndNode = GetParent().GetNode("EndNode"); + Player = GetParent().GetNode("Player"); + + // Play into animation + GetParent().GetNode("ScreenAnimations").GetNode("LevelStartAssets").GetNode("LevelStart").CurrentAnimation = "default"; + GetParent().GetNode("ScreenAnimations").GetNode("LevelStartAssets").Reparent(GetTree().Root.GetNode("Camera").GetNode("Camera2D")); + GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode("LevelStartAssets").GlobalPosition = GetTree().Root.GetNode("Camera").GetNode("Camera2D").GlobalPosition; + GetTree().Root.GetNode("Camera").GetNode("Camera2D").GetNode("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; + } + } +} diff --git a/project.godot b/project.godot index e614ab6..ec889f2 100644 --- a/project.godot +++ b/project.godot @@ -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"