Files
peggle-roguelike/Attack.cs
T

68 lines
1.5 KiB
C#

using System.Collections.Generic;
using Godot;
public partial class Attack : RigidBody2D
{
[Signal]
public delegate void HitEventHandler(Node NODE);
[Signal]
public delegate void BucketEnteredEventHandler();
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){
LinearVelocity = _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 EnteredBucket()
{
EmitSignal(SignalName.BucketEntered);
}
public void Shoot(Vector2 FORCE){
_speed = FORCE;
GravityScale = 1;
}
public void TakeAction(Node BODY)
{
EmitSignal(SignalName.Hit, BODY);
if (BODY is Peg peg)
{
peg.TakeDamage(_damage, _commanderOwner);
}
}
public void OnMouseEntered(){
_hovered = true;
}
public void OnMouseExited(){
_hovered = true;
}
}