8-2-2025 @ 3:51 AM

This commit is contained in:
2025-08-02 03:51:34 -04:00
parent a8373726f9
commit 50e4f8fcb5
12 changed files with 348 additions and 86 deletions

View File

@@ -5,7 +5,6 @@ using System.Linq;
public partial class Battle : Node
{
public bool _current;
public Vector2 _startPosition = new Vector2(890, 340);
public Manager _turn;
@@ -73,51 +72,38 @@ public partial class Battle : Node
Globals.Instance._currentBattle = this;
// _player.Start();
int count = 1;
int columns = 0;
int diameter = 36;
Table table = GetNode<Table>("Table");
Ball eightBall = COMPUTER._balls[0];
List<Ball> computerBalls = COMPUTER._balls.Values.ToList();
computerBalls.RemoveAt(0);
Ball cueBall = PLAYER._balls[0];
List<Ball> playerBalls = PLAYER._balls.Values.ToList();
playerBalls.RemoveAt(0);
List<Ball> randomRack = new();
randomRack.AddRange(computerBalls);
randomRack.AddRange(playerBalls);
int n = randomRack.Count;
while (n > 1) {
n--;
int k = Globals.Instance._random.Next(n + 1);
Ball value = randomRack[k];
randomRack[k] = randomRack[n];
randomRack[n] = value;
}
randomRack.Insert(4, eightBall);
randomRack.Insert(0, cueBall);
List<Ball> computerBalls = COMPUTER._balls;
List<Ball> playerBalls = PLAYER._balls;
List<Ball> rack = new();
rack.AddRange(computerBalls);
rack.AddRange(playerBalls);
int rows = rack.Max(b => b._rackPosition.Y);
Ball rackBall;
for (int i = 0; i < 5; i++)
int r, c;
for (int i = 0; i < rack.Count; i++)
{
for (int j = 0; j <= columns; j++)
rackBall = rack[i];
c = rackBall._rackPosition.X;
r = Math.Abs(rackBall._rackPosition.Y - rows);
if (c > 0)
{
Vector2 position = new Vector2(table.GlobalPosition.X - (i * (diameter / 2)) + (j * (diameter)), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (i * diameter));
rackBall = randomRack[count];
if (PLAYER._balls.ContainsValue(rackBall))
Vector2 position = new Vector2(table.GlobalPosition.X - (r * (diameter / 2)) + ((c - 1) * diameter), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (r * diameter));
if (PLAYER._id == rackBall._ownerId)
{
PLAYER.PlaceBall(rackBall, position);
}
if (COMPUTER._balls.ContainsValue(rackBall))
if (COMPUTER._id == rackBall._ownerId)
{
COMPUTER.PlaceBall(rackBall, position);
}
count += 1;
}
columns += 1;
}
// PLAYER.PotBall();
}
}