Compare commits
No commits in common. "1fe08a596dd454e9a596f89b1b42accfb10c4ef9" and "b0caf9937384bdee34e097798788cff27157349e" have entirely different histories.
1fe08a596d
...
b0caf99373
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=7 format=3 uid="uid://bpusphyhhg074"]
|
[gd_scene load_steps=5 format=3 uid="uid://bpusphyhhg074"]
|
||||||
|
|
||||||
[ext_resource type="SpriteFrames" uid="uid://cw4pv1qucngxu" path="res://sprites/enemies/armor/living_armor.tres" id="1_j445m"]
|
[ext_resource type="SpriteFrames" uid="uid://cw4pv1qucngxu" path="res://sprites/enemies/armor/living_armor.tres" id="1_j445m"]
|
||||||
[ext_resource type="Script" path="res://scripts/enemies/LivingArmor.cs" id="1_ofbsx"]
|
[ext_resource type="Script" path="res://scripts/enemies/LivingArmor.cs" id="1_ofbsx"]
|
||||||
|
@ -7,17 +7,10 @@
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_d1ojb"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_d1ojb"]
|
||||||
size = Vector2(15, 15)
|
size = Vector2(15, 15)
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_ex1co"]
|
|
||||||
radius = 150.0
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_62y1x"]
|
|
||||||
radius = 15.0
|
|
||||||
|
|
||||||
[node name="LivingArmor" type="CharacterBody2D"]
|
[node name="LivingArmor" type="CharacterBody2D"]
|
||||||
collision_layer = 5
|
collision_layer = 5
|
||||||
collision_mask = 5
|
collision_mask = 5
|
||||||
script = ExtResource("1_ofbsx")
|
script = ExtResource("1_ofbsx")
|
||||||
MovingSpeed = 35.0
|
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = ExtResource("1_j445m")
|
sprite_frames = ExtResource("1_j445m")
|
||||||
|
@ -35,21 +28,5 @@ polygon = PackedVector2Array(-7, -4, -7, 15, 8, 15, 8, -4, 5, -11, -4, -11)
|
||||||
position = Vector2(0.5, 7.5)
|
position = Vector2(0.5, 7.5)
|
||||||
shape = SubResource("RectangleShape2D_d1ojb")
|
shape = SubResource("RectangleShape2D_d1ojb")
|
||||||
|
|
||||||
[node name="AreaOfSight" type="Area2D" parent="."]
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="AreaOfSight"]
|
|
||||||
shape = SubResource("CircleShape2D_ex1co")
|
|
||||||
|
|
||||||
[node name="PlayerCollision" type="Area2D" parent="."]
|
|
||||||
monitorable = false
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerCollision"]
|
|
||||||
position = Vector2(1, 8)
|
|
||||||
shape = SubResource("CircleShape2D_62y1x")
|
|
||||||
|
|
||||||
[connection signal="area_entered" from="LightSense" to="." method="_OnLightEntered"]
|
[connection signal="area_entered" from="LightSense" to="." method="_OnLightEntered"]
|
||||||
[connection signal="area_exited" from="LightSense" to="." method="_OnLightExited"]
|
[connection signal="area_exited" from="LightSense" to="." method="_OnLightExited"]
|
||||||
[connection signal="body_entered" from="AreaOfSight" to="." method="_OnBodyEntered"]
|
|
||||||
[connection signal="body_exited" from="AreaOfSight" to="." method="_OnBodyExited"]
|
|
||||||
[connection signal="body_entered" from="PlayerCollision" to="." method="_OnPlayerCollision"]
|
|
||||||
[connection signal="body_exited" from="PlayerCollision" to="." method="_OnPlayerCollisionExited"]
|
|
||||||
|
|
|
@ -1,42 +0,0 @@
|
||||||
[gd_scene load_steps=6 format=3 uid="uid://bmyjqerhno5vi"]
|
|
||||||
|
|
||||||
[ext_resource type="SpriteFrames" uid="uid://blijqhtsnyq7n" path="res://sprites/enemies/wretched/wretched.tres" id="1_aqrsj"]
|
|
||||||
[ext_resource type="Script" path="res://scripts/enemies/Wretched.cs" id="1_ec388"]
|
|
||||||
[ext_resource type="PackedScene" uid="uid://cf0wpahgwygxx" path="res://prefabs/light_sense.tscn" id="2_16fib"]
|
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_svj4b"]
|
|
||||||
size = Vector2(24, 16)
|
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_nortt"]
|
|
||||||
radius = 15.0
|
|
||||||
|
|
||||||
[node name="Wretched" type="CharacterBody2D"]
|
|
||||||
collision_layer = 5
|
|
||||||
collision_mask = 5
|
|
||||||
script = ExtResource("1_ec388")
|
|
||||||
|
|
||||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
|
||||||
sprite_frames = ExtResource("1_aqrsj")
|
|
||||||
animation = &"NonActivatedUp"
|
|
||||||
frame_progress = 0.776966
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="AnimatedSprite2D"]
|
|
||||||
|
|
||||||
[node name="LightSense" parent="." instance=ExtResource("2_16fib")]
|
|
||||||
|
|
||||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="LightSense"]
|
|
||||||
polygon = PackedVector2Array(-5, -16, -7, -3, -7, 9, -11, 14, -11, 16, 8, 16, 8, 8, 7, 4, 7, -16)
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
|
||||||
position = Vector2(1, 8)
|
|
||||||
shape = SubResource("RectangleShape2D_svj4b")
|
|
||||||
|
|
||||||
[node name="PlayerCollision" type="Area2D" parent="."]
|
|
||||||
monitorable = false
|
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerCollision"]
|
|
||||||
position = Vector2(1, 8)
|
|
||||||
shape = SubResource("CircleShape2D_nortt")
|
|
||||||
|
|
||||||
[connection signal="area_entered" from="LightSense" to="." method="_OnLightEntered"]
|
|
||||||
[connection signal="body_entered" from="PlayerCollision" to="." method="_OnPlayerCollision"]
|
|
|
@ -1,7 +1,7 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://dqx43vr727ft8"]
|
[gd_scene load_steps=4 format=3 uid="uid://dqx43vr727ft8"]
|
||||||
|
|
||||||
[ext_resource type="Script" path="res://scripts/entities/Spikes.cs" id="1_r27mb"]
|
[ext_resource type="Script" path="res://scripts/entities/Spikes.cs" id="1_r27mb"]
|
||||||
[ext_resource type="SpriteFrames" uid="uid://uith5rxps4s" path="res://sprites/tiles/floor/spikes/spikes.tres" id="2_t76h0"]
|
[ext_resource type="SpriteFrames" uid="uid://0xgmr60v1vxg" path="res://sprites/tiles/floor/spikes/spikes.tres" id="2_t76h0"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_guqiy"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_guqiy"]
|
||||||
size = Vector2(32, 32)
|
size = Vector2(32, 32)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=27 format=3 uid="uid://dhn7yt46fyac8"]
|
[gd_scene load_steps=26 format=3 uid="uid://dhn7yt46fyac8"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://bhulqhxesd5gc" path="res://prefabs/player.tscn" id="1_65a7v"]
|
[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="AudioStream" uid="uid://bsy2d0bl3lgg0" path="res://sounds/crank.ogg" id="1_cweq4"]
|
||||||
|
@ -11,15 +11,14 @@
|
||||||
[ext_resource type="Script" path="res://scripts/GameCamera.cs" id="6_quua3"]
|
[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="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" uid="uid://ccg3n7sobsvdw" path="res://prefabs/enemies/watcher.tscn" id="10_fsiss"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bpusphyhhg074" path="res://prefabs/enemies/living_armor.tscn" id="11_x3ep3"]
|
[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://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="PackedScene" uid="uid://dqx43vr727ft8" path="res://prefabs/entities/spikes.tscn" id="13_w1hk1"]
|
||||||
[ext_resource type="Script" path="res://scripts/DeathScreen.cs" id="15_12mhe"]
|
[ext_resource type="Script" path="res://scripts/DeathScreen.cs" id="15_12mhe"]
|
||||||
[ext_resource type="PackedScene" uid="uid://bmyjqerhno5vi" path="res://prefabs/enemies/wretched.tscn" id="16_ejflu"]
|
|
||||||
|
|
||||||
[sub_resource type="Curve" id="Curve_o5byr"]
|
[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]
|
_data = [Vector2(0, 0), 0.0, 0.0, 0, 0, Vector2(0.0824742, 0.273684), -10.2105, 0.0, 0, 0, Vector2(0.242268, 0.494737), -5.10526, 0.0, 0, 0, Vector2(0.396907, 0.736842), -7.6579, 0.0, 0, 0, Vector2(0.737113, 1), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
|
||||||
point_count = 2
|
point_count = 6
|
||||||
|
|
||||||
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_wg1ao"]
|
[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_wg1ao"]
|
||||||
light_mode = 2
|
light_mode = 2
|
||||||
|
@ -27,7 +26,7 @@ light_mode = 2
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"]
|
||||||
shader = ExtResource("5_64d71")
|
shader = ExtResource("5_64d71")
|
||||||
|
|
||||||
[sub_resource type="ViewportTexture" id="ViewportTexture_1dtfl"]
|
[sub_resource type="ViewportTexture" id="ViewportTexture_psi2l"]
|
||||||
viewport_path = NodePath("FlashlightViewport")
|
viewport_path = NodePath("FlashlightViewport")
|
||||||
|
|
||||||
[sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"]
|
[sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"]
|
||||||
|
@ -123,7 +122,7 @@ CameraBounds = Vector2(30, 20)
|
||||||
[node name="PointLight2D" type="PointLight2D" parent="PlayerCamera" node_paths=PackedStringArray("LightViewport")]
|
[node name="PointLight2D" type="PointLight2D" parent="PlayerCamera" node_paths=PackedStringArray("LightViewport")]
|
||||||
blend_mode = 2
|
blend_mode = 2
|
||||||
range_item_cull_mask = 2
|
range_item_cull_mask = 2
|
||||||
texture = SubResource("ViewportTexture_1dtfl")
|
texture = SubResource("ViewportTexture_psi2l")
|
||||||
script = ExtResource("6_slohe")
|
script = ExtResource("6_slohe")
|
||||||
LightViewport = NodePath("../../FlashlightViewport")
|
LightViewport = NodePath("../../FlashlightViewport")
|
||||||
|
|
||||||
|
@ -196,6 +195,18 @@ position = Vector2(116, -76)
|
||||||
[node name="LivingArmor" parent="." instance=ExtResource("11_x3ep3")]
|
[node name="LivingArmor" parent="." instance=ExtResource("11_x3ep3")]
|
||||||
position = Vector2(-70, -67)
|
position = Vector2(-70, -67)
|
||||||
|
|
||||||
|
[node name="LivingArmor2" parent="." instance=ExtResource("11_x3ep3")]
|
||||||
|
position = Vector2(-86, -51)
|
||||||
|
Facing = 2
|
||||||
|
|
||||||
|
[node name="LivingArmor3" parent="." instance=ExtResource("11_x3ep3")]
|
||||||
|
position = Vector2(-54, -50)
|
||||||
|
Facing = 0
|
||||||
|
|
||||||
|
[node name="LivingArmor4" parent="." instance=ExtResource("11_x3ep3")]
|
||||||
|
position = Vector2(-70, -36)
|
||||||
|
Facing = 1
|
||||||
|
|
||||||
[node name="pressure_plate" parent="." instance=ExtResource("12_ynt5e")]
|
[node name="pressure_plate" parent="." instance=ExtResource("12_ynt5e")]
|
||||||
position = Vector2(31, 51)
|
position = Vector2(31, 51)
|
||||||
|
|
||||||
|
@ -216,10 +227,4 @@ Enabled = true
|
||||||
SpikesTimeout = 0.5
|
SpikesTimeout = 0.5
|
||||||
StartOffset = 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)
|
|
||||||
|
|
||||||
[connection signal="timeout" from="CanvasLayer/DeathScreen/Timer" to="CanvasLayer/DeathScreen" method="Timeout"]
|
[connection signal="timeout" from="CanvasLayer/DeathScreen/Timer" to="CanvasLayer/DeathScreen" method="Timeout"]
|
||||||
|
|
|
@ -10,6 +10,5 @@ public static class Constants
|
||||||
public const float MaxFlashlightDistance = 96;
|
public const float MaxFlashlightDistance = 96;
|
||||||
public const float MinFlashlightDistance = 16;
|
public const float MinFlashlightDistance = 16;
|
||||||
public const float MaxFlashlightEnergy = 100;
|
public const float MaxFlashlightEnergy = 100;
|
||||||
public const float FlashlightEnergyPerCharge = 40;
|
public const float FlashlightEnergyPerCharge = 5;
|
||||||
public const float FlashlightDischargeModifier = 10;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,7 +20,7 @@ public partial class Flashlight : Node
|
||||||
[Export] public AudioStreamPlayer CrankSoundPlayer;
|
[Export] public AudioStreamPlayer CrankSoundPlayer;
|
||||||
|
|
||||||
private float FlashlightRadius = Constants.MaxFlashlightRadius;
|
private float FlashlightRadius = Constants.MaxFlashlightRadius;
|
||||||
private float FlashlightEnergy = 0;
|
private float FlashlightEnergy = Constants.MaxFlashlightEnergy;
|
||||||
private float FlashlightChargeTimeout = 1;
|
private float FlashlightChargeTimeout = 1;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
|
@ -86,8 +86,7 @@ public partial class Flashlight : Node
|
||||||
CrankSoundPlayer.Play();
|
CrankSoundPlayer.Play();
|
||||||
}
|
}
|
||||||
|
|
||||||
FlashlightEnergy = Mathf.Clamp(FlashlightEnergy - (float)delta * Constants.FlashlightDischargeModifier,
|
FlashlightEnergy = Mathf.Clamp(FlashlightEnergy - (float)delta, 0, Constants.MaxFlashlightEnergy);
|
||||||
0, Constants.MaxFlashlightEnergy);
|
|
||||||
FlashlightGroup.Modulate =
|
FlashlightGroup.Modulate =
|
||||||
new Color(BrightnessCurve.Sample(FlashlightEnergy / Constants.MaxFlashlightEnergy), 1, 1, 1);
|
new Color(BrightnessCurve.Sample(FlashlightEnergy / Constants.MaxFlashlightEnergy), 1, 1, 1);
|
||||||
CollisionCircle.Disabled = CollisionPlayerCircle.Disabled = CollisionPolygon.Disabled = FlashlightEnergy < 10;
|
CollisionCircle.Disabled = CollisionPlayerCircle.Disabled = CollisionPolygon.Disabled = FlashlightEnergy < 10;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public partial class LivingArmor : CharacterBody2D
|
public partial class LivingArmor : CharacterBody2D
|
||||||
{
|
{
|
||||||
|
@ -10,7 +9,7 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
Moving,
|
Moving,
|
||||||
Attack
|
Attack
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SideFace
|
public enum SideFace
|
||||||
{
|
{
|
||||||
Left,
|
Left,
|
||||||
|
@ -18,10 +17,10 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
Right,
|
Right,
|
||||||
Down
|
Down
|
||||||
}
|
}
|
||||||
|
|
||||||
[Export] public SideFace Facing = SideFace.Down;
|
[Export] public SideFace Facing = SideFace.Down;
|
||||||
[Export] public float MovingSpeed = 16f;
|
[Export] public float MovingSpeed = 16f;
|
||||||
|
|
||||||
public State CurrentState
|
public State CurrentState
|
||||||
{
|
{
|
||||||
get => _state;
|
get => _state;
|
||||||
|
@ -47,11 +46,7 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
private float _timeSinceState;
|
private float _timeSinceState;
|
||||||
private AnimatedSprite2D _sprite;
|
private AnimatedSprite2D _sprite;
|
||||||
private bool _isLitUp;
|
private bool _isLitUp;
|
||||||
//private readonly List<WeakRef> _bodiesInSight = new List<WeakRef>();
|
|
||||||
private readonly List<Node2D> _bodiesInSight = new List<Node2D>();
|
|
||||||
private readonly List<Node2D> _bodiesNearBy = new List<Node2D>();
|
|
||||||
private Node2D _target = null;
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
||||||
|
@ -71,7 +66,6 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
animationName = "down_walk";
|
animationName = "down_walk";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
_sprite.Play(animationName);
|
_sprite.Play(animationName);
|
||||||
_sprite.Stop();
|
_sprite.Stop();
|
||||||
}
|
}
|
||||||
|
@ -93,42 +87,7 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State.Moving:
|
case State.Moving:
|
||||||
foreach (var body in _bodiesNearBy)
|
var direction = (Player.Instance.Position - Position).Normalized();
|
||||||
{
|
|
||||||
switch (body)
|
|
||||||
{
|
|
||||||
case Wretched wretched:
|
|
||||||
wretched.Kill(this);
|
|
||||||
break;
|
|
||||||
case Player player:
|
|
||||||
player.Kill(this);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SearchTarget();
|
|
||||||
switch (_target)
|
|
||||||
{
|
|
||||||
case Player player:
|
|
||||||
if (!player.Alive)
|
|
||||||
{
|
|
||||||
_bodiesInSight.Remove(player);
|
|
||||||
_target = null;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Wretched wretched:
|
|
||||||
if (!wretched.IsAlive)
|
|
||||||
{
|
|
||||||
_bodiesInSight.Remove(wretched);
|
|
||||||
_target = null;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (_target is null)
|
|
||||||
{
|
|
||||||
_state = State.Waiting;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var direction = (_target.Position - Position).Normalized();
|
|
||||||
Velocity = direction * MovingSpeed;
|
Velocity = direction * MovingSpeed;
|
||||||
|
|
||||||
var animationName = "side_walk";
|
var animationName = "side_walk";
|
||||||
|
@ -147,39 +106,9 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
//MoveAndCollide(direction);
|
//MoveAndCollide(direction);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckIfLitUp();
|
CheckIfLitUp();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SearchTarget()
|
|
||||||
{
|
|
||||||
float targetDistance = -1;
|
|
||||||
foreach (var body in _bodiesInSight)
|
|
||||||
{
|
|
||||||
var distance = (body.Position - Position).Length();
|
|
||||||
GD.Print($"{body.Name}");
|
|
||||||
switch (body)
|
|
||||||
{
|
|
||||||
case Wretched wretched:
|
|
||||||
if (targetDistance < 0 || targetDistance > distance)
|
|
||||||
{
|
|
||||||
targetDistance = distance;
|
|
||||||
_target = wretched;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case Player player:
|
|
||||||
|
|
||||||
if (_target is Wretched)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
_target = player;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _OnLightEntered(Area2D area)
|
private void _OnLightEntered(Area2D area)
|
||||||
{
|
{
|
||||||
if (area.GetParentOrNull<GameCamera>() is null)
|
if (area.GetParentOrNull<GameCamera>() is null)
|
||||||
|
@ -191,7 +120,13 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
|
|
||||||
private void _OnPlayerCollision(Node2D body)
|
private void _OnPlayerCollision(Node2D body)
|
||||||
{
|
{
|
||||||
_bodiesNearBy.Add(body);
|
if (body is not Player player)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (CurrentState is State.Waiting)
|
||||||
|
return;
|
||||||
|
|
||||||
|
player.Kill(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void _OnLightExited(Area2D area)
|
private void _OnLightExited(Area2D area)
|
||||||
|
@ -204,7 +139,6 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
|
|
||||||
private void _OnPlayerCollisionExited(Node2D body)
|
private void _OnPlayerCollisionExited(Node2D body)
|
||||||
{
|
{
|
||||||
_bodiesNearBy.Remove(body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CheckIfLitUp()
|
void CheckIfLitUp()
|
||||||
|
@ -214,31 +148,10 @@ public partial class LivingArmor : CharacterBody2D
|
||||||
CurrentState = State.Waiting;
|
CurrentState = State.Waiting;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CurrentState is State.Moving or State.Attack)
|
if (CurrentState is State.Moving or State.Attack)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CurrentState = State.Moving;
|
CurrentState = State.Moving;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void _OnBodyEntered(Node2D body)
|
|
||||||
{
|
|
||||||
if (body is not Wretched and not Player)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_bodiesInSight.Add(body);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void _OnBodyExited(Node2D body)
|
|
||||||
{
|
|
||||||
if (body is not Wretched and not Player)
|
|
||||||
return;
|
|
||||||
if (body == _target)
|
|
||||||
{
|
|
||||||
_target = null;
|
|
||||||
}
|
|
||||||
_bodiesInSight.Remove(body);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,161 +0,0 @@
|
||||||
using Godot;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
public partial class Wretched : CharacterBody2D
|
|
||||||
{
|
|
||||||
[Signal]
|
|
||||||
public delegate void KilledEventHandler();
|
|
||||||
|
|
||||||
public enum State
|
|
||||||
{
|
|
||||||
Waiting,
|
|
||||||
Moving,
|
|
||||||
Attack
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum SideFace
|
|
||||||
{
|
|
||||||
Left,
|
|
||||||
Up,
|
|
||||||
Right,
|
|
||||||
Down
|
|
||||||
}
|
|
||||||
|
|
||||||
[Export] public SideFace Facing = SideFace.Down;
|
|
||||||
[Export] public float MovingSpeed = 32f;
|
|
||||||
[Export] public bool IsAlive = true;
|
|
||||||
|
|
||||||
|
|
||||||
public State CurrentState
|
|
||||||
{
|
|
||||||
get => _state;
|
|
||||||
|
|
||||||
private set
|
|
||||||
{
|
|
||||||
_state = value;
|
|
||||||
_timeSinceState = 0;
|
|
||||||
|
|
||||||
switch (_state)
|
|
||||||
{
|
|
||||||
case State.Waiting:
|
|
||||||
break;
|
|
||||||
case State.Moving:
|
|
||||||
break;
|
|
||||||
case State.Attack:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private State _state;
|
|
||||||
private float _timeSinceState;
|
|
||||||
private AnimatedSprite2D _sprite;
|
|
||||||
private bool _isActivated;
|
|
||||||
|
|
||||||
public override void _Ready()
|
|
||||||
{
|
|
||||||
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
|
|
||||||
CurrentState = State.Waiting;
|
|
||||||
var animationName = "NonActivatedSide";
|
|
||||||
switch (Facing)
|
|
||||||
{
|
|
||||||
case SideFace.Left:
|
|
||||||
_sprite.FlipH = true;
|
|
||||||
break;
|
|
||||||
case SideFace.Right:
|
|
||||||
break;
|
|
||||||
case SideFace.Up:
|
|
||||||
animationName = "NonActivatedUp";
|
|
||||||
break;
|
|
||||||
case SideFace.Down:
|
|
||||||
animationName = "NonActivatedDown";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
_sprite.Play(animationName);
|
|
||||||
_sprite.Stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Process(double delta)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _PhysicsProcess(double delta)
|
|
||||||
{
|
|
||||||
if (!IsAlive)
|
|
||||||
return;
|
|
||||||
_timeSinceState += (float)delta;
|
|
||||||
|
|
||||||
switch (_state)
|
|
||||||
{
|
|
||||||
case State.Attack:
|
|
||||||
break;
|
|
||||||
case State.Waiting:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case State.Moving:
|
|
||||||
var direction = (Player.Instance.Position - Position).Normalized();
|
|
||||||
Velocity = direction * MovingSpeed;
|
|
||||||
|
|
||||||
var animationName = "ActivatedSide";
|
|
||||||
|
|
||||||
if (Velocity.Y > 0.001f)
|
|
||||||
animationName = "ActivatedDown";
|
|
||||||
else if (Velocity.Y < 0.001f)
|
|
||||||
animationName = "ActivatedUp";
|
|
||||||
|
|
||||||
if (Mathf.Abs(Velocity.X) >= Mathf.Abs(Velocity.Y))
|
|
||||||
animationName = "ActivatedSide";
|
|
||||||
|
|
||||||
_sprite.FlipH = Velocity.X < 0.001f && animationName == "ActivatedSide";
|
|
||||||
_sprite.Play(animationName);
|
|
||||||
MoveAndSlide();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
CheckIfLitUp();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void _OnLightEntered(Area2D area)
|
|
||||||
{
|
|
||||||
if (area.GetParentOrNull<GameCamera>() is null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
_isActivated = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void _OnPlayerCollision(Node2D body)
|
|
||||||
{
|
|
||||||
if (body is not Player player)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (CurrentState is State.Waiting)
|
|
||||||
return;
|
|
||||||
|
|
||||||
player.Kill(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CheckIfLitUp()
|
|
||||||
{
|
|
||||||
if (!_isActivated)
|
|
||||||
{
|
|
||||||
CurrentState = State.Waiting;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CurrentState is State.Moving or State.Attack)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CurrentState = State.Moving;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Kill(Node2D killer)
|
|
||||||
{
|
|
||||||
if (!IsAlive)
|
|
||||||
return;
|
|
||||||
|
|
||||||
GD.Print($"{this.Name} was killed by {killer.Name}");
|
|
||||||
IsAlive = false;
|
|
||||||
EmitSignal(SignalName.Killed);
|
|
||||||
QueueFree(); // TODO
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -58,19 +58,13 @@ public partial class Spikes : Area2D
|
||||||
|
|
||||||
private void _OnEntered(Node2D body)
|
private void _OnEntered(Node2D body)
|
||||||
{
|
{
|
||||||
|
if (body is not Player player)
|
||||||
|
return;
|
||||||
|
|
||||||
if (_state is State.Waiting)
|
if (_state is State.Waiting)
|
||||||
return;
|
return;
|
||||||
switch (body)
|
|
||||||
{
|
player.Kill(this);
|
||||||
case Wretched wretched:
|
|
||||||
wretched.Kill(this);
|
|
||||||
break;
|
|
||||||
case Player player:
|
|
||||||
player.Kill(this);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,171 +0,0 @@
|
||||||
[gd_resource type="SpriteFrames" load_steps=23 format=3 uid="uid://blijqhtsnyq7n"]
|
|
||||||
|
|
||||||
[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"]
|
|
||||||
[ext_resource type="Texture2D" uid="uid://ceffjiq2vofiu" path="res://sprites/enemies/wretched/wretched_up.png" id="3_y353x"]
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_e1ng1"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(32, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_h7wwv"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(64, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d2riq"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(96, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j1sxl"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(128, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_1tjil"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(160, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qo1on"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(192, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gd2f2"]
|
|
||||||
atlas = ExtResource("2_8muft")
|
|
||||||
region = Rect2(32, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j1id5"]
|
|
||||||
atlas = ExtResource("2_8muft")
|
|
||||||
region = Rect2(64, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jujmv"]
|
|
||||||
atlas = ExtResource("2_8muft")
|
|
||||||
region = Rect2(96, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_5cpt1"]
|
|
||||||
atlas = ExtResource("2_8muft")
|
|
||||||
region = Rect2(128, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8hfxb"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(32, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_t3n7s"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(64, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_k755r"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(96, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_7cl4u"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(128, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3l3jb"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(160, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_xtic1"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(192, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_gj6u3"]
|
|
||||||
atlas = ExtResource("1_42h2f")
|
|
||||||
region = Rect2(0, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_8toq8"]
|
|
||||||
atlas = ExtResource("2_8muft")
|
|
||||||
region = Rect2(0, 0, 32, 32)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d30l2"]
|
|
||||||
atlas = ExtResource("3_y353x")
|
|
||||||
region = Rect2(0, 0, 32, 32)
|
|
||||||
|
|
||||||
[resource]
|
|
||||||
animations = [{
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_e1ng1")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_h7wwv")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_d2riq")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_j1sxl")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_1tjil")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_qo1on")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"ActivatedDown",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_gd2f2")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_j1id5")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_jujmv")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_5cpt1")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"ActivatedSide",
|
|
||||||
"speed": 6.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_8hfxb")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_t3n7s")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_k755r")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_7cl4u")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_3l3jb")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_xtic1")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"ActivatedUp",
|
|
||||||
"speed": 6.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_gj6u3")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"NonActivatedDown",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_8toq8")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"NonActivatedSide",
|
|
||||||
"speed": 5.0
|
|
||||||
}, {
|
|
||||||
"frames": [{
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_d30l2")
|
|
||||||
}],
|
|
||||||
"loop": true,
|
|
||||||
"name": &"NonActivatedUp",
|
|
||||||
"speed": 5.0
|
|
||||||
}]
|
|
Before Width: | Height: | Size: 917 B After Width: | Height: | Size: 946 B |
Before Width: | Height: | Size: 833 B After Width: | Height: | Size: 862 B |
Before Width: | Height: | Size: 812 B After Width: | Height: | Size: 855 B |
Before Width: | Height: | Size: 946 B |
Before Width: | Height: | Size: 862 B |
Before Width: | Height: | Size: 855 B |