7-17-25 @ 3:55am

This commit is contained in:
2025-07-17 03:55:30 -04:00
parent c5795028f0
commit 3884c07811
23 changed files with 371 additions and 103 deletions

View File

@@ -9,24 +9,41 @@ 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 List<Sprite2D> _potted = new();
public List<Ball> _balls;
public override void _Ready()
public List<Ball> _balls = new();
public Table _table;
public static Battle _Create()
{
_player = GetNode<Player>("Player");
Start();
List<Area2D> pockets = GetNode<Table>("Table").GetChildren()
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/battle.tscn");
Battle newBattle = scene.Instantiate<Battle>();
Player newPlayer = Player._Create();
newBattle._player = newPlayer;
newBattle.AddChild(newPlayer);
Table newTable = Table._Create();
newTable.Position = Globals.Instance._screenCenter;
newBattle._table = newTable;
List<Area2D> pockets = newBattle._table.GetChildren()
.Where(n => n.GetName().ToString().ToLower().Contains("pocket"))
.Select(n => (Area2D)n)
.ToList<Area2D>();
for (int i = 0; i < pockets.Count; i++)
{
pockets[i].BodyEntered += PottedBall;
pockets[i].BodyEntered += newBattle.PottedBall;
}
newBattle.AddChild(newTable);
return newBattle;
}
public override void _Ready()
{
_balls = GetTree().GetNodesInGroup("balls").Select(b => (Ball)b).ToList<Ball>();
Start();
}
public override void _Process(double DELTA_)
@@ -37,21 +54,22 @@ public partial class Battle : Node
public void GenerateBalls()
{
int count = 1;
int rows = 5;
int columns = 0;
int diameter = 36;
Table table = GetNode<Table>("Table");
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < rows; j++)
for (int j = 0; j <= columns; j++)
{
Vector2 position = new Vector2(250 + (i*(diameter)), 267 + (j*(diameter)) + (i*(diameter / 2)));
Ball ball = Ball.Create("ball", count);
Vector2 position = new Vector2(table.GlobalPosition.X - (i * (diameter / 2)) + (j * (diameter)), table.GlobalPosition.Y - table.Texture.GetSize().Y / 4 - (i * diameter));
Ball ball = Ball._Create(count);
ball.Place(position);
AddChild(ball);
count += 1;
}
rows -= 1;
columns += 1;
}
}
@@ -83,10 +101,10 @@ public partial class Battle : Node
{
return;
}
if (BODY == _player._actor._selectedBall)
if (BODY == _player._selectedActor._selectedBall)
{
_player._actor._selectedBall._potted = true;
_player._actor._selectedBall._placed = false;
_player._selectedActor._selectedBall._potted = true;
_player._selectedActor._selectedBall._placed = false;
}
else
{