Исправлена логика шипов

This commit is contained in:
Евгений Титаренко 2023-08-19 12:06:48 +03:00
parent 1fe08a596d
commit 4dbcb00029
2 changed files with 56 additions and 14 deletions

View file

@ -4,6 +4,8 @@ using System.Collections.Generic;
public partial class LivingArmor : CharacterBody2D
{
[Signal]
public delegate void KilledEventHandler();
public enum State
{
Waiting,
@ -21,6 +23,7 @@ public partial class LivingArmor : CharacterBody2D
[Export] public SideFace Facing = SideFace.Down;
[Export] public float MovingSpeed = 16f;
[Export] public bool IsAlive = true;
public State CurrentState
{
@ -82,6 +85,8 @@ public partial class LivingArmor : CharacterBody2D
public override void _PhysicsProcess(double delta)
{
if (!IsAlive)
return;
_timeSinceState += (float)delta;
switch (_state)
@ -240,5 +245,15 @@ public partial class LivingArmor : CharacterBody2D
}
_bodiesInSight.Remove(body);
}
public void Kill(Node2D killer)
{
if (!IsAlive)
return;
GD.Print($"{this.Name} was killed by {killer.Name}");
IsAlive = false;
EmitSignal(SignalName.Killed);
QueueFree(); // TODO
}
}