mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-11 05:25:55 +00:00
Keycards
This commit is contained in:
parent
14893a544b
commit
ba46799911
7 changed files with 60 additions and 6 deletions
|
|
@ -2,7 +2,7 @@ using Godot;
|
|||
using System;
|
||||
using System.Diagnostics;
|
||||
|
||||
public partial class Activable : Area2D
|
||||
public partial class Activable : Node2D
|
||||
{
|
||||
public virtual void Activate()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -5,9 +5,24 @@ using System.Diagnostics;
|
|||
public partial class Interactable : Area2D
|
||||
{
|
||||
[Export] public Activable Target { get; set; }
|
||||
[Export] public bool RequiresKeycard { get; set; }
|
||||
private InventoryManager _inventoryManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
}
|
||||
|
||||
public void Activate()
|
||||
{
|
||||
Target?.Activate();
|
||||
if (RequiresKeycard) {
|
||||
if (_inventoryManager.RedKeycard) {
|
||||
Target?.Activate();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Target?.Activate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
18
Scenes/Keycard_Pad.tscn
Normal file
18
Scenes/Keycard_Pad.tscn
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://cymtsmui4yo17"]
|
||||
|
||||
[ext_resource type="Script" path="res://Scenes/Interactable.cs" id="1_q256v"]
|
||||
[ext_resource type="Texture2D" uid="uid://ch6nbhxgxxtf" path="res://Sprites/Red_Card_Reader.png" id="2_xidhq"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_x0adl"]
|
||||
|
||||
[node name="KeycardPad" type="Area2D" groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_q256v")
|
||||
RequiresKeycard = true
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_x0adl")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("2_xidhq")
|
||||
|
|
@ -6,10 +6,11 @@
|
|||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_x0adl"]
|
||||
|
||||
[node name="ControlPad" type="Area2D" groups=["Interactable"]]
|
||||
[node name="ControlPad" type="Area2D" node_paths=PackedStringArray("Target") groups=["Interactable"]]
|
||||
collision_layer = 4
|
||||
collision_mask = 2
|
||||
script = ExtResource("1_8ev2v")
|
||||
Target = NodePath("Pickupper")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_x0adl")
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=22 format=4 uid="uid://bv451a8wgty4u"]
|
||||
[gd_scene load_steps=24 format=4 uid="uid://bv451a8wgty4u"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
|
||||
[ext_resource type="PackedScene" uid="uid://rp4jhx0tuh24" path="res://Scenes/fragola.tscn" id="4_s7wq6"]
|
||||
|
|
@ -18,6 +18,8 @@
|
|||
[ext_resource type="PackedScene" uid="uid://cxjumgf8bhr3l" path="res://Scenes/Elevator.tscn" id="16_n40rt"]
|
||||
[ext_resource type="Script" path="res://Scripts/InventoryManager.cs" id="18_dvo37"]
|
||||
[ext_resource type="PackedScene" uid="uid://v8s3kubgb2qg" path="res://Scenes/Enemy.tscn" id="18_ixcwn"]
|
||||
[ext_resource type="PackedScene" uid="uid://dxs3ks2ucaxl4" path="res://Scenes/Red_Keycard.tscn" id="19_8fb73"]
|
||||
[ext_resource type="PackedScene" uid="uid://cymtsmui4yo17" path="res://Scenes/Keycard_Pad.tscn" id="20_0aphx"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_jwf4b"]
|
||||
resource_name = "Factory"
|
||||
|
|
@ -296,7 +298,7 @@ position = Vector2(-840, 184)
|
|||
[node name="Door" parent="Factory Tilemaps" instance=ExtResource("14_y363m")]
|
||||
position = Vector2(-766, -74)
|
||||
|
||||
[node name="Area2D" parent="Factory Tilemaps" instance=ExtResource("12_i7i2m")]
|
||||
[node name="HorizontalDoor" parent="Factory Tilemaps" instance=ExtResource("12_i7i2m")]
|
||||
position = Vector2(-1120, 128)
|
||||
|
||||
[node name="CameraController" type="Camera2D" parent="."]
|
||||
|
|
@ -340,3 +342,10 @@ position = Vector2(-1258, 179)
|
|||
|
||||
[node name="InventoryManager" type="Node2D" parent="."]
|
||||
script = ExtResource("18_dvo37")
|
||||
|
||||
[node name="ControlPad" parent="." instance=ExtResource("19_8fb73")]
|
||||
position = Vector2(-1164, 208)
|
||||
|
||||
[node name="KeycardPad" parent="." node_paths=PackedStringArray("Target") instance=ExtResource("20_0aphx")]
|
||||
position = Vector2(-1094, 135)
|
||||
Target = NodePath("../Factory Tilemaps/HorizontalDoor")
|
||||
|
|
|
|||
|
|
@ -3,9 +3,17 @@ using System;
|
|||
|
||||
public partial class Pickupper : Activable
|
||||
{
|
||||
|
||||
private InventoryManager inventoryManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
}
|
||||
|
||||
public override void Activate()
|
||||
{
|
||||
|
||||
inventoryManager.AddRedKeycard();
|
||||
GetParent().QueueFree();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,12 +41,15 @@ public partial class PlayerMovement : CharacterBody2D, IDestructible
|
|||
|
||||
private bool _isDestroyed = false;
|
||||
|
||||
//private InventoryManager _inventoryManager;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_currentHealth = Health;
|
||||
|
||||
_animatedSprite = GetNode<AnimatedSprite2D>("./Smoothing2D/AnimatedSprite2D");
|
||||
_crosshair = GetNode<Sprite2D>("./Smoothing2D/Crosshair");
|
||||
//_inventoryManager = GetNode<InventoryManager>("/root/GameScene/InventoryManager");
|
||||
|
||||
_movementDirection = Vector2.Zero;
|
||||
_facingDirection = Vector2.Zero;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue