now it's actually playable
This commit is contained in:
parent
5496914c2a
commit
b5439da5a0
13 changed files with 84 additions and 26 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +1,4 @@
|
|||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
# Binaries
|
||||
bin/
|
|
@ -48,7 +48,7 @@ custom_features=""
|
|||
export_filter="all_resources"
|
||||
include_filter=""
|
||||
exclude_filter=""
|
||||
export_path=""
|
||||
export_path="bin/quest-of-light.exe"
|
||||
encryption_include_filters=""
|
||||
encryption_exclude_filters=""
|
||||
encrypt_pck=false
|
||||
|
|
|
@ -34,6 +34,8 @@ sprite_frames = SubResource("SpriteFrames_v2loo")
|
|||
animation = &"closed"
|
||||
|
||||
[node name="StaticBody2D" type="StaticBody2D" parent="."]
|
||||
collision_layer = 4
|
||||
collision_mask = 4
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StaticBody2D"]
|
||||
position = Vector2(0, 6)
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[ext_resource type="Script" path="res://scripts/Player.cs" id="1_1vpun"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://cfdng3tdv65p6" path="res://sprites/player/player.tres" id="1_8jl58"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://2621hqkv4w0x" path="res://sprites/key_space.tres" id="3_h0r18"]
|
||||
[ext_resource type="SpriteFrames" uid="uid://dqtp1l5ecav4k" path="res://sprites/key_space.tres" id="3_h0r18"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_5hhj3"]
|
||||
size = Vector2(15, 15)
|
||||
|
|
|
@ -82,12 +82,15 @@ position = Vector2(624, -385)
|
|||
|
||||
[node name="spikes" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(683, -352)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes2" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(683, -384)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes3" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(683, -415)
|
||||
Enabled = true
|
||||
|
||||
[node name="papers2" parent="." instance=ExtResource("5_th514")]
|
||||
position = Vector2(751, 92)
|
||||
|
@ -106,33 +109,39 @@ position = Vector2(688, -850)
|
|||
|
||||
[node name="spikes4" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(785, -847)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes5" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(847, -847)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes6" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(817, -847)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes7" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(848, -816)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes8" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(848, -783)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes9" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(848, -752)
|
||||
Enabled = true
|
||||
|
||||
[node name="pressure_plate_puzzle_4_bl" parent="." instance=ExtResource("9_6ydrq")]
|
||||
position = Vector2(-113, -592)
|
||||
position = Vector2(-83, -622)
|
||||
|
||||
[node name="pressure_plate_puzzle_4_br" parent="." instance=ExtResource("9_6ydrq")]
|
||||
position = Vector2(432, -592)
|
||||
position = Vector2(404, -624)
|
||||
|
||||
[node name="pressure_plate_puzzle_4_tl" parent="." instance=ExtResource("9_6ydrq")]
|
||||
position = Vector2(-110, -1072)
|
||||
position = Vector2(-87, -1046)
|
||||
|
||||
[node name="pressure_plate_puzzle_4_tr" parent="." instance=ExtResource("9_6ydrq")]
|
||||
position = Vector2(432, -1071)
|
||||
position = Vector2(413, -1045)
|
||||
|
||||
[node name="door_closed_puzzle_4" parent="." instance=ExtResource("7_kt8g1")]
|
||||
position = Vector2(177, -1112)
|
||||
|
@ -256,21 +265,27 @@ position = Vector2(791, 783)
|
|||
|
||||
[node name="spikes10" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(732, 980)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes11" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(764, 947)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes12" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(796, 915)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes13" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(576, 978)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes14" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(544, 946)
|
||||
Enabled = true
|
||||
|
||||
[node name="spikes15" parent="." instance=ExtResource("10_yerk5")]
|
||||
position = Vector2(512, 915)
|
||||
Enabled = true
|
||||
|
||||
[node name="Watcher" parent="." instance=ExtResource("13_nbkmp")]
|
||||
position = Vector2(1489, 566)
|
||||
|
|
|
@ -22,7 +22,7 @@ point_count = 2
|
|||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"]
|
||||
shader = ExtResource("5_64d71")
|
||||
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_42ps6"]
|
||||
[sub_resource type="ViewportTexture" id="ViewportTexture_57pph"]
|
||||
viewport_path = NodePath("FlashlightViewport")
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"]
|
||||
|
@ -46,8 +46,9 @@ height = 192
|
|||
[node name="Root" type="Node2D"]
|
||||
y_sort_enabled = true
|
||||
|
||||
[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("Player")]
|
||||
[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("FirstZone", "Player")]
|
||||
script = ExtResource("1_ij566")
|
||||
FirstZone = NodePath("../Zones/PlayZone1")
|
||||
Player = NodePath("../Player")
|
||||
|
||||
[node name="Sounds" type="Node" parent="."]
|
||||
|
@ -242,7 +243,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_42ps6")
|
||||
texture = SubResource("ViewportTexture_57pph")
|
||||
script = ExtResource("6_slohe")
|
||||
LightViewport = NodePath("../../FlashlightViewport")
|
||||
|
||||
|
@ -302,7 +303,7 @@ layout_mode = 0
|
|||
[node name="MonsterSprite" type="TextureRect" parent="CanvasLayer/DeathScreen"]
|
||||
layout_mode = 0
|
||||
|
||||
[node name="WinScreen" type="TextureRect" parent="CanvasLayer" node_paths=PackedStringArray("Manager")]
|
||||
[node name="WinScreen" type="TextureRect" parent="CanvasLayer" node_paths=PackedStringArray("Manager", "TextLabel")]
|
||||
visible = false
|
||||
z_index = 15
|
||||
anchors_preset = 15
|
||||
|
@ -313,6 +314,7 @@ grow_vertical = 2
|
|||
texture = SubResource("GradientTexture2D_2sbp3")
|
||||
script = ExtResource("13_prax6")
|
||||
Manager = NodePath("../../GameManager")
|
||||
TextLabel = NodePath("Label2")
|
||||
|
||||
[node name="Label" type="Label" parent="CanvasLayer/WinScreen"]
|
||||
layout_mode = 1
|
||||
|
@ -327,7 +329,6 @@ horizontal_alignment = 1
|
|||
vertical_alignment = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="CanvasLayer/WinScreen"]
|
||||
visible = false
|
||||
layout_mode = 1
|
||||
anchors_preset = 14
|
||||
anchor_top = 0.5
|
||||
|
@ -360,5 +361,15 @@ horizontal_alignment = 1
|
|||
vertical_alignment = 1
|
||||
|
||||
[connection signal="GameOver" from="GameManager" to="CanvasLayer/WinScreen" method="Open"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone1" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone2" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone3" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone4" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone5" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone6" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone7" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone8" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="ZoneEntered" from="Zones/PlayZone9" to="GameManager" method="SetCurrentZone"]
|
||||
[connection signal="Killed" from="Player" to="GameManager" method="OnPlayerDied"]
|
||||
[connection signal="BossKilled" from="level" to="GameManager" method="EndGame"]
|
||||
[connection signal="timeout" from="CanvasLayer/DeathScreen/Timer" to="CanvasLayer/DeathScreen" method="Timeout"]
|
||||
|
|
|
@ -8,11 +8,17 @@ public partial class GameManager : Node
|
|||
public ulong GameStart = 0;
|
||||
public ulong GameEnd = 0;
|
||||
public int Attempts = 0;
|
||||
public Node2D Checkpoint;
|
||||
public NodePath Checkpoint = new NodePath();
|
||||
|
||||
public GameInfo(Node2D checkpoint)
|
||||
public GameInfo(NodePath path)
|
||||
{
|
||||
Checkpoint = checkpoint;
|
||||
SetCheckpoint(path);
|
||||
}
|
||||
|
||||
public void SetCheckpoint(NodePath path)
|
||||
{
|
||||
GD.Print($"{path}");
|
||||
Checkpoint = path;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,8 +36,9 @@ public partial class GameManager : Node
|
|||
{
|
||||
if (!IsPlaying)
|
||||
{
|
||||
GD.Print("Restart stats");
|
||||
IsPlaying = true;
|
||||
_gameInfo = new GameInfo(FirstZone.PlayerSpawnPoint);
|
||||
_gameInfo = new GameInfo(GetPathTo(FirstZone.PlayerSpawnPoint));
|
||||
}
|
||||
|
||||
StartGame();
|
||||
|
@ -40,18 +47,21 @@ public partial class GameManager : Node
|
|||
public void StartGame()
|
||||
{
|
||||
_gameInfo.GameStart = Time.GetTicksMsec();
|
||||
Player.Position = _gameInfo.Checkpoint.GlobalPosition;
|
||||
Player.GlobalPosition = GetNode<Node2D>(_gameInfo.Checkpoint).GlobalPosition;
|
||||
}
|
||||
|
||||
public void EndGame()
|
||||
{
|
||||
_gameInfo.GameEnd = Time.GetTicksMsec();
|
||||
|
||||
Player.Invincible = true;
|
||||
Player.SetProcess(false);
|
||||
|
||||
EmitSignal(SignalName.GameOver);
|
||||
}
|
||||
|
||||
public string GetFormattedTimeElapsed() =>
|
||||
TimeSpan.FromMilliseconds(_gameInfo.GameEnd - _gameInfo.GameStart).ToString(@"hh\:mm\:ss.fff");
|
||||
TimeSpan.FromMilliseconds(_gameInfo.GameEnd - _gameInfo.GameStart).ToString(@"hh\:mm\:ss\.fff");
|
||||
|
||||
public void OnPlayerDied() => _gameInfo.Attempts++;
|
||||
|
||||
|
@ -60,6 +70,7 @@ public partial class GameManager : Node
|
|||
public void SetCurrentZone(PlayZone zone)
|
||||
{
|
||||
GD.Print($"New zone {zone}");
|
||||
_gameInfo.Checkpoint = zone.PlayerSpawnPoint;
|
||||
var path = GetPathTo(zone.PlayerSpawnPoint);
|
||||
_gameInfo.SetCheckpoint(path);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,12 @@ public partial class PlayZone : Node2D
|
|||
|
||||
private Area2D _area2D;
|
||||
private CollisionShape2D _collisionShape2D;
|
||||
//private GameManager _gameManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
//_gameManager = (GameManager)GetTree().Root.FindChild("GameManager");
|
||||
|
||||
_area2D = (Area2D)FindChild("Area2D");
|
||||
_collisionShape2D = (CollisionShape2D)FindChild("CollisionShape2D");
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ public partial class Player : CharacterBody2D
|
|||
public delegate void KilledEventHandler();
|
||||
|
||||
public bool Alive = true;
|
||||
public bool Invincible = false;
|
||||
|
||||
public static Player Instance { get; private set; }
|
||||
|
||||
|
@ -65,7 +66,7 @@ public partial class Player : CharacterBody2D
|
|||
|
||||
public void Kill(Node2D killer)
|
||||
{
|
||||
if (!Alive)
|
||||
if (!Alive || Invincible)
|
||||
return;
|
||||
|
||||
GD.Print($"Killed by {killer.Name}");
|
||||
|
|
|
@ -4,6 +4,7 @@ using System;
|
|||
public partial class WinScreen : TextureRect
|
||||
{
|
||||
[Export] public GameManager Manager;
|
||||
[Export] public Label TextLabel;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
@ -14,7 +15,7 @@ public partial class WinScreen : TextureRect
|
|||
{
|
||||
Visible = true;
|
||||
|
||||
((Label)FindChild("Label2")).Text =
|
||||
TextLabel.Text =
|
||||
$"It took you\n{Manager.GetAttempts()} attempts\nand {Manager.GetFormattedTimeElapsed()}\nto finish the game.";
|
||||
}
|
||||
|
||||
|
|
|
@ -15,13 +15,15 @@ public partial class And : Node
|
|||
public void Increment()
|
||||
{
|
||||
_buttons++;
|
||||
GD.Print($"Increment {_buttons}/{CountOfButtons}");
|
||||
if (_buttons == CountOfButtons)
|
||||
EmitSignal(SignalName.ConditionNotMet);
|
||||
EmitSignal(SignalName.ConditionMet);
|
||||
}
|
||||
|
||||
public void Decrement()
|
||||
{
|
||||
_buttons--;
|
||||
GD.Print($"Decrement {_buttons}/{CountOfButtons}");
|
||||
if (_buttons != CountOfButtons)
|
||||
EmitSignal(SignalName.ConditionNotMet);
|
||||
}
|
||||
|
|
|
@ -3,12 +3,18 @@ using Godot;
|
|||
public partial class Door : Node2D
|
||||
{
|
||||
private AnimatedSprite2D _animatedSprite2D;
|
||||
private CollisionShape2D _collisionShape2D;
|
||||
private StaticBody2D _staticBody2D;
|
||||
|
||||
private uint _collisionMask;
|
||||
private uint _collisionLayer;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_animatedSprite2D = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
||||
_collisionShape2D = (CollisionShape2D)FindChild("CollisionShape2D");
|
||||
_staticBody2D = (StaticBody2D)FindChild("StaticBody2D");
|
||||
|
||||
_collisionMask = _staticBody2D.CollisionMask;
|
||||
_collisionLayer = _staticBody2D.CollisionLayer;
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -16,12 +22,16 @@ public partial class Door : Node2D
|
|||
public void Close()
|
||||
{
|
||||
_animatedSprite2D.Play("close");
|
||||
_collisionShape2D.Disabled = false;
|
||||
|
||||
_staticBody2D.CollisionMask = _collisionMask;
|
||||
_staticBody2D.CollisionLayer = _collisionLayer;
|
||||
}
|
||||
|
||||
public void Open()
|
||||
{
|
||||
_animatedSprite2D.Play("open");
|
||||
_collisionShape2D.Disabled = true;
|
||||
|
||||
_staticBody2D.CollisionMask = 0;
|
||||
_staticBody2D.CollisionLayer = 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_resource type="SpriteFrames" load_steps=4 format=3 uid="uid://2621hqkv4w0x"]
|
||||
[gd_resource type="SpriteFrames" load_steps=4 format=3 uid="uid://dqtp1l5ecav4k"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://geiagnq38try" path="res://sprites/key_space.png" id="1_xhlet"]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue