Alarm box

This commit is contained in:
Marco 2025-02-04 13:22:05 +01:00
commit 60dad2d002
15 changed files with 581 additions and 401 deletions

View file

@ -0,0 +1,277 @@
[gd_resource type="SpriteFrames" load_steps=35 format=3 uid="uid://yfxog8pww6ih"]
[ext_resource type="Texture2D" uid="uid://cpuffmksk41n4" path="res://Sprites/Actors/Camera.png" id="1_p68hc"]
[sub_resource type="AtlasTexture" id="AtlasTexture_1cxu1"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_bi4kn"]
atlas = ExtResource("1_p68hc")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qgntu"]
atlas = ExtResource("1_p68hc")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0xn7d"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_5xbm6"]
atlas = ExtResource("1_p68hc")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oxghg"]
atlas = ExtResource("1_p68hc")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_6e5gf"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dxl8p"]
atlas = ExtResource("1_p68hc")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_d0i3t"]
atlas = ExtResource("1_p68hc")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oy0eq"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_14w2k"]
atlas = ExtResource("1_p68hc")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_m2si1"]
atlas = ExtResource("1_p68hc")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_lbhml"]
atlas = ExtResource("1_p68hc")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_rw7h1"]
atlas = ExtResource("1_p68hc")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_x62ns"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_unrcw"]
atlas = ExtResource("1_p68hc")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_y5qth"]
atlas = ExtResource("1_p68hc")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qkmcw"]
atlas = ExtResource("1_p68hc")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_myuwn"]
atlas = ExtResource("1_p68hc")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_8aa11"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_u7xyi"]
atlas = ExtResource("1_p68hc")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qrkj0"]
atlas = ExtResource("1_p68hc")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qcqm5"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_34faw"]
atlas = ExtResource("1_p68hc")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_j34h0"]
atlas = ExtResource("1_p68hc")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ojvts"]
atlas = ExtResource("1_p68hc")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kf402"]
atlas = ExtResource("1_p68hc")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_aaebm"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_owve1"]
atlas = ExtResource("1_p68hc")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0eww4"]
atlas = ExtResource("1_p68hc")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0pie4"]
atlas = ExtResource("1_p68hc")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oh7bx"]
atlas = ExtResource("1_p68hc")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_vxoib"]
atlas = ExtResource("1_p68hc")
region = Rect2(0, 0, 16, 16)
[resource]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_1cxu1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bi4kn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qgntu")
}],
"loop": false,
"name": &"center_to_left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_0xn7d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5xbm6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oxghg")
}],
"loop": false,
"name": &"center_to_right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_6e5gf")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_dxl8p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d0i3t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oy0eq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_14w2k")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m2si1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lbhml")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rw7h1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x62ns")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_unrcw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y5qth")
}],
"loop": true,
"name": &"full_scan",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qkmcw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_myuwn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8aa11")
}],
"loop": false,
"name": &"left_to_center",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_u7xyi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qrkj0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qcqm5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_34faw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j34h0")
}],
"loop": false,
"name": &"left_to_right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ojvts")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kf402")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aaebm")
}],
"loop": false,
"name": &"right_to_center",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_owve1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0eww4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0pie4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oh7bx")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vxoib")
}],
"loop": false,
"name": &"right_to_left",
"speed": 5.0
}]

View file

@ -1,293 +1,49 @@
[gd_scene load_steps=38 format=3 uid="uid://c27co22bjym3c"]
[gd_scene load_steps=7 format=3 uid="uid://c27co22bjym3c"]
[ext_resource type="Script" path="res://Scripts/Actors/Camera.cs" id="1_2qb38"]
[ext_resource type="Texture2D" uid="uid://cpuffmksk41n4" path="res://Sprites/Actors/Camera.png" id="1_l5lfg"]
[sub_resource type="AtlasTexture" id="AtlasTexture_1cxu1"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_bi4kn"]
atlas = ExtResource("1_l5lfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qgntu"]
atlas = ExtResource("1_l5lfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0xn7d"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_5xbm6"]
atlas = ExtResource("1_l5lfg")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oxghg"]
atlas = ExtResource("1_l5lfg")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_6e5gf"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_dxl8p"]
atlas = ExtResource("1_l5lfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_d0i3t"]
atlas = ExtResource("1_l5lfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oy0eq"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_14w2k"]
atlas = ExtResource("1_l5lfg")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_m2si1"]
atlas = ExtResource("1_l5lfg")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_lbhml"]
atlas = ExtResource("1_l5lfg")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_rw7h1"]
atlas = ExtResource("1_l5lfg")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_x62ns"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_unrcw"]
atlas = ExtResource("1_l5lfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_y5qth"]
atlas = ExtResource("1_l5lfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qkmcw"]
atlas = ExtResource("1_l5lfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_myuwn"]
atlas = ExtResource("1_l5lfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_8aa11"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_u7xyi"]
atlas = ExtResource("1_l5lfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qrkj0"]
atlas = ExtResource("1_l5lfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_qcqm5"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_34faw"]
atlas = ExtResource("1_l5lfg")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_j34h0"]
atlas = ExtResource("1_l5lfg")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ojvts"]
atlas = ExtResource("1_l5lfg")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_kf402"]
atlas = ExtResource("1_l5lfg")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_aaebm"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_owve1"]
atlas = ExtResource("1_l5lfg")
region = Rect2(64, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0eww4"]
atlas = ExtResource("1_l5lfg")
region = Rect2(48, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_0pie4"]
atlas = ExtResource("1_l5lfg")
region = Rect2(32, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_oh7bx"]
atlas = ExtResource("1_l5lfg")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_vxoib"]
atlas = ExtResource("1_l5lfg")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_dvf56"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_1cxu1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_bi4kn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qgntu")
}],
"loop": false,
"name": &"center_to_left",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_0xn7d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_5xbm6")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oxghg")
}],
"loop": false,
"name": &"center_to_right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_6e5gf")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_dxl8p")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_d0i3t")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oy0eq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_14w2k")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m2si1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_lbhml")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_rw7h1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_x62ns")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_unrcw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_y5qth")
}],
"loop": true,
"name": &"full_scan",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qkmcw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_myuwn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_8aa11")
}],
"loop": false,
"name": &"left_to_center",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_u7xyi")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qrkj0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_qcqm5")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_34faw")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_j34h0")
}],
"loop": false,
"name": &"left_to_right",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ojvts")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kf402")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_aaebm")
}],
"loop": false,
"name": &"right_to_center",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_owve1")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0eww4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_0pie4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_oh7bx")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_vxoib")
}],
"loop": false,
"name": &"right_to_left",
"speed": 5.0
}]
[ext_resource type="SpriteFrames" uid="uid://yfxog8pww6ih" path="res://Resources/Sprites/Camera.tres" id="2_omkb8"]
[ext_resource type="Script" path="res://Scripts/Components/ProximityPlayerDetection.cs" id="3_1qxk5"]
[sub_resource type="CircleShape2D" id="CircleShape2D_nkpag"]
[node name="Camera" type="Area2D"]
[sub_resource type="CircleShape2D" id="CircleShape2D_gs7jc"]
radius = 85.0529
[sub_resource type="RectangleShape2D" id="RectangleShape2D_3bqsq"]
size = Vector2(8, 12)
[node name="Camera" type="CharacterBody2D" node_paths=PackedStringArray("_playerDetection")]
collision_layer = 16
collision_mask = 8
script = ExtResource("1_2qb38")
Health = 1.0
WalkSpeed = 0.0
_playerDetection = NodePath("PlayerDetection")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_dvf56")
sprite_frames = ExtResource("2_omkb8")
animation = &"full_scan"
frame_progress = 0.779565
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_nkpag")
[node name="PlayerDetection" type="Area2D" parent="."]
visible = false
collision_layer = 16
collision_mask = 2
script = ExtResource("3_1qxk5")
[node name="PlayerDetectionArea" type="CollisionShape2D" parent="PlayerDetection"]
shape = SubResource("CircleShape2D_gs7jc")
[node name="DamageHitbox" type="Area2D" parent="."]
collision_layer = 16
collision_mask = 9
[node name="CollisionShape2D" type="CollisionShape2D" parent="DamageHitbox"]
shape = SubResource("RectangleShape2D_3bqsq")
[connection signal="area_entered" from="PlayerDetection" to="PlayerDetection" method="_on_area_entered"]
[connection signal="area_exited" from="PlayerDetection" to="PlayerDetection" method="_on_area_exited"]
[connection signal="area_entered" from="DamageHitbox" to="." method="_on_damage_hitbox_area_entered"]

View file

@ -22,12 +22,13 @@ radius = 85.0529
[sub_resource type="RectangleShape2D" id="RectangleShape2D_m1rsg"]
size = Vector2(8, 12)
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("EquippedWeapon") groups=["Destroyable"]]
[node name="Enemy" type="CharacterBody2D" node_paths=PackedStringArray("EquippedWeapon", "_playerDetection") groups=["Destroyable"]]
collision_layer = 16
collision_mask = 9
script = ExtResource("1_h0ey4")
EquippedWeapon = NodePath("Weapon")
NavigationEnabled = true
_playerDetection = NodePath("PlayerDetection")
_navigationEnabled = true
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]

View file

@ -28,7 +28,7 @@ collision_mask = 9
script = ExtResource("1_lpwdj")
EquippedWeapon = NodePath("Weapon")
_playerDetection = NodePath("PlayerDetection")
NavigationEnabled = true
_navigationEnabled = true
metadata/_edit_group_ = true
[node name="Sprite2D" type="Sprite2D" parent="."]

View file

@ -0,0 +1,53 @@
[gd_scene load_steps=8 format=3 uid="uid://d1h48wgasakk4"]
[ext_resource type="Script" path="res://Scripts/Interactables/AlarmBox.cs" id="1_usvoy"]
[ext_resource type="Texture2D" uid="uid://bpc66amnvvkrn" path="res://Sprites/AlarmBox.png" id="2_slydm"]
[sub_resource type="CircleShape2D" id="CircleShape2D_vvpve"]
[sub_resource type="AtlasTexture" id="AtlasTexture_uh6p2"]
atlas = ExtResource("2_slydm")
region = Rect2(0, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_wt4ye"]
atlas = ExtResource("2_slydm")
region = Rect2(16, 0, 16, 16)
[sub_resource type="AtlasTexture" id="AtlasTexture_ucweu"]
atlas = ExtResource("2_slydm")
region = Rect2(0, 0, 16, 16)
[sub_resource type="SpriteFrames" id="SpriteFrames_kbgi5"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_uh6p2")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wt4ye")
}],
"loop": true,
"name": &"alarmed",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_ucweu")
}],
"loop": true,
"name": &"default",
"speed": 5.0
}]
[node name="AlarmBox" type="Area2D" groups=["Interactable"]]
collision_layer = 4
collision_mask = 2
script = ExtResource("1_usvoy")
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_vvpve")
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
sprite_frames = SubResource("SpriteFrames_kbgi5")
animation = &"alarmed"
frame_progress = 0.613245

View file

