From 68271c94edd638de873b3834366b7f74246cf9b3 Mon Sep 17 00:00:00 2001 From: Ivan Kuzmenko <6745157+rndtrash@users.noreply.github.com> Date: Sat, 19 Aug 2023 15:23:08 +0300 Subject: [PATCH] Last stretch --- prefabs/entities/Teleport.tscn | 16 +++ prefabs/entities/teleport_dest.tscn | 3 + prefabs/furniture/door_closed.tscn | 40 ++++++- scenes/level.tscn | 102 +++++++++++++++- scenes/main_scene.tscn | 159 ++++++++++++------------- scenes/menu.tscn | 15 +++ scripts/GameManager.cs | 2 + scripts/WinScreen.cs | 28 +++++ scripts/enemies/Claw.cs | 21 +++- scripts/entities/Door.cs | 27 +++++ scripts/entities/Teleport.cs | 20 ++++ sprites/enemies/wretched/wretched.tres | 2 +- sprites/tiles/QoL.tres | 2 +- 13 files changed, 338 insertions(+), 99 deletions(-) create mode 100644 prefabs/entities/Teleport.tscn create mode 100644 prefabs/entities/teleport_dest.tscn create mode 100644 scripts/WinScreen.cs create mode 100644 scripts/entities/Door.cs create mode 100644 scripts/entities/Teleport.cs diff --git a/prefabs/entities/Teleport.tscn b/prefabs/entities/Teleport.tscn new file mode 100644 index 0000000..6cde8b1 --- /dev/null +++ b/prefabs/entities/Teleport.tscn @@ -0,0 +1,16 @@ +[gd_scene load_steps=3 format=3 uid="uid://crulyoxqqw74r"] + +[ext_resource type="Script" path="res://scripts/entities/Teleport.cs" id="1_luklc"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_ogixu"] + +[node name="Teleport" type="Area2D"] +collision_layer = 4 +collision_mask = 4 +monitorable = false +script = ExtResource("1_luklc") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_ogixu") + +[connection signal="body_entered" from="." to="." method="OnPlayerEntered"] diff --git a/prefabs/entities/teleport_dest.tscn b/prefabs/entities/teleport_dest.tscn new file mode 100644 index 0000000..e2149df --- /dev/null +++ b/prefabs/entities/teleport_dest.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://dteeck6gict0d"] + +[node name="teleport_dest" type="Node2D"] diff --git a/prefabs/furniture/door_closed.tscn b/prefabs/furniture/door_closed.tscn index 24e92a0..ba5c537 100644 --- a/prefabs/furniture/door_closed.tscn +++ b/prefabs/furniture/door_closed.tscn @@ -1,8 +1,40 @@ -[gd_scene load_steps=2 format=3 uid="uid://chhytv8se7mfk"] +[gd_scene load_steps=6 format=3 uid="uid://chhytv8se7mfk"] +[ext_resource type="Script" path="res://scripts/entities/Door.cs" id="1_ckaca"] [ext_resource type="Texture2D" uid="uid://cn362llclhulw" path="res://sprites/furniture/door-closed.png" id="1_lnba4"] +[ext_resource type="Texture2D" uid="uid://ccv54fdk8unka" path="res://sprites/furniture/door-open.png" id="3_ornej"] -[node name="door_closed" type="Node2D"] +[sub_resource type="SpriteFrames" id="SpriteFrames_v2loo"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": ExtResource("1_lnba4") +}], +"loop": true, +"name": &"closed", +"speed": 1.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": ExtResource("3_ornej") +}], +"loop": true, +"name": &"open", +"speed": 1.0 +}] -[node name="Sprite2D" type="Sprite2D" parent="."] -texture = ExtResource("1_lnba4") +[sub_resource type="RectangleShape2D" id="RectangleShape2D_srxyv"] +size = Vector2(32, 60) + +[node name="DoorClosed" type="Node2D"] +script = ExtResource("1_ckaca") + +[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."] +sprite_frames = SubResource("SpriteFrames_v2loo") +animation = &"closed" + +[node name="StaticBody2D" type="StaticBody2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"] +position = Vector2(0, 6) +shape = SubResource("RectangleShape2D_srxyv") diff --git a/scenes/level.tscn b/scenes/level.tscn index 9905826..69f55bd 100644 --- a/scenes/level.tscn +++ b/scenes/level.tscn @@ -1,6 +1,6 @@ -[gd_scene load_steps=17 format=3 uid="uid://cn0rwyjern2vx"] +[gd_scene load_steps=21 format=3 uid="uid://cn0rwyjern2vx"] -[ext_resource type="TileSet" uid="uid://b4dpeakjmn31p" path="res://sprites/tiles/QoL.tres" id="1_kp7y7"] +[ext_resource type="TileSet" uid="uid://c7x8hryljgpha" path="res://sprites/tiles/QoL.tres" id="1_kp7y7"] [ext_resource type="PackedScene" uid="uid://b2nngdg27wccf" path="res://prefabs/furniture/bed.tscn" id="2_7ee73"] [ext_resource type="PackedScene" uid="uid://chd3lj3gisjgj" path="res://prefabs/furniture/window.tscn" id="3_1vbfb"] [ext_resource type="PackedScene" uid="uid://dcol2k6su0v4" path="res://prefabs/furniture/komod.tscn" id="4_5646q"] @@ -13,8 +13,12 @@ [ext_resource type="PackedScene" uid="uid://bo5we64scaa1x" path="res://prefabs/furniture/table2.tscn" id="11_43o4k"] [ext_resource type="PackedScene" uid="uid://cvfk53tse4okx" path="res://prefabs/furniture/book.tscn" id="12_7tfnm"] [ext_resource type="PackedScene" uid="uid://ccg3n7sobsvdw" path="res://prefabs/enemies/watcher.tscn" id="13_nbkmp"] -[ext_resource type="PackedScene" uid="uid://bpusphyhhg074" path="res://prefabs/enemies/living_armor.tscn" id="14_4tmmq"] -[ext_resource type="PackedScene" uid="uid://bmyjqerhno5vi" path="res://prefabs/enemies/wretched.tscn" id="15_3rigu"] +[ext_resource type="PackedScene" path="res://prefabs/enemies/living_armor.tscn" id="14_4tmmq"] +[ext_resource type="PackedScene" path="res://prefabs/enemies/wretched.tscn" id="15_3rigu"] +[ext_resource type="PackedScene" uid="uid://crulyoxqqw74r" path="res://prefabs/entities/Teleport.tscn" id="16_c6ifr"] +[ext_resource type="PackedScene" uid="uid://dteeck6gict0d" path="res://prefabs/entities/teleport_dest.tscn" id="17_0di6y"] +[ext_resource type="PackedScene" uid="uid://cpi5lgdlnvhlg" path="res://prefabs/enemies/boss/boss.tscn" id="18_8j1w1"] +[ext_resource type="PackedScene" uid="uid://bihh0dp1vbqfu" path="res://prefabs/enemies/boss/claw.tscn" id="19_q14f4"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_ul7os"] light_mode = 2 @@ -71,10 +75,10 @@ position = Vector2(672, 328) [node name="skull" parent="." instance=ExtResource("8_sfpxp")] position = Vector2(2033, -496) -[node name="door_closed4" parent="." instance=ExtResource("7_kt8g1")] +[node name="door_closed_puzzle_1" parent="." instance=ExtResource("7_kt8g1")] position = Vector2(747, -120) -[node name="pressure_plate" parent="." instance=ExtResource("9_6ydrq")] +[node name="pressure_plate_puzzle_1" parent="." instance=ExtResource("9_6ydrq")] position = Vector2(750, 16) [node name="pressure_plate2" parent="." instance=ExtResource("9_6ydrq")] @@ -334,3 +338,89 @@ position = Vector2(329, -1044) [node name="Wretched9" parent="." instance=ExtResource("15_3rigu")] position = Vector2(-109, -974) + +[node name="Teleport" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(112, 259) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport" instance=ExtResource("17_0di6y")] +position = Vector2(-31, 174) + +[node name="Teleport2" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(503, 465) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport2" instance=ExtResource("17_0di6y")] +position = Vector2(126, -1) + +[node name="Teleport3" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(884, 465) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport3" instance=ExtResource("17_0di6y")] +position = Vector2(154, -66) + +[node name="Teleport4" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(2064, -497) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport4" instance=ExtResource("17_0di6y")] +position = Vector2(-1313, 611) + +[node name="Teleport_puzzle_1" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(748, -96) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport_puzzle_1" instance=ExtResource("17_0di6y")] +position = Vector2(1, -212) + +[node name="Teleport_puzzle_2" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(744, -514) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport_puzzle_2" instance=ExtResource("17_0di6y")] +position = Vector2(1, -212) + +[node name="Teleport_puzzle_3" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(752, -930) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport_puzzle_3" instance=ExtResource("17_0di6y")] +position = Vector2(-448, 747) + +[node name="Teleport_puzzle_4" parent="." node_paths=PackedStringArray("To") instance=ExtResource("16_c6ifr")] +position = Vector2(481, -1273) +To = NodePath("teleport_dest") + +[node name="teleport_dest" parent="Teleport_puzzle_4" instance=ExtResource("17_0di6y")] +position = Vector2(173, 2391) + +[node name="boss" parent="." instance=ExtResource("18_8j1w1")] +position = Vector2(655, 942) + +[node name="claw" parent="." instance=ExtResource("19_q14f4")] +position = Vector2(589, 1035) + +[node name="claw2" parent="." instance=ExtResource("19_q14f4")] +position = Vector2(706, 1031) + +[node name="LivingArmor9" parent="." instance=ExtResource("14_4tmmq")] +position = Vector2(485, 1107) +Facing = 1 + +[node name="LivingArmor10" parent="." instance=ExtResource("14_4tmmq")] +position = Vector2(826, 1110) +Facing = 1 + +[node name="LivingArmor11" parent="." instance=ExtResource("14_4tmmq")] +position = Vector2(824, 1042) +Facing = 0 + +[node name="LivingArmor12" parent="." instance=ExtResource("14_4tmmq")] +position = Vector2(483, 1050) +Facing = 2 + +[connection signal="ButtonPressed" from="pressure_plate_puzzle_1" to="door_closed_puzzle_1" method="Open"] +[connection signal="ButtonUnpressed" from="pressure_plate_puzzle_1" to="door_closed_puzzle_1" method="Close"] +[connection signal="TeleportTriggered" from="Teleport_puzzle_4" to="claw" method="Enable"] +[connection signal="TeleportTriggered" from="Teleport_puzzle_4" to="claw2" method="Enable"] diff --git a/scenes/main_scene.tscn b/scenes/main_scene.tscn index d39a391..412d13e 100644 --- a/scenes/main_scene.tscn +++ b/scenes/main_scene.tscn @@ -1,34 +1,28 @@ -[gd_scene load_steps=28 format=3 uid="uid://dhn7yt46fyac8"] +[gd_scene load_steps=23 format=3 uid="uid://dhn7yt46fyac8"] [ext_resource type="PackedScene" uid="uid://bhulqhxesd5gc" path="res://prefabs/player.tscn" id="1_65a7v"] [ext_resource type="AudioStream" uid="uid://bsy2d0bl3lgg0" path="res://sounds/crank.ogg" id="1_cweq4"] [ext_resource type="Script" path="res://scripts/GameManager.cs" id="1_ij566"] -[ext_resource type="Texture2D" uid="uid://py6qiu3rm7cu" path="res://sprites/brickwall.png" id="2_edqdh"] [ext_resource type="Texture2D" uid="uid://dlbl6d4yghvht" path="res://sprites/mask.png" id="3_8o315"] [ext_resource type="Script" path="res://scripts/Flashlight.cs" id="3_cylxo"] +[ext_resource type="PackedScene" uid="uid://bdtjnmjopi5h2" path="res://prefabs/play_zone.tscn" id="4_5sggf"] [ext_resource type="Material" uid="uid://xuvxq5hy1dt" path="res://shaders/light_shader_material.tres" id="4_ro05e"] [ext_resource type="Shader" path="res://shaders/dithering.gdshader" id="5_64d71"] +[ext_resource type="PackedScene" uid="uid://cn0rwyjern2vx" path="res://scenes/level.tscn" id="5_skctj"] [ext_resource type="Script" path="res://scripts/GameCamera.cs" id="6_quua3"] [ext_resource type="Script" path="res://scripts/PointLight2DWorkaround.cs" id="6_slohe"] -[ext_resource type="PackedScene" uid="uid://ccg3n7sobsvdw" path="res://prefabs/enemies/watcher.tscn" id="10_fsiss"] -[ext_resource type="PackedScene" path="res://prefabs/enemies/living_armor.tscn" id="11_x3ep3"] -[ext_resource type="PackedScene" uid="uid://bj1ixwjdpnooo" path="res://prefabs/entities/pressure_plate.tscn" id="12_ynt5e"] -[ext_resource type="PackedScene" uid="uid://dqx43vr727ft8" path="res://prefabs/entities/spikes.tscn" id="13_w1hk1"] +[ext_resource type="Script" path="res://scripts/WinScreen.cs" id="13_prax6"] +[ext_resource type="Theme" uid="uid://daxgxg7c8v0ih" path="res://themes/zx_theme.tres" id="14_g1c0r"] [ext_resource type="Script" path="res://scripts/DeathScreen.cs" id="15_12mhe"] -[ext_resource type="PackedScene" path="res://prefabs/enemies/wretched.tscn" id="16_ejflu"] -[ext_resource type="PackedScene" uid="uid://bdtjnmjopi5h2" path="res://prefabs/play_zone.tscn" id="17_mxxy2"] [sub_resource type="Curve" id="Curve_o5byr"] _data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0] point_count = 2 -[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_wg1ao"] -light_mode = 2 - [sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"] shader = ExtResource("5_64d71") -[sub_resource type="ViewportTexture" id="ViewportTexture_q4yg2"] +[sub_resource type="ViewportTexture" id="ViewportTexture_x6taj"] viewport_path = NodePath("FlashlightViewport") [sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"] @@ -49,15 +43,11 @@ gradient = SubResource("Gradient_cy0nu") width = 256 height = 192 -[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_au1d0"] -light_mode = 2 - [node name="Root" type="Node2D"] y_sort_enabled = true -[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("FirstZone", "Player")] +[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("Player")] script = ExtResource("1_ij566") -FirstZone = NodePath("../TestPlayZone") Player = NodePath("../Player") [node name="Sounds" type="Node" parent="."] @@ -79,21 +69,27 @@ FlashlightGroup = NodePath("../FlashlightViewport/CanvasGroup") BrightnessCurve = SubResource("Curve_o5byr") CrankSoundPlayer = NodePath("../Sounds/CrankSound") +[node name="Zones" type="Node" parent="."] + +[node name="PlayZone1" parent="Zones" node_paths=PackedStringArray("TopLeftCorner", "BottomRightCorner", "PlayerSpawnPoint") instance=ExtResource("4_5sggf")] +position = Vector2(25, -1) +TopLeftCorner = NodePath("TL") +BottomRightCorner = NodePath("BR") +PlayerSpawnPoint = NodePath("PS") + +[node name="TL" type="Node2D" parent="Zones/PlayZone1"] +position = Vector2(9, 95) + +[node name="BR" type="Node2D" parent="Zones/PlayZone1"] +position = Vector2(166, 256) + +[node name="PS" type="Node2D" parent="Zones/PlayZone1"] +position = Vector2(55, 127) + [node name="Player" parent="." instance=ExtResource("1_65a7v")] -position = Vector2(19, 4) +position = Vector2(74, 147) -[node name="TestWall" type="Sprite2D" parent="."] -light_mask = 2 -y_sort_enabled = true -material = SubResource("CanvasItemMaterial_wg1ao") -position = Vector2(58, 37) -texture = ExtResource("2_edqdh") - -[node name="TestWall2" type="Sprite2D" parent="."] -light_mask = 2 -y_sort_enabled = true -position = Vector2(85, 71) -texture = ExtResource("2_edqdh") +[node name="level" parent="." instance=ExtResource("5_skctj")] [node name="FlashlightViewport" type="SubViewport" parent="."] disable_3d = true @@ -126,7 +122,7 @@ CameraBounds = Vector2(30, 20) [node name="PointLight2D" type="PointLight2D" parent="PlayerCamera" node_paths=PackedStringArray("LightViewport")] blend_mode = 2 range_item_cull_mask = 2 -texture = SubResource("ViewportTexture_q4yg2") +texture = SubResource("ViewportTexture_x6taj") script = ExtResource("6_slohe") LightViewport = NodePath("../../FlashlightViewport") @@ -186,58 +182,59 @@ layout_mode = 0 [node name="MonsterSprite" type="TextureRect" parent="CanvasLayer/DeathScreen"] layout_mode = 0 -[node name="Sprite2D" type="Sprite2D" parent="."] -light_mask = 2 -y_sort_enabled = true -material = SubResource("CanvasItemMaterial_au1d0") -position = Vector2(-83, 43) -texture = ExtResource("3_8o315") +[node name="WinScreen" type="TextureRect" parent="CanvasLayer" node_paths=PackedStringArray("Manager")] +z_index = 15 +anchors_preset = 15 +anchor_right = 1.0 +anchor_bottom = 1.0 +grow_horizontal = 2 +grow_vertical = 2 +texture = SubResource("GradientTexture2D_2sbp3") +script = ExtResource("13_prax6") +Manager = NodePath("../../GameManager") -[node name="Watcher" parent="." instance=ExtResource("10_fsiss")] -position = Vector2(116, -76) +[node name="Label" type="Label" parent="CanvasLayer/WinScreen"] +layout_mode = 1 +anchors_preset = 10 +anchor_right = 1.0 +offset_bottom = 81.0 +grow_horizontal = 2 +theme = ExtResource("14_g1c0r") +theme_override_font_sizes/font_size = 20 +text = "CONGRATULATIONS!" +horizontal_alignment = 1 +vertical_alignment = 1 -[node name="LivingArmor" parent="." instance=ExtResource("11_x3ep3")] -position = Vector2(-70, -67) +[node name="Label2" type="Label" parent="CanvasLayer/WinScreen"] +layout_mode = 1 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_top = -11.5 +offset_bottom = 11.5 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("14_g1c0r") +text = "It took you +{} attempts +and {} +to finish the game." +horizontal_alignment = 1 +vertical_alignment = 1 -[node name="pressure_plate" parent="." instance=ExtResource("12_ynt5e")] -position = Vector2(31, 51) - -[node name="spikes" parent="." instance=ExtResource("13_w1hk1")] -position = Vector2(-40, 112) -Enabled = true -SpikesTimeout = 0.5 - -[node name="spikes2" parent="." instance=ExtResource("13_w1hk1")] -position = Vector2(-8, 112) -Enabled = true -SpikesTimeout = 0.5 -StartOffset = 0.25 - -[node name="spikes3" parent="." instance=ExtResource("13_w1hk1")] -position = Vector2(24, 112) -Enabled = true -SpikesTimeout = 0.5 -StartOffset = 0.5 - -[node name="Wretched" parent="." instance=ExtResource("16_ejflu")] -position = Vector2(-120, 42) - -[node name="Wretched2" parent="." instance=ExtResource("16_ejflu")] -position = Vector2(-139, -39) - -[node name="TestPlayZone" parent="." node_paths=PackedStringArray("TopLeftCorner", "BottomRightCorner", "PlayerSpawnPoint") instance=ExtResource("17_mxxy2")] -position = Vector2(79, 99) -TopLeftCorner = NodePath("TopLeft") -BottomRightCorner = NodePath("BottomRight") -PlayerSpawnPoint = NodePath("SpawnPoint") - -[node name="TopLeft" type="Node2D" parent="TestPlayZone"] - -[node name="BottomRight" type="Node2D" parent="TestPlayZone"] -position = Vector2(97, 67) - -[node name="SpawnPoint" type="Node2D" parent="TestPlayZone"] -position = Vector2(56, 34) +[node name="Label3" type="Label" parent="CanvasLayer/WinScreen"] +layout_mode = 1 +anchors_preset = 12 +anchor_top = 1.0 +anchor_right = 1.0 +anchor_bottom = 1.0 +offset_top = -52.0 +grow_horizontal = 2 +grow_vertical = 0 +theme = ExtResource("14_g1c0r") +text = "Thank you for playing! :)" +horizontal_alignment = 1 +vertical_alignment = 1 [connection signal="timeout" from="CanvasLayer/DeathScreen/Timer" to="CanvasLayer/DeathScreen" method="Timeout"] -[connection signal="ZoneEntered" from="TestPlayZone" to="GameManager" method="SetCurrentZone"] diff --git a/scenes/menu.tscn b/scenes/menu.tscn index ff938a5..298b9f5 100644 --- a/scenes/menu.tscn +++ b/scenes/menu.tscn @@ -241,6 +241,21 @@ grow_horizontal = 2 grow_vertical = 2 texture = ExtResource("7_jjakx") +[node name="Label" type="Label" parent="CanvasLayer/Title"] +layout_mode = 1 +anchors_preset = 14 +anchor_top = 0.5 +anchor_right = 1.0 +anchor_bottom = 0.5 +offset_top = 27.5 +offset_bottom = 40.5 +grow_horizontal = 2 +grow_vertical = 2 +theme = ExtResource("3_d3ur4") +text = "by Tea Sanctuary, 2023" +horizontal_alignment = 1 +vertical_alignment = 1 + [node name="LabelBackground" type="TextureRect" parent="CanvasLayer"] anchors_preset = 12 anchor_top = 1.0 diff --git a/scripts/GameManager.cs b/scripts/GameManager.cs index 5f90d3e..35a3866 100644 --- a/scripts/GameManager.cs +++ b/scripts/GameManager.cs @@ -55,6 +55,8 @@ public partial class GameManager : Node public void OnPlayerDied() => _gameInfo.Attempts++; + public int GetAttempts() => _gameInfo.Attempts; + public void SetCurrentZone(PlayZone zone) { GD.Print($"New zone {zone}"); diff --git a/scripts/WinScreen.cs b/scripts/WinScreen.cs new file mode 100644 index 0000000..62c1790 --- /dev/null +++ b/scripts/WinScreen.cs @@ -0,0 +1,28 @@ +using Godot; +using System; + +public partial class WinScreen : TextureRect +{ + [Export] public GameManager Manager; + + public override void _Ready() + { + Visible = false; + } + + public void Open() + { + Visible = true; + + ((Label)FindChild("Label2")).Text = + $"It took you\n{Manager.GetAttempts()} attempts\nand {Manager.GetFormattedTimeElapsed()}\nto finish the game."; + } + + public override void _Input(InputEvent @event) + { + if (Visible && @event.IsActionPressed("ui_confirm")) + { + GetTree().ChangeSceneToFile("res://scenes/menu.tscn"); + } + } +} diff --git a/scripts/enemies/Claw.cs b/scripts/enemies/Claw.cs index 80f5972..5639841 100644 --- a/scripts/enemies/Claw.cs +++ b/scripts/enemies/Claw.cs @@ -4,18 +4,20 @@ using System; public partial class Claw : CharacterBody2D { [Export] public float MovingSpeed = 32f; + public enum State { + Waiting, Moving, Prepare, Attack } - private State _state = State.Moving; + private State _state = State.Waiting; private float _stateTimeout = 0; private bool _isPlayerNearBy = false; private AnimatedSprite2D _sprite; - + // Called when the node enters the scene tree for the first time. public override void _Ready() { @@ -32,6 +34,9 @@ public partial class Claw : CharacterBody2D _stateTimeout -= (float)delta; switch (_state) { + case State.Waiting: + break; + case State.Moving: var direction = (Player.Instance.Position - Position).Normalized(); Velocity = direction * MovingSpeed; @@ -46,6 +51,7 @@ public partial class Claw : CharacterBody2D _state = State.Attack; _stateTimeout = 0.25f; } + break; case State.Attack: _sprite.Play("attack"); @@ -55,10 +61,10 @@ public partial class Claw : CharacterBody2D if (_isPlayerNearBy) Player.Instance.Kill(this); } + break; } } - private void _OnEntered(Node2D body) { @@ -75,7 +81,10 @@ public partial class Claw : CharacterBody2D { _isPlayerNearBy = false; } - - -} + public void Enable() + { + GD.Print("Boss enabled"); + _state = State.Moving; + } +} diff --git a/scripts/entities/Door.cs b/scripts/entities/Door.cs new file mode 100644 index 0000000..05868d3 --- /dev/null +++ b/scripts/entities/Door.cs @@ -0,0 +1,27 @@ +using Godot; + +public partial class Door : Node2D +{ + private AnimatedSprite2D _animatedSprite2D; + private CollisionShape2D _collisionShape2D; + + public override void _Ready() + { + _animatedSprite2D = (AnimatedSprite2D)FindChild("AnimatedSprite2D"); + _collisionShape2D = (CollisionShape2D)FindChild("CollisionShape2D"); + + Close(); + } + + public void Close() + { + _animatedSprite2D.Play("close"); + _collisionShape2D.Disabled = false; + } + + public void Open() + { + _animatedSprite2D.Play("open"); + _collisionShape2D.Disabled = true; + } +} diff --git a/scripts/entities/Teleport.cs b/scripts/entities/Teleport.cs new file mode 100644 index 0000000..25bf640 --- /dev/null +++ b/scripts/entities/Teleport.cs @@ -0,0 +1,20 @@ +using Godot; +using System; + +public partial class Teleport : Area2D +{ + [Signal] + public delegate void TeleportTriggeredEventHandler(); + + [Export] public Node2D To; + + private void OnPlayerEntered(Node2D body) + { + if (body is not Player player) + return; + + player.GlobalPosition = To.GlobalPosition; + + EmitSignal(SignalName.TeleportTriggered); + } +} diff --git a/sprites/enemies/wretched/wretched.tres b/sprites/enemies/wretched/wretched.tres index f4c72f2..a3999a3 100644 --- a/sprites/enemies/wretched/wretched.tres +++ b/sprites/enemies/wretched/wretched.tres @@ -1,4 +1,4 @@ -[gd_resource type="SpriteFrames" load_steps=23 format=3 uid="uid://blijqhtsnyq7n"] +[gd_resource type="SpriteFrames" load_steps=23 format=3 uid="uid://cisc0k30gpx1q"] [ext_resource type="Texture2D" uid="uid://jt8w0gpcde42" path="res://sprites/enemies/wretched/wretched_bottom.png" id="1_42h2f"] [ext_resource type="Texture2D" uid="uid://dx8chnbe6vmow" path="res://sprites/enemies/wretched/wretched_side.png" id="2_8muft"] diff --git a/sprites/tiles/QoL.tres b/sprites/tiles/QoL.tres index 532caea..4b0c7b7 100644 --- a/sprites/tiles/QoL.tres +++ b/sprites/tiles/QoL.tres @@ -1,4 +1,4 @@ -[gd_resource type="TileSet" load_steps=10 format=3 uid="uid://b4dpeakjmn31p"] +[gd_resource type="TileSet" load_steps=10 format=3 uid="uid://c7x8hryljgpha"] [ext_resource type="Texture2D" uid="uid://br3o2fekkyynd" path="res://sprites/tiles/frames/brd_atlas.png" id="1_r6rba"] [ext_resource type="Texture2D" uid="uid://d32t4dsukrsq2" path="res://sprites/tiles/floor/floor_atlas.png" id="2_h4pc5"]