43 lines
907 B
C#
43 lines
907 B
C#
using Godot;
|
|
|
|
public partial class Attack : RigidBody2D
|
|
{
|
|
[Signal]
|
|
public delegate void HitEventHandler(Node NODE);
|
|
|
|
public bool _hovered = false;
|
|
public int _damage = 1;
|
|
public Vector2 _speed;
|
|
public Commander _commanderOwner;
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
base._PhysicsProcess(delta);
|
|
if (_speed != Vector2.Zero){
|
|
ApplyCentralForce(_speed);
|
|
_speed = Vector2.Zero;
|
|
}
|
|
}
|
|
|
|
public void Shoot(Vector2 FORCE){
|
|
_speed = FORCE;
|
|
GravityScale = 1;
|
|
}
|
|
|
|
public void TakeAction(Node BODY)
|
|
{
|
|
EmitSignal(SignalName.Hit, BODY);
|
|
if (BODY is Enemy enemy)
|
|
{
|
|
enemy.TakeDamage(_damage, _commanderOwner);
|
|
}
|
|
}
|
|
|
|
public void OnMouseEntered(){
|
|
_hovered = true;
|
|
}
|
|
public void OnMouseExited(){
|
|
_hovered = true;
|
|
}
|
|
}
|