@ -38,3 +38,7 @@ gravity_scale = 0.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"]
position = Vector2(0, -3)
shape = SubResource("RectangleShape2D_ss2y0")
[node name="NavigationObstacle2D" type="NavigationObstacle2D" parent="."]
radius = 8.36
vertices = PackedVector2Array(-6, -9, 6, -9, 6, 2, -6, 2)

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=25 format=4 uid="uid://bv451a8wgty4u"]
[gd_scene load_steps=27 format=4 uid="uid://bv451a8wgty4u"]
[ext_resource type="Script" path="res://Scripts/GameManager.cs" id="1_8tmoj"]
[ext_resource type="PackedScene" uid="uid://bghghp5ep4w2j" path="res://Scenes/player.tscn" id="2_8mh54"]
@ -17,6 +17,7 @@
[ext_resource type="PackedScene" uid="uid://bc64lr3vlwchq" path="res://Scenes/Door_Vertical.tscn" id="15_mgtvp"]
[ext_resource type="PackedScene" uid="uid://c27co22bjym3c" path="res://Scenes/Actors/Camera.tscn" id="16_clqjt"]
[ext_resource type="PackedScene" uid="uid://cxjumgf8bhr3l" path="res://Scenes/Elevator.tscn" id="16_n40rt"]
[ext_resource type="PackedScene" uid="uid://d1h48wgasakk4" path="res://Scenes/Interactable/alarm_box.tscn" id="17_dppcs"]
[ext_resource type="PackedScene" uid="uid://cdr4m7pydqk6u" path="res://Scenes/Interactable/control_pad_red_keycard.tscn" id="17_e3v0b"]
[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"]
@ -24,6 +25,7 @@
[ext_resource type="PackedScene" uid="uid://dkwi1hu1bixoe" path="res://Scenes/HUD/HUD.tscn" id="22_krk0o"]
[ext_resource type="Script" path="res://Scenes/CameraTarget.gd" id="24_0c2yt"]
[ext_resource type="PackedScene" uid="uid://djf0y08ix66fn" path="res://Scenes/Interactable/Chest.tscn" id="25_4b2ed"]
[ext_resource type="Script" path="res://Scripts/AlarmManager.cs" id="25_rpwvt"]
[node name="GameScene" type="Node2D" node_paths=PackedStringArray("PlayerSpawnMarker")]
position = Vector2(38, 39)
@ -124,7 +126,16 @@ Target = NodePath("../HorizontalDoor")
position = Vector2(-790, -184)
[node name="Camera" parent="Factory Tilemaps" instance=ExtResource("16_clqjt")]
position = Vector2(-711, -168)
position = Vector2(-649, -168)
[node name="AlarmBox" parent="Factory Tilemaps" instance=ExtResource("17_dppcs")]
position = Vector2(-713, -153)
[node name="AlarmBox2" parent="Factory Tilemaps" instance=ExtResource("17_dppcs")]
position = Vector2(-616, -153)
[node name="AlarmBox3" parent="Factory Tilemaps" instance=ExtResource("17_dppcs")]
position = Vector2(-775, -184)
[node name="CameraController" type="Camera2D" parent="."]
script = ExtResource("6_t8ide")
@ -179,3 +190,6 @@ position = Vector2(-790, -161)
[node name="RedKeyCard2" parent="." instance=ExtResource("19_8fb73")]
position = Vector2(-824, -152)
[node name="AlarmManager" type="Node2D" parent="."]
script = ExtResource("25_rpwvt")

View file

@ -1,16 +1,34 @@
using Godot;
using System;
using Cirno.Scripts;
public partial class Camera : Node2D
public partial class Camera : Enemy
{
private AnimatedSprite2D _sprite;
private GameManager _gameManager;
///private AlarmManager _alarmManager;
public override void _Ready()
{
base._Ready();
_gameManager = GetNode<GameManager>("/root/GameScene");
//_alarmManager = _gameManager.AlarmManager;
_sprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
_sprite.Play("full_scan");
}
protected override void Shoot()
{
_gameManager.AlarmManager.SoundAlarm(this.GlobalPosition);
}
}

32
Scripts/AlarmManager.cs Normal file
View file

@ -0,0 +1,32 @@
using Godot;
namespace Cirno.Scripts;
public partial class AlarmManager : Node2D
{
public bool IsAlarmOn { get; private set; } = false;
public Vector2 LastAlarmPosition { get; private set; } = new Vector2();
[Signal]
public delegate void AlarmEnabledEventHandler(Vector2 location);
[Signal]
public delegate void AlarmDisabledEventHandler();
public void SoundAlarm(Vector2 location)
{
if (IsAlarmOn) return;
IsAlarmOn = true;
LastAlarmPosition = location;
EmitSignal(nameof(AlarmEnabled), location);
GD.Print($"Alarm sounded at {location}");
}
public void DisableAlarm()
{
IsAlarmOn = false;
EmitSignal(nameof(AlarmDisabled));
}
}

View file

@ -26,31 +26,29 @@ public partial class Enemy : CharacterBody2D
private bool IsPlayerInRange => _playerDetection is { IsPlayerInRange: true };
private bool IsPlayerInSight => _playerDetection is not null && _playerDetection.IsPlayerInSight(CollisionMask);
private Vector2? _lastPlayerPosition = null;
[Export]
private PlayerDetection _playerDetection;
[Export]
private bool _navigationEnabled = false;
[Export] public bool NavigationEnabled { get; set; } = false;
public bool NavigationEnabled
{
get => _navigationEnabled && _navigationAgent != null;
set => _navigationEnabled = value;
}
// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
_currentHealth = Health;
_navigationAgent = GetNode<NavigationAgent2D>("NavigationAgent2D");
//var asdf = GetNode<ProximityPlayerDetection>("PlayerDetection");
//_playerDetection = GetNode<PlayerDetection>("PlayerDetection");
//CallDeferred("Setup");
_navigationAgent = GetNodeOrNull<NavigationAgent2D>("NavigationAgent2D");
}
// private void Setup()
// {
//
// }
// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
@ -90,41 +88,54 @@ public partial class Enemy : CharacterBody2D
{
_lastPlayerPosition = _playerDetection.CachedPlayer.GlobalPosition;
}
if (NavigationEnabled)
{
if (_lastPlayerPosition.HasValue)
{
_navigationAgent.SetTargetPosition(_lastPlayerPosition.Value);
}
var currentAgentPosition = GlobalPosition;
var nextPathPosition = _navigationAgent.GetNextPathPosition();
var newVelocity = currentAgentPosition.DirectionTo(nextPathPosition) * (float)(WalkSpeed * delta);
// Navigation is over, can do other things like shooting
if (_navigationAgent.IsNavigationFinished())
{
// Shoot player
if (IsPlayerInSight)
{
Shoot();
}
// TODO: If player totally left the max range it should stop shooting and go back to idle
return;
}
if (_navigationAgent.AvoidanceEnabled)
{
_navigationAgent.SetVelocity(newVelocity);
}
else
{
_on_navigation_agent_2d_velocity_computed(newVelocity);
}
if (_lastPlayerPosition.HasValue)
{
_navigationAgent.SetTargetPosition(_lastPlayerPosition.Value);
}
var currentAgentPosition = GlobalPosition;
var nextPathPosition = _navigationAgent.GetNextPathPosition();
var newVelocity = currentAgentPosition.DirectionTo(nextPathPosition) * (float)(WalkSpeed * delta);
// Navigation is over, can do other things like shooting
if (_navigationAgent.IsNavigationFinished())
{
// Shoot player
Shoot();
// TODO: If player totally left the max range it should stop shooting and go back to idle
return;
}
if (_navigationAgent.AvoidanceEnabled)
{
_navigationAgent.SetVelocity(newVelocity);
MoveAndSlide();
}
else
{
_on_navigation_agent_2d_velocity_computed(newVelocity);
if (IsPlayerInSight)
{
Shoot();
}
}
MoveAndSlide();
break;
case EnemyState.Patrolling:
@ -140,96 +151,15 @@ public partial class Enemy : CharacterBody2D
}
// private void HandlePlayerDetection()
// {
// if (_cachedPlayer == null)
// {
// return;
// }
//
// if (IsPlayerInSight())
// {
// // Update player position only if player is in sight
// // if (NavigationEnabled)
// // {
// // _navigationAgent.SetTargetPosition(_cachedPlayer.GlobalPosition);
// // }
// //Shoot();
//
// _currentState = EnemyState.Alert;
// }
// }
private void Shoot()
protected virtual void Shoot()
{
if (EquippedWeapon == null || !_lastPlayerPosition.HasValue) return;
// Shoot at the player's last known position
EquippedWeapon.ShootDirection = (_lastPlayerPosition.Value - this.GlobalPosition).Normalized();
EquippedWeapon.Shoot();
// // SHOOT
// var bullet = this.CreateChild<Bullet>(BulletScene);
// // var bullet = BulletScene.Instantiate<Bullet>();
// // Owner.AddChild(bullet);
// // bullet.Transform = this.GlobalTransform;
// // bullet.Position = this.Position;
// bullet.SetDirection((_cachedPlayer.GlobalPosition - this.GlobalPosition).Normalized());
// bullet.Speed = BulletSpeed;
//
// _ammo -= 1;
//
// if (_ammo <= 0)
// {
// _ammo = BulletCount;
// _cooldownTimer.Start(ReloadTime);
// }
// else
// {
// _cooldownTimer.Start(RateOfFire);
// }
}
// private bool IsPlayerInSight()
// {
// var spaceState = GetWorld2D().DirectSpaceState;
// var query = PhysicsRayQueryParameters2D.Create(this.GlobalPosition, _cachedPlayer.GlobalPosition, CollisionMask, new Godot.Collections.Array<Rid> { GetRid() });
// var result = spaceState.IntersectRay(query);
//
// // If count is 0 then the player is in sight, otherwise there is level geometry in the way
// return result.Count == 0;
//
// // if (result.Count > 0)
// // GD.Print("Hit at point: ", result["position"]);
// }
// private void _on_player_detection_area_entered(Area2D area)
// {
// // Assume area is player for now
// if (area is InteractionController player)
// {
// Debug.WriteLine("Enemy detection area Entered by interaction controller");
//
// _cachedPlayer = player;
//
// _isPlayerInRange = true;
// // if (_currentState is EnemyState.Idle)
// // {
// // _currentState = EnemyState.Primed;
// // }
// }
// }
//
// private void _on_player_detection_area_exited(Area2D area)
// {
// _isPlayerInRange = false;
//
// // if (_currentState is EnemyState.Primed)
// // {
// // _currentState = EnemyState.Idle;
// // }
// }
private void _on_damage_hitbox_area_entered(Area2D area)
{

View file

@ -17,8 +17,12 @@ public partial class GameManager : Node2D
public Marker2D PlayerSpawnMarker { get; set; }
private InventoryManager _inventoryManager { get; set; }
private AlarmManager _alarmManager { get; set; }
public InventoryManager Inventory => _inventoryManager;
public AlarmManager AlarmManager => _alarmManager;
private Node2D _bulletsContainer;
public Node2D BulletsContainer => _bulletsContainer;
@ -31,6 +35,8 @@ public partial class GameManager : Node2D
_inventoryManager = GetNode<InventoryManager>("InventoryManager");
_alarmManager = GetNode<AlarmManager>("AlarmManager");
SpawnBulletsContainer();
if (PlayerSpawnMarker != null)

View file

@ -0,0 +1,49 @@
using Godot;
namespace Cirno.Scripts.Interactables;
public partial class AlarmBox : Interactable
{
private GameManager _gameManager;
private AnimatedSprite2D _sprite;
public override void _Ready()
{
base._Ready();
_gameManager = GetNode<GameManager>("/root/GameScene");
_sprite = GetNode<AnimatedSprite2D>("AnimatedSprite2D");
_gameManager.AlarmManager.AlarmEnabled += AlarmManagerOnAlarmEnabled;
_gameManager.AlarmManager.AlarmDisabled += AlarmManagerOnAlarmDisabled;
}
private void AlarmManagerOnAlarmDisabled()
{
GD.Print("Playing disabled alarm");
_sprite.Play("default");
}
private void AlarmManagerOnAlarmEnabled(Vector2 location)
{
GD.Print("Playing enabled alarm");
_sprite.Play("alarmed");
}
public override bool Activate()
{
if (MeetsRequirements() && _gameManager.AlarmManager.IsAlarmOn)
{
_gameManager.AlarmManager.DisableAlarm();
// disable alarm
GD.Print("Alarm disabled");
return true;
}
return false;
}
}

BIN
Sprites/AlarmBox.aseprite (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Sprites/AlarmBox.png (Stored with Git LFS) Normal file

Binary file not shown.

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bpc66amnvvkrn"
path="res://.godot/imported/AlarmBox.png-da592e01763f275e2bad76c6462ad1e5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sprites/AlarmBox.png"
dest_files=["res://.godot/imported/AlarmBox.png-da592e01763f275e2bad76c6462ad1e5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1