Воскрешение доспехов при их смерти

This commit is contained in:
Евгений Титаренко 2023-08-19 12:24:17 +03:00
parent 4dbcb00029
commit 619ed0c88e
2 changed files with 6 additions and 9 deletions

View file

@ -27,7 +27,7 @@ light_mode = 2
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"]
shader = ExtResource("5_64d71")
[sub_resource type="ViewportTexture" id="ViewportTexture_1dtfl"]
[sub_resource type="ViewportTexture" id="ViewportTexture_pym12"]
viewport_path = NodePath("FlashlightViewport")
[sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"]
@ -123,7 +123,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_1dtfl")
texture = SubResource("ViewportTexture_pym12")
script = ExtResource("6_slohe")
LightViewport = NodePath("../../FlashlightViewport")

View file

@ -23,7 +23,6 @@ public partial class LivingArmor : CharacterBody2D
[Export] public SideFace Facing = SideFace.Down;
[Export] public float MovingSpeed = 16f;
[Export] public bool IsAlive = true;
public State CurrentState
{
@ -54,10 +53,12 @@ public partial class LivingArmor : CharacterBody2D
private readonly List<Node2D> _bodiesInSight = new List<Node2D>();
private readonly List<Node2D> _bodiesNearBy = new List<Node2D>();
private Node2D _target = null;
private Vector2 _respawnPosition;
public override void _Ready()
{
_sprite = (AnimatedSprite2D)FindChild("AnimatedSprite2D");
_respawnPosition = Position;
CurrentState = State.Waiting;
var animationName = "side_walk";
switch (Facing)
@ -85,8 +86,6 @@ public partial class LivingArmor : CharacterBody2D
public override void _PhysicsProcess(double delta)
{
if (!IsAlive)
return;
_timeSinceState += (float)delta;
switch (_state)
@ -248,12 +247,10 @@ public partial class LivingArmor : CharacterBody2D
public void Kill(Node2D killer)
{
if (!IsAlive)
return;
GD.Print($"{this.Name} was killed by {killer.Name}");
IsAlive = false;
EmitSignal(SignalName.Killed);
QueueFree(); // TODO
Position = _respawnPosition;
// QueueFree(); // TODO
}
}