two enemy types, ready to refactor
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using Movementtests.player_controller.Scripts;
|
||||
using Movementtests.interfaces;
|
||||
|
||||
|
||||
[GlobalClass]
|
||||
public partial class FirstEnemy : CharacterBody3D, ISpawnable
|
||||
public partial class FirstEnemy : CharacterBody3D, IDamageable, IKillable, IKnockbackable
|
||||
{
|
||||
[Export]
|
||||
public Node3D Target { get; set; }
|
||||
@@ -13,20 +13,18 @@ public partial class FirstEnemy : CharacterBody3D, ISpawnable
|
||||
public EnemyInitInputs Inputs;
|
||||
|
||||
private RayCast3D _wallInFrontRayCast;
|
||||
private Area3D _damageBox;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_wallInFrontRayCast = GetNode<RayCast3D>("WallInFrontRayCast");
|
||||
_damageBox = GetNode<Area3D>("DamageBox");
|
||||
_damageBox.BodyEntered += OnDamageBoxTriggered;
|
||||
}
|
||||
|
||||
public Resource GetSpawnInitResource()
|
||||
public void OnDamageBoxTriggered(Node3D body)
|
||||
{
|
||||
return Inputs;
|
||||
}
|
||||
|
||||
public void TestMethod()
|
||||
{
|
||||
GD.Print("I'm an enemy");
|
||||
if(body is IDamageable damageable) damageable.TakeDamage();
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double delta)
|
||||
@@ -49,4 +47,9 @@ public partial class FirstEnemy : CharacterBody3D, ISpawnable
|
||||
Velocity = velocity;
|
||||
MoveAndSlide();
|
||||
}
|
||||
|
||||
public void TakeDamage()
|
||||
{
|
||||
GD.Print("Emotional daaamaaage!");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user