7-28-25 @ 11:39pm

This commit is contained in:
2025-07-28 23:39:40 -04:00
parent f351f0ade9
commit 41b5c34e70
30 changed files with 669 additions and 402 deletions

View File

@@ -8,9 +8,9 @@ public partial class Battle : Node
public bool _current;
public Vector2 _startPosition = new Vector2(890, 340);
public Player _player;
public Player _computer;
public Player _turn;
public Manager _player;
public Manager _computer;
public Manager _turn;
public List<Sprite2D> _potted = new();
public List<Ball> _balls = new();
public Table _table;
@@ -20,9 +20,9 @@ public partial class Battle : Node
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/battle.tscn");
Battle newBattle = scene.Instantiate<Battle>();
Player newPlayer = Player._Create();
newBattle._player = newPlayer;
newBattle.AddChild(newPlayer);
Manager newManager = Manager._Create();
newBattle._player = newManager;
newBattle.AddChild(newManager);
Table newTable = Table._Create();
newTable.Position = Globals.Instance._screenCenter;
@@ -34,7 +34,7 @@ public partial class Battle : Node
.ToList<Area2D>();
for (int i = 0; i < pockets.Count; i++)
{
pockets[i].BodyEntered += newBattle.PottedBall;
pockets[i].BodyEntered += newBattle.PotBall;
}
newBattle.AddChild(newTable);
@@ -42,7 +42,6 @@ public partial class Battle : Node
}
public override void _Ready()
{
_balls = GetTree().GetNodesInGroup("balls").Select(b => (Ball)b).ToList<Ball>();
Start();
}
@@ -62,8 +61,13 @@ public partial class Battle : Node
for (int j = 0; j <= columns; j++)
{
Vector2 position = new Vector2(table.GlobalPosition.X - (i * (diameter / 2)) + (j * (diameter)), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (i * diameter));
SupportBall ball = SupportBall._Create(count);
ball.Place(position);
Ball ball = Ball._Create();
ball.Position = position;
ball._placed = true;
ball._potted = false;
ball.GetNode<CollisionShape2D>("Bounds").Disabled = false;
ball.SetSprite("res://art/ball_"+count+".png");
_balls.Add(ball);
AddChild(ball);
count += 1;
@@ -75,7 +79,8 @@ public partial class Battle : Node
public void CheckMovement()
{
bool movementCheck = _balls.Any(b => b._moving && b._placed);
bool movementCheck = _balls.Any(b => b._moving);
if (movementCheck)
{
if (!Globals.Instance._anyMovement)
@@ -94,29 +99,23 @@ public partial class Battle : Node
}
}
}
public void PottedBall(Node2D BODY)
public void PotBall(Node2D BODY)
{
if (BODY.GetType() != typeof(Ball))
if (BODY is Ball)
{
return;
}
if (((Ball)BODY)._isCue)
{
((Ball)BODY)._potted = true;
((Ball)BODY)._placed = false;
}
else
{
// Panel pottedPanel = GetNode<Panel>("PottedPanel");
// Sprite2D ballSprite = new Sprite2D();
// AddChild(ballSprite);
// ballSprite.Texture = BODY.GetNode<Sprite2D>("Image").Texture;
// _potted.Add(ballSprite);
// ballSprite.Position = new Vector2(pottedPanel.Position.X + pottedPanel.Size.X / 2, pottedPanel.Position.Y + (50 * _potted.Count));
((Ball)BODY)._placed = false;
((Ball)BODY)._potted = true;
BODY.QueueFree();
Ball ball = (Ball)BODY;
if (ball.GetParentOrNull<Manager>() == _player)
{
_player.PotWorker(ball.GetParent<Worker>());
}
else
{
ball.Pot();
_balls.Remove(ball);
RemoveChild(ball);
ball.QueueFree();
}
}
}