60 lines
1.3 KiB
C#
60 lines
1.3 KiB
C#
using System.Collections.Generic;
|
|
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 Path2D _predictionPath;
|
|
public Commander _commanderOwner;
|
|
|
|
public override void _Ready()
|
|
{
|
|
base._Ready();
|
|
_predictionPath = GetNode<Path2D>("PredictedPath");
|
|
}
|
|
|
|
public override void _PhysicsProcess(double delta)
|
|
{
|
|
base._PhysicsProcess(delta);
|
|
if (_speed != Vector2.Zero){
|
|
ApplyCentralImpulse(_speed);
|
|
_speed = Vector2.Zero;
|
|
}
|
|
}
|
|
|
|
public void DrawPath(List<Vector2> POINTS)
|
|
{
|
|
_predictionPath.Curve.ClearPoints();
|
|
for (int i = 0; i < POINTS.Count; i++)
|
|
{
|
|
_predictionPath.Curve.AddPoint(POINTS[i]);
|
|
}
|
|
}
|
|
|
|
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;
|
|
}
|
|
}
|