adding in some example pegs and their actions. organizing folders, still working on pathing for some reason it won't move sometimes, and causes the looping to break
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Generic;
|
||||
using Godot;
|
||||
|
||||
public partial class Ball : RigidBody2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void HitEventHandler(Node NODE);
|
||||
[Signal]
|
||||
public delegate void BucketEnteredEventHandler();
|
||||
|
||||
public bool _hovered = false;
|
||||
public int _healthChange = -1, _hits = 0;
|
||||
public Vector2 _speed;
|
||||
public Path2D _predictionPath;
|
||||
public Commander _commanderOwner;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
|
||||
_predictionPath = GetNode<Path2D>("PredictedPath");
|
||||
}
|
||||
|
||||
public void Act(Node BODY)
|
||||
{
|
||||
EmitSignal(SignalName.Hit, BODY);
|
||||
if (BODY is Peg peg)
|
||||
{
|
||||
peg.ChangeHealth(_healthChange, _commanderOwner);
|
||||
_hits++;
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user