From 258b6c7856331a3bd667b9a7be752df91d06497d Mon Sep 17 00:00:00 2001 From: Layla Manley Date: Sun, 28 Jan 2024 15:05:54 +0100 Subject: [PATCH] Unbork some very borked stuff --- nodes/Victory.tscn | 42 ++++++++++++++++++++--------------------- nodes/exit.tscn | 47 +++++++++++++++++++++++++++++----------------- scripts/Console.gd | 26 ++++++++++++------------- scripts/Exit.gd | 19 ++++++++++++++----- 4 files changed, 78 insertions(+), 56 deletions(-) diff --git a/nodes/Victory.tscn b/nodes/Victory.tscn index ac775e9..1513736 100644 --- a/nodes/Victory.tscn +++ b/nodes/Victory.tscn @@ -1,14 +1,9 @@ -[gd_scene load_steps=6 format=3] +[gd_scene load_steps=4 format=3 uid="uid://dnicfvo878on7"] -[ext_resource type="Theme" uid="uid://cxgvk5h68qluc" path="res://general_theme.tres" id="1"] -[ext_resource type="FontFile" uid="uid://5pudbq7h6eh7" path="res://assets/fonts/pixelmix/pixelmix_bold.ttf" id="2"] +[ext_resource type="Theme" uid="uid://x4at2pluavto" path="res://general_theme.tres" id="1"] [ext_resource type="Script" path="res://scripts/Console.gd" id="3"] -[sub_resource type="FontFile" id=1] -size = 48 -font_data = ExtResource( 2 ) - -[sub_resource type="GDScript" id=2] +[sub_resource type="GDScript" id="2"] script/source = "extends ColorRect # Declare member variables here. Examples: @@ -55,42 +50,47 @@ func fade_out(): fade_timer.queue_free()" [node name="Control" type="Control"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 1 ) +theme = ExtResource("1") [node name="CanvasLayer" type="CanvasLayer" parent="."] [node name="Control" type="Control" parent="CanvasLayer"] +layout_mode = 3 +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 -theme = ExtResource( 1 ) +theme = ExtResource("1") [node name="Level Complete" type="Label" parent="CanvasLayer/Control"] +layout_mode = 0 offset_left = 20.0 offset_top = 15.0 offset_right = 691.0 offset_bottom = 88.0 -custom_fonts/font = SubResource( 1 ) -custom_colors/font_color = Color( 0.6, 0.898039, 0.313726, 1 ) text = "LEVEL COMPLETE!" [node name="Console" type="Control" parent="CanvasLayer/Control"] +anchors_preset = 0 anchor_right = 1.0 anchor_bottom = 1.0 -script = ExtResource( 3 ) +script = ExtResource("3") [node name="Display" type="Label" parent="CanvasLayer/Control/Console"] +layout_mode = 0 offset_left = 20.0 offset_top = 70.0 offset_right = 550.0 offset_bottom = 480.0 -custom_colors/font_color = Color( 0.6, 0.898039, 0.313726, 1 ) text = "Running debugger... Debugging complete!" [node name="Buttons" type="HBoxContainer" parent="CanvasLayer/Control/Console"] +layout_mode = 0 offset_left = 20.0 offset_top = 480.0 offset_right = 550.0 @@ -100,23 +100,23 @@ grow_vertical = 2 alignment = 1 [node name="Button2" type="Button" parent="CanvasLayer/Control/Console/Buttons"] -offset_left = 241.0 -offset_right = 289.0 -offset_bottom = 40.0 +layout_mode = 2 text = "Test" [node name="ColorRect" type="ColorRect" parent="CanvasLayer/Control/Console"] +layout_mode = 0 offset_left = 20.0 offset_top = 475.0 offset_right = 550.0 offset_bottom = 485.0 -scale = Vector2( 1, 0.5 ) -color = Color( 0.6, 0.898039, 0.313726, 1 ) +scale = Vector2(1, 0.5) +color = Color(0.6, 0.898039, 0.313726, 1) [node name="FadeRect" type="ColorRect" parent="CanvasLayer"] visible = false +anchors_preset = 15 anchor_right = 1.0 anchor_bottom = 1.0 mouse_filter = 2 -color = Color( 0, 0, 0, 1 ) -script = SubResource( 2 ) +color = Color(0, 0, 0, 1) +script = SubResource("2") diff --git a/nodes/exit.tscn b/nodes/exit.tscn index de5d5e2..6467521 100644 --- a/nodes/exit.tscn +++ b/nodes/exit.tscn @@ -1,39 +1,52 @@ -[gd_scene load_steps=9 format=3] +[gd_scene load_steps=10 format=3 uid="uid://cahrkuao8ip70"] [ext_resource type="Script" path="res://scripts/Exit.gd" id="1"] [ext_resource type="Texture2D" uid="uid://mn17ql7wilx3" path="res://assets/art/Exit/Exit1.png" id="2"] +[ext_resource type="PackedScene" uid="uid://dnicfvo878on7" path="res://nodes/Victory.tscn" id="2_i8a2h"] [ext_resource type="Texture2D" uid="uid://ca3q21m0btdrl" path="res://assets/art/Exit/Exit2.png" id="3"] [ext_resource type="Texture2D" uid="uid://cbft4yscrmjw5" path="res://assets/art/Exit/Exit3.png" id="4"] [ext_resource type="Texture2D" uid="uid://8nubee34g3bl" path="res://assets/art/Exit/Exit4.png" id="5"] [ext_resource type="Texture2D" uid="uid://df3auvg5myvws" path="res://assets/art/light.png" id="6"] -[sub_resource type="SpriteFrames" id=1] -animations = [ { -"frames": [ ExtResource( 2 ), ExtResource( 3 ), ExtResource( 4 ), ExtResource( 5 ) ], +[sub_resource type="SpriteFrames" id="1"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("2") +}, { +"duration": 1.0, +"texture": ExtResource("3") +}, { +"duration": 1.0, +"texture": ExtResource("4") +}, { +"duration": 1.0, +"texture": ExtResource("5") +}], "loop": true, -"name": "default", +"name": &"default", "speed": 12.0 -} ] +}] -[sub_resource type="RectangleShape2D" id=2] -extents = Vector2( 7.00912, 7.45768 ) +[sub_resource type="RectangleShape2D" id="2"] +size = Vector2(14.0182, 14.9154) -[node name="Exit" type="Node2D"] -script = ExtResource( 1 ) +[node name="Exit" type="Node2D" node_paths=PackedStringArray("area")] +script = ExtResource("1") +area = NodePath("Area2D") +victory_scene = ExtResource("2_i8a2h") [node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] z_index = -1 -frames = SubResource( 1 ) +sprite_frames = SubResource("1") frame = 2 -playing = true [node name="Area2D" type="Area2D" parent="."] -editor/display_folded = true [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -position = Vector2( 0, 0.5 ) -shape = SubResource( 2 ) +position = Vector2(0, 0.5) +shape = SubResource("2") [node name="PointLight2D" type="PointLight2D" parent="."] -texture = ExtResource( 6 ) -color = Color( 0.486275, 1, 0.25098, 1 ) +color = Color(0.486275, 1, 0.25098, 1) +texture = ExtResource("6") diff --git a/scripts/Console.gd b/scripts/Console.gd index 447493e..9cef3ba 100644 --- a/scripts/Console.gd +++ b/scripts/Console.gd @@ -36,7 +36,7 @@ func _ready(): actionTimer = Timer.new() actionTimer.connect("timeout",Callable(self,"RunQueuedAction")) add_child(actionTimer) - $Display.text = $Display.text + "\nGood job Unit " + String(SaveManager.get_run()) + "!" + $Display.text = $Display.text + "\nGood job Unit " + str(SaveManager.get_run()) + "!" addLine("\nAwaiting input...") changeChar = CHANGE_TIME $Display.visible_characters = 18 @@ -63,11 +63,11 @@ func ButtonInput(input): if !queuedAction: queuedAction = input elif input == "Next Level": - addLine("gis run unit " + String(SaveManager.get_run())) + addLine("gis run unit " + str(SaveManager.get_run())) if !queuedAction: queuedAction = input elif input == "Upgrades": - addLine("gis config unit " + String(SaveManager.get_run())) + addLine("gis config unit " + str(SaveManager.get_run())) if !queuedAction: queuedAction = input elif input == "Back": @@ -123,7 +123,7 @@ func RunQueuedAction(): get_tree().change_scene_to_file("res://Nodes/Game.tscn") elif queuedAction == "Upgrades": clearConsole() - addLine("Upgrade Chips: " + String(SaveManager.get_upgrade_points()) + "\n\n") + addLine("Upgrade Chips: " + str(SaveManager.get_upgrade_points()) + "\n\n") addLine("Select upgrade category:") addLine("1. Abilities") addLine("2. Equipment") @@ -132,14 +132,14 @@ func RunQueuedAction(): GenerateInputs(['Abilities', 'Equipment', 'Buy Equipment', 'Back']) elif queuedAction == "Buy Equipment": clearConsole() - addLine("Upgrade Chips: " + String(SaveManager.get_upgrade_points()) + "\n\n") + addLine("Upgrade Chips: " + str(SaveManager.get_upgrade_points()) + "\n\n") addLine("Equipment:") var i = 1 var tempInputs = [] for equipment in ALL_EQUIPMENT: if !(equipment in SaveManager.get_equipment()): tempInputs.append(capFirst(equipment)) - addLine(String(i) + ". " + capFirst(equipment) + " (COST " + String(ALL_EQUIPMENT[equipment]) + ")") + addLine(str(i) + ". " + capFirst(equipment) + " (COST " + str(ALL_EQUIPMENT[equipment]) + ")") i += 1 GenerateInputs(tempInputs + ['Upgrades']) elif queuedAction == "Back": @@ -147,7 +147,7 @@ func RunQueuedAction(): clearConsole() elif queuedAction == "Equipment": clearConsole() - addLine("Upgrade Chips: " + String(SaveManager.get_upgrade_points()) + "\n\n") + addLine("Upgrade Chips: " + str(SaveManager.get_upgrade_points()) + "\n\n") addLine("Equipment:") var i = 1 var tempInputs = [] @@ -155,7 +155,7 @@ func RunQueuedAction(): var suffix = "" if equip == SaveManager.get_equiped(): suffix = " (EQUIPED)" - addLine(String(i) + ". " + equip.capitalize()[0] + equip.substr(1, len(equip)) + suffix) + addLine(str(i) + ". " + equip.capitalize()[0] + equip.substr(1, len(equip)) + suffix) tempInputs.append(equip.capitalize()[0] + equip.substr(1, len(equip))) i += 1 addLine('\nX. Back') @@ -163,12 +163,12 @@ func RunQueuedAction(): GenerateInputs(tempInputs + ["Upgrades"]) elif queuedAction == "Abilities": clearConsole() - addLine("Upgrade Chips: " + String(SaveManager.get_upgrade_points()) + "\n\n") + addLine("Upgrade Chips: " + str(SaveManager.get_upgrade_points()) + "\n\n") addLine("Abilities:") var i = 1 var tempInputs = [] for action in SaveManager.get_actions(): - addLine(String(i) + ". " + action.capitalize()[0] + action.substr(1, len(action))) + addLine(str(i) + ". " + action.capitalize()[0] + action.substr(1, len(action))) tempInputs.append(action.capitalize()[0] + action.substr(1, len(action))) i += 1 addLine('\nX. Back') @@ -190,16 +190,16 @@ func RunQueuedAction(): GenerateInputs(tempInputs + ["Equipment"]) elif queuedAction.to_lower() in SaveManager.get_actions(): clearConsole() - addLine("Upgrade Chips: " + String(SaveManager.get_upgrade_points()) + "\n\n") + addLine("Upgrade Chips: " + str(SaveManager.get_upgrade_points()) + "\n\n") addLine("Ability: " + queuedAction) - addLine("Level: " + String(SaveManager.get_action_value(queuedAction.to_lower()))) + addLine("Level: " + str(SaveManager.get_action_value(queuedAction.to_lower()))) addLine("") var pointsToUpgrade = 1 * int(SaveManager.get_action_value(queuedAction.to_lower())) if queuedAction.to_lower() in BASE_UNLOCK: pointsToUpgrade += BASE_UNLOCK[queuedAction.to_lower()] var tempInputs = [] tempInputs.append("Upgrade") - addLine("1. Upgrade (" + String(pointsToUpgrade) + " Points)") + addLine("1. Upgrade (" + str(pointsToUpgrade) + " Points)") addLine("\nX. Back") tempValue = queuedAction.to_lower() GenerateInputs(tempInputs + ["Abilities"]) diff --git a/scripts/Exit.gd b/scripts/Exit.gd index 810c7a7..9c8aea3 100644 --- a/scripts/Exit.gd +++ b/scripts/Exit.gd @@ -1,14 +1,23 @@ +class_name Exit extends Node2D +@export +var area: Area2D -func _ready(): +@export +var victory_scene: PackedScene + +func _ready() -> void: + area.body_entered.connect(self._on_body_entered) $Area2D.connect("body_entered",Callable(self,"on_collide")) - -func on_collide(body): - if body.has_method("victoryCondition"): +func _on_body_entered(body: PhysicsBody2D) -> void: + if body is Player: MusicPlayer.stop() MusicPlayer.stream = load("res://Music/DOS-88/Smooth Sailing.ogg") MusicPlayer.volume_db = 0 MusicPlayer.play() - body.victoryCondition() + SaveManager.change_upgrade_points(1) + get_tree().change_scene_to_packed(victory_scene) + +