7-29-25 @ 2:57am
This commit is contained in:
@@ -10,36 +10,43 @@ public partial class Worker : Node2D
|
||||
public int _defense = 5, _defenseMax = 5;
|
||||
public CollisionShape2D _startArea;
|
||||
public TempBall _tempBall;
|
||||
public Ball _ball;
|
||||
public Ball _ball;
|
||||
|
||||
public static Worker _Create()
|
||||
{
|
||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/worker.tscn");
|
||||
Worker newWorker = scene.Instantiate<Worker>();
|
||||
return newWorker;
|
||||
}
|
||||
// public static Worker _Create()
|
||||
// {
|
||||
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/worker.tscn");
|
||||
// Worker newWorker = scene.Instantiate<Worker>();
|
||||
// return newWorker;
|
||||
// }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_ball = GetNode<Ball>("Ball");
|
||||
_tempBall = GetNode<TempBall>("TempBall");
|
||||
|
||||
|
||||
RemoveChild(_ball);
|
||||
RemoveChild(_tempBall);
|
||||
}
|
||||
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
_hovered = _ball._hovered || _tempBall._hovered;
|
||||
}
|
||||
|
||||
public virtual void ChangeBallPosition(Vector2 NEWPOSITION)
|
||||
public override void _Process(double delta)
|
||||
{
|
||||
RemoveChild(_ball);
|
||||
_ball.Position = NEWPOSITION;
|
||||
AddChild(_ball);
|
||||
_hovered = (_ball._active && _ball._hovered) || (_tempBall._active && _tempBall._hovered);
|
||||
if (_launched)
|
||||
{
|
||||
if (!_ball._launched)
|
||||
{
|
||||
_launched = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// public virtual void ChangeBallPosition(Vector2 NEWPOSITION)
|
||||
// {
|
||||
// RemoveChild(_ball);
|
||||
// _ball.Position = NEWPOSITION;
|
||||
// AddChild(_ball);
|
||||
// }
|
||||
|
||||
public virtual void ChangeDefense(int CHANGE)
|
||||
{
|
||||
_defense += CHANGE;
|
||||
@@ -47,14 +54,16 @@ public partial class Worker : Node2D
|
||||
if (_defense < 0)
|
||||
{
|
||||
EmitSignal(SignalName.DamageOverflow, _defense);
|
||||
if (!_isLead)
|
||||
{
|
||||
PotBall();
|
||||
}
|
||||
_defense = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void Launch()
|
||||
{
|
||||
_launched = true;
|
||||
_ball.Launch();
|
||||
}
|
||||
|
||||
public void SetSprite(string PATH)
|
||||
{
|
||||
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
||||
@@ -62,25 +71,55 @@ public partial class Worker : Node2D
|
||||
|
||||
public void PlaceBall(Vector2 POSITION)
|
||||
{
|
||||
_available = true;
|
||||
_placed = true;
|
||||
_potted = false;
|
||||
_ball.Position = POSITION;
|
||||
_ball._active = true;
|
||||
_ball._placed = true;
|
||||
_ball._potted = false;
|
||||
_ball._active = true;
|
||||
|
||||
AddChild(_ball);
|
||||
TempBallHide();
|
||||
}
|
||||
|
||||
public void PotBall()
|
||||
{
|
||||
_ball.Pot();
|
||||
_available = false;
|
||||
_placed = false;
|
||||
_potted = true;
|
||||
_ball.Sleeping = true;
|
||||
_ball._moving = false;
|
||||
_ball._active = false;
|
||||
_ball._placed = false;
|
||||
_ball._potted = true;
|
||||
_ball._active = false;
|
||||
|
||||
RemoveChild(_ball);
|
||||
TempBallShow();
|
||||
}
|
||||
|
||||
public void OnBallHit()
|
||||
public void TempBallHide()
|
||||
{
|
||||
// if (!_launched)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
// Ball target = (Ball)TARGET;
|
||||
// target.ChangeDefense(-1);
|
||||
// ChangeDefense(-6);
|
||||
// GD.Print("Defense: " + _defense);
|
||||
_tempBall._active = false;
|
||||
RemoveChild(_tempBall);
|
||||
}
|
||||
|
||||
public void TempBallShow()
|
||||
{
|
||||
_tempBall._active = true;
|
||||
AddChild(_tempBall);
|
||||
}
|
||||
|
||||
// Processes
|
||||
public virtual void ProcessOnCollision(Ball TARGET)
|
||||
{
|
||||
Worker TARGETWORKER = TARGET.GetParent<Worker>();
|
||||
if (_launched)
|
||||
{
|
||||
TARGETWORKER.ChangeDefense(-3);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user