Tuesday, 05 August 2025 01:43:58
This commit is contained in:
@@ -7,104 +7,27 @@ public partial class Battle : Node
|
||||
{
|
||||
public bool _current;
|
||||
public Vector2 _startPosition = new Vector2(890, 340);
|
||||
public Manager _turn;
|
||||
public List<Sprite2D> _potted = new();
|
||||
public List<Ball> _balls = new();
|
||||
public Table _table;
|
||||
|
||||
public List<Pocket> _pockets = new();
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
_table = GetNode<Table>("Table");
|
||||
_pockets = _table.GetNode<Node2D>("Pockets").GetChildren().Select(n => (Pocket)n).ToList();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
CheckMovement();
|
||||
}
|
||||
|
||||
|
||||
public void CheckMovement()
|
||||
{
|
||||
bool movementCheck = _balls.Any(b => b._moving);
|
||||
|
||||
if (movementCheck)
|
||||
{
|
||||
if (!Globals.Instance._anyMovement)
|
||||
{
|
||||
Globals.Instance._anyMovement = true;
|
||||
//EmitSignal(SignalName.DetectMovement, true);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Globals.Instance._anyMovement)
|
||||
{
|
||||
Globals.Instance._anyMovement = false;
|
||||
//EmitSignal(SignalName.DetectMovement, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// public void PotBall(Node2D BODY)
|
||||
// {
|
||||
// if (BODY is Ball)
|
||||
// {
|
||||
// Ball ball = (Ball)BODY;
|
||||
// if (ball.GetParentOrNull<Manager>() == _player)
|
||||
// {
|
||||
// // _player.PotWorker(ball.GetParent<Worker>());
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// ball.Pot();
|
||||
// _balls.Remove(ball);
|
||||
// RemoveChild(ball);
|
||||
// ball.QueueFree();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public void Start(PlayerManager PLAYER, ComputerManager COMPUTER)
|
||||
public void Start()
|
||||
{
|
||||
// _current = true;
|
||||
// // GenerateBalls();
|
||||
_current = true;
|
||||
Globals.Instance._currentBattle = this;
|
||||
// _player.Start();
|
||||
|
||||
int diameter = 36;
|
||||
Table table = GetNode<Table>("Table");
|
||||
|
||||
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;
|
||||
int r, c;
|
||||
for (int i = 0; i < rack.Count; i++)
|
||||
{
|
||||
rackBall = rack[i];
|
||||
c = rackBall._rackPosition.X;
|
||||
r = Math.Abs(rackBall._rackPosition.Y - rows);
|
||||
if (c > 0)
|
||||
{
|
||||
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 == rackBall._owner)
|
||||
{
|
||||
PLAYER.PlaceBall(rackBall, position);
|
||||
}
|
||||
if (COMPUTER == rackBall._owner)
|
||||
{
|
||||
COMPUTER.PlaceBall(rackBall, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
// PLAYER.PotBall();
|
||||
PLAYER.SetRack();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class ComputerManager : Manager
|
||||
{
|
||||
public List<Vector2I> _initialRackPositions =
|
||||
[
|
||||
new Vector2I(2, 3),
|
||||
new Vector2I(2, 1),
|
||||
new Vector2I(5, 1),
|
||||
new Vector2I(1, 2),
|
||||
new Vector2I(3, 2),
|
||||
new Vector2I(3, 3),
|
||||
new Vector2I(1, 4),
|
||||
new Vector2I(1, 5)
|
||||
];
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
Ball newBall;
|
||||
BallSprite newBallSprite;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/ball_" + (i+8) + ".png");
|
||||
newBall._rackPosition = _initialRackPositions[i];
|
||||
newBall._owner = this;
|
||||
_balls.Add(newBall);
|
||||
|
||||
newBallSprite = _ballSpriteScene.Instantiate<BallSprite>();
|
||||
newBallSprite.SetSprite(newBall._imagePath);
|
||||
newBallSprite._rackPosition = _initialRackPositions[i];
|
||||
newBallSprite._owner = this;
|
||||
_ballSprites.Add(newBallSprite);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://d03s3a1jvn6cn
|
||||
@@ -4,18 +4,13 @@ using System;
|
||||
public partial class Cue : Sprite2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void ShootEventHandler(Vector2 IMPULSE);
|
||||
public delegate void OnShootEventHandler(Vector2 IMPULSE);
|
||||
|
||||
public bool _donned = false, _equiped = false, _sending = false;
|
||||
public float _power = 0.0f, _maxPower = 20.0f;
|
||||
Vector2 _direction;
|
||||
public ProgressBar _progressBar;
|
||||
|
||||
public Cue()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
|
||||
@@ -52,7 +47,7 @@ public partial class Cue : Sprite2D
|
||||
{
|
||||
_sending = false;
|
||||
Offset = Vector2.Zero;
|
||||
EmitSignal(SignalName.Shoot, _power * _direction);
|
||||
EmitSignal(SignalName.OnShoot, _power * _direction);
|
||||
_power = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ using System;
|
||||
public partial class Main : Node
|
||||
{
|
||||
public Battle _currentBattle;
|
||||
public PlayerManager _player;
|
||||
public ComputerManager _computer;
|
||||
public Manager _player;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
@@ -13,14 +12,10 @@ public partial class Main : Node
|
||||
Globals.Instance._screenCenter = new Vector2(Globals.Instance._screenSize.X / 2, Globals.Instance._screenSize.Y / 2);
|
||||
|
||||
_currentBattle = GetNode<Battle>("Battle");
|
||||
_player = GetNode<PlayerManager>("Player");
|
||||
_computer = GetNode<ComputerManager>("Computer");
|
||||
_player._opponent = _computer;
|
||||
_computer._opponent = _player;
|
||||
_player = GetNode<Manager>("Player");
|
||||
|
||||
_currentBattle.Start(_player, _computer);
|
||||
_player.Start();
|
||||
_computer.Start();
|
||||
_currentBattle.Start();
|
||||
_player.Start(_currentBattle.GetNode<Table>("Table"));
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
|
||||
@@ -9,14 +9,39 @@ public partial class Manager : Node
|
||||
public bool _dead, _ready;
|
||||
public int _ballsMoving = 0, _health = 10, _healthMax, _placeLimit = 8;
|
||||
public string _imagePath;
|
||||
public Node _hoveredNode = null;
|
||||
public Node _selectedNode = null;
|
||||
public CollisionShape2D _startArea;
|
||||
public Cue _cue;
|
||||
public Manager _opponent;
|
||||
public ManagerPanel _managerPanel = null;
|
||||
public BallReturn _ballReturn = null;
|
||||
public Rack _rack = null;
|
||||
public List<Ball> _balls = new();
|
||||
public List<BallSprite> _ballSprites = new();
|
||||
public List<Worker> _workers = new();
|
||||
|
||||
public List<Vector2I> _initialRackPositions =
|
||||
[
|
||||
new Vector2I(0, 1),
|
||||
new Vector2I(1, 1),
|
||||
new Vector2I(3, 1),
|
||||
new Vector2I(4, 1),
|
||||
new Vector2I(2, 2),
|
||||
new Vector2I(4, 2),
|
||||
new Vector2I(1, 3),
|
||||
new Vector2I(2, 4),
|
||||
new Vector2I(2, 3),
|
||||
new Vector2I(2, 1),
|
||||
new Vector2I(5, 1),
|
||||
new Vector2I(1, 2),
|
||||
new Vector2I(3, 2),
|
||||
new Vector2I(3, 3),
|
||||
new Vector2I(1, 4),
|
||||
new Vector2I(1, 5)
|
||||
];
|
||||
// denoted by c1r1 notation where (3,1) translates to row 1 column 3
|
||||
// column 0 represents the ball return where the row represents its order in the return,
|
||||
// (0,0) denotes a ball that is not on the screen
|
||||
// numbers should increase from top to bottom and left to right from the player's perspective
|
||||
|
||||
// PACKED SCENES
|
||||
public PackedScene _ballScene = ResourceLoader.Load<PackedScene>("res://Gameplay/ball.tscn");
|
||||
@@ -24,12 +49,123 @@ public partial class Manager : Node
|
||||
public PackedScene _cueScene = ResourceLoader.Load<PackedScene>("res://Gameplay/cue.tscn");
|
||||
public PackedScene _workerScene = ResourceLoader.Load<PackedScene>("res://Gameplay/worker.tscn");
|
||||
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_healthMax = _health;
|
||||
_cue = GetNode<Cue>("Cue");
|
||||
_cue.OnShoot += OnCueShoot;
|
||||
_cue.Doff();
|
||||
|
||||
SetSprite("res://art/ness.png");
|
||||
|
||||
_managerPanel = GetNode<ManagerPanel>("Panel");
|
||||
_ballReturn = _managerPanel.GetNode<BallReturn>("BallReturn");
|
||||
_rack = _managerPanel.GetNode<Rack>("Rack");
|
||||
|
||||
Ball newBall;
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/cue_ball.png");
|
||||
newBall._rackPosition = _initialRackPositions[0];
|
||||
newBall._owner = this;
|
||||
newBall.OnHover += SetHovered;
|
||||
newBall.OnMovement += MovingChange;
|
||||
_balls.Add(newBall);
|
||||
|
||||
BallSprite newBallSprite;
|
||||
newBallSprite = _ballSpriteScene.Instantiate<BallSprite>();
|
||||
newBallSprite.SetSprite(newBall._imagePath);
|
||||
newBallSprite._rackPosition = _initialRackPositions[0];
|
||||
newBallSprite._owner = this;
|
||||
newBallSprite.OnHover += SetHovered;
|
||||
_ballSprites.Add(newBallSprite);
|
||||
|
||||
|
||||
for (int i = 1; i <= 15; i++)
|
||||
{
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/ball_" + i + ".png");
|
||||
newBall._rackPosition = _initialRackPositions[i];
|
||||
newBall._owner = this;
|
||||
newBall.OnHover += SetHovered;
|
||||
newBall.OnMovement += MovingChange;
|
||||
_balls.Add(newBall);
|
||||
|
||||
newBallSprite = _ballSpriteScene.Instantiate<BallSprite>();
|
||||
newBallSprite.SetSprite(newBall._imagePath);
|
||||
newBallSprite._rackPosition = _initialRackPositions[i];
|
||||
_rack.SetSprite((int)newBallSprite._rackPosition.Y, (int)newBallSprite._rackPosition.X, newBallSprite._imagePath);
|
||||
newBallSprite._owner = this;
|
||||
newBallSprite.OnHover += SetHovered;
|
||||
_ballSprites.Add(newBallSprite);
|
||||
}
|
||||
|
||||
_managerPanel.SetManager(this);
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
if (_ballsMoving == 0)
|
||||
{
|
||||
if (_ready)
|
||||
{
|
||||
if (_hoveredNode is Ball || _selectedNode is Ball)
|
||||
{
|
||||
if ((Ball)_selectedNode == null || ((Ball)_selectedNode != _hoveredNode && _hoveredNode is Ball))
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_selectedNode = (Ball)_hoveredNode;
|
||||
((Ball)_selectedNode)._selected = true;
|
||||
_cue.Don(((Ball)_selectedNode).Position);
|
||||
}
|
||||
}
|
||||
else if (Input.IsActionJustReleased("right_click"))
|
||||
{
|
||||
((Ball)_selectedNode)._selected = false;
|
||||
_selectedNode = null;
|
||||
_cue.Doff();
|
||||
}
|
||||
else if (_hoveredNode == null)
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click") && (Ball)_selectedNode != null && _cue._power == 0)
|
||||
{
|
||||
((Ball)_selectedNode)._selected = false;
|
||||
_selectedNode = null;
|
||||
_cue.Doff();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_hoveredNode is BallSprite || _selectedNode is BallSprite)
|
||||
{
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
Vector2 mousePosition = GetViewport().GetMousePosition();
|
||||
((BallSprite)_selectedNode).Position = mousePosition;
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
Ball ball = _balls.Single(b => b._rackPosition == ((BallSprite)_hoveredNode)._rackPosition);
|
||||
PlaceBall(ball, mousePosition);
|
||||
_hoveredNode = null;
|
||||
_selectedNode = null;
|
||||
if (_balls.Where(b => b._placed).ToList().Count >= _placeLimit)
|
||||
{
|
||||
_ready = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_selectedNode = (BallSprite)_hoveredNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ChangeHealth(int CHANGE)
|
||||
@@ -42,11 +178,25 @@ public partial class Manager : Node
|
||||
_dead = true;
|
||||
_health = 0;
|
||||
}
|
||||
|
||||
GetNode<ManagerPanel>("Panel").SetValue(_health);
|
||||
}
|
||||
|
||||
public void MovingChange(Ball BALL, bool MOVING)
|
||||
{
|
||||
if (MOVING)
|
||||
{
|
||||
_ballsMoving++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ballsMoving--;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void PlaceBall(Ball BALL, Vector2 POSITION)
|
||||
{
|
||||
|
||||
|
||||
BALL._available = true;
|
||||
BALL.Position = POSITION;
|
||||
BALL._active = true;
|
||||
@@ -54,12 +204,29 @@ public partial class Manager : Node
|
||||
BALL._potted = false;
|
||||
BALL._active = true;
|
||||
if (!GetChildren().Contains(BALL))
|
||||
{
|
||||
AddChild(BALL);
|
||||
}
|
||||
|
||||
BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition);
|
||||
|
||||
ballSprite._active = false;
|
||||
if (GetChildren().Contains(ballSprite))
|
||||
{
|
||||
AddChild(BALL);
|
||||
RemoveChild(ballSprite);
|
||||
}
|
||||
_ballReturn._returnCount = _balls.Where(b => b._potted).ToList().Count;
|
||||
if (_ballReturn._returnCount > 0)
|
||||
{
|
||||
_ready = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void PotBall(Ball BALL)
|
||||
public virtual void PotBall(Ball BALL, Pocket POCKET)
|
||||
{
|
||||
BALL.Sleeping = true;
|
||||
BALL._available = false;
|
||||
@@ -69,19 +236,94 @@ public partial class Manager : Node
|
||||
BALL._potted = true;
|
||||
BALL._active = false;
|
||||
if (GetChildren().Contains(BALL))
|
||||
{
|
||||
RemoveChild(BALL);
|
||||
}
|
||||
{
|
||||
RemoveChild(BALL);
|
||||
}
|
||||
|
||||
BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition);
|
||||
int pottedCount = _ballReturn._returnCount;
|
||||
ballSprite.Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (pottedCount + 1));
|
||||
ballSprite._active = true;
|
||||
if (!GetChildren().Contains(ballSprite))
|
||||
{
|
||||
CallDeferred(MethodName.AddChild, ballSprite);
|
||||
}
|
||||
_ballReturn._returnCount = _balls.Where(b => b._potted).ToList().Count;
|
||||
if (_ballReturn._returnCount > 0)
|
||||
{
|
||||
_ready = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ready = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetHovered(Node NODE, bool HOVERED)
|
||||
{
|
||||
if (HOVERED)
|
||||
{
|
||||
if (_hoveredNode == null)
|
||||
{
|
||||
if (NODE is Ball)
|
||||
{
|
||||
_hoveredNode = (Ball)NODE;
|
||||
}
|
||||
else if (NODE is BallSprite)
|
||||
{
|
||||
_hoveredNode = (BallSprite)NODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_hoveredNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRack()
|
||||
{
|
||||
for (int i = 0; i < _ballSprites.Count; i++)
|
||||
{
|
||||
if ((int)_ballSprites[i]._rackPosition.Y > 0 && (int)_ballSprites[i]._rackPosition.X > 0)
|
||||
{
|
||||
_rack.SetSprite((int)_ballSprites[i]._rackPosition.Y, (int)_ballSprites[i]._rackPosition.X, _ballSprites[i]._imagePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetSprite(string PATH)
|
||||
{
|
||||
_imagePath = PATH;
|
||||
}
|
||||
|
||||
public virtual void Start()
|
||||
public virtual void Start(Table TABLE)
|
||||
{
|
||||
|
||||
int diameter = 36;
|
||||
|
||||
int rows = _balls.Max(b => b._rackPosition.Y);
|
||||
|
||||
Ball rackBall;
|
||||
int r, c;
|
||||
for (int i = 0; i < _balls.Count; i++)
|
||||
{
|
||||
rackBall = _balls[i];
|
||||
c = rackBall._rackPosition.X;
|
||||
r = Math.Abs(rackBall._rackPosition.Y - rows);
|
||||
if (c > 0)
|
||||
{
|
||||
Vector2 position = new Vector2(TABLE.GlobalPosition.X - (r * (diameter / 2)) + ((c - 1) * diameter), TABLE.GlobalPosition.Y - TABLE.Texture.GetSize().Y / 4 - (r * diameter));
|
||||
|
||||
PlaceBall(rackBall, position);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
TABLE.OnBallPotted += PotBall;
|
||||
|
||||
// PLAYER.PotBall();
|
||||
SetRack();
|
||||
PotBall(_balls[0], null);
|
||||
}
|
||||
|
||||
private void OnCueShoot(Vector2 IMPULSE)
|
||||
@@ -95,7 +337,6 @@ public partial class Manager : Node
|
||||
selectedBall._selected = false;
|
||||
selectedBall.Launch();
|
||||
_selectedNode = null;
|
||||
selectedBall = null;
|
||||
_cue.Doff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,246 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
public partial class PlayerManager : Manager
|
||||
{
|
||||
public List<Vector2I> _initialRackPositions =
|
||||
[
|
||||
new Vector2I(0, 1),
|
||||
new Vector2I(1, 1),
|
||||
new Vector2I(3, 1),
|
||||
new Vector2I(4, 1),
|
||||
new Vector2I(2, 2),
|
||||
new Vector2I(4, 2),
|
||||
new Vector2I(1, 3),
|
||||
new Vector2I(2, 4)
|
||||
];
|
||||
// denoted by c1r1 notation where (3,1) translates to row 1 column 3
|
||||
// column 0 represents the ball return where the row represents its order in the return,
|
||||
// (0,0) denotes a ball that is not on the screen
|
||||
// numbers should increase from top to bottom and left to right from the player's perspective
|
||||
public Node _hoveredNode = null;
|
||||
public ManagerPanel _managerPanel = null;
|
||||
public BallReturn _ballReturn = null;
|
||||
public Rack _rack = null;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
base._Ready();
|
||||
SetSprite("res://art/ness.png");
|
||||
|
||||
_managerPanel = GetNode<ManagerPanel>("Panel");
|
||||
_ballReturn = _managerPanel.GetNode<BallReturn>("BallReturn");
|
||||
_rack = _managerPanel.GetNode<Rack>("Rack");
|
||||
|
||||
Ball newBall;
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/cue_ball.png");
|
||||
newBall._rackPosition = _initialRackPositions[0];
|
||||
newBall._owner = this;
|
||||
newBall.OnHover += SetHovered;
|
||||
newBall.OnMovement += MovingChange;
|
||||
_balls.Add(newBall);
|
||||
|
||||
BallSprite newBallSprite;
|
||||
newBallSprite = _ballSpriteScene.Instantiate<BallSprite>();
|
||||
newBallSprite.SetSprite(newBall._imagePath);
|
||||
newBallSprite._rackPosition = _initialRackPositions[0];
|
||||
newBallSprite._owner = this;
|
||||
newBallSprite.OnHover += SetHovered;
|
||||
_ballSprites.Add(newBallSprite);
|
||||
|
||||
|
||||
for (int i = 1; i <= 7; i++)
|
||||
{
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/ball_" + i + ".png");
|
||||
newBall._rackPosition = _initialRackPositions[i];
|
||||
newBall._owner = this;
|
||||
newBall.OnHover += SetHovered;
|
||||
newBall.OnMovement += MovingChange;
|
||||
_balls.Add(newBall);
|
||||
|
||||
newBallSprite = _ballSpriteScene.Instantiate<BallSprite>();
|
||||
newBallSprite.SetSprite(newBall._imagePath);
|
||||
newBallSprite._rackPosition = _initialRackPositions[i];
|
||||
_rack.SetSprite((int)newBallSprite._rackPosition.Y, (int)newBallSprite._rackPosition.X, newBallSprite._imagePath);
|
||||
newBallSprite._owner = this;
|
||||
newBallSprite.OnHover += SetHovered;
|
||||
_ballSprites.Add(newBallSprite);
|
||||
}
|
||||
|
||||
_managerPanel.SetManager(this);
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
if (_ballsMoving == 0 && _opponent._ballsMoving == 0)
|
||||
{
|
||||
if (_ready)
|
||||
{
|
||||
if (_hoveredNode is Ball || _selectedNode is Ball)
|
||||
{
|
||||
if ((Ball)_selectedNode == null || ((Ball)_selectedNode != _hoveredNode && _hoveredNode is Ball))
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_selectedNode = (Ball)_hoveredNode;
|
||||
((Ball)_selectedNode)._selected = true;
|
||||
_cue.Don(((Ball)_selectedNode).Position);
|
||||
}
|
||||
}
|
||||
else if (Input.IsActionJustReleased("right_click"))
|
||||
{
|
||||
((Ball)_selectedNode)._selected = false;
|
||||
_selectedNode = null;
|
||||
_cue.Doff();
|
||||
}
|
||||
else if (_hoveredNode == null)
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click") && (Ball)_selectedNode != null && _cue._power == 0)
|
||||
{
|
||||
((Ball)_selectedNode)._selected = false;
|
||||
_selectedNode = null;
|
||||
_cue.Doff();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_hoveredNode is BallSprite || _selectedNode is BallSprite)
|
||||
{
|
||||
|
||||
if (_selectedNode != null)
|
||||
{
|
||||
Vector2 mousePosition = GetViewport().GetMousePosition();
|
||||
((BallSprite)_selectedNode).Position = mousePosition;
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
Ball ball = _balls.Single(b => b._rackPosition == ((BallSprite)_hoveredNode)._rackPosition);
|
||||
PlaceBall(ball, mousePosition);
|
||||
_hoveredNode = null;
|
||||
_selectedNode = null;
|
||||
if (_balls.Where(b => b._placed).ToList().Count >= _placeLimit)
|
||||
{
|
||||
_ready = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_selectedNode = (BallSprite)_hoveredNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ChangeHealth(int CHANGE)
|
||||
{
|
||||
base.ChangeHealth(CHANGE);
|
||||
GetNode<ManagerPanel>("Panel").SetValue(_health);
|
||||
}
|
||||
|
||||
public void MovingChange(Ball BALL, bool MOVING)
|
||||
{
|
||||
if (MOVING)
|
||||
{
|
||||
_ballsMoving++;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ballsMoving--;
|
||||
}
|
||||
}
|
||||
|
||||
public override void PlaceBall(Ball BALL, Vector2 POSITION)
|
||||
{
|
||||
base.PlaceBall(BALL, POSITION);
|
||||
BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition);
|
||||
|
||||
ballSprite._active = false;
|
||||
if (GetChildren().Contains(ballSprite))
|
||||
{
|
||||
RemoveChild(ballSprite);
|
||||
}
|
||||
_ballReturn._returnCount = _balls.Where(b => b._potted).ToList().Count;
|
||||
}
|
||||
|
||||
public override void PotBall(Ball BALL)
|
||||
{
|
||||
base.PotBall(BALL);
|
||||
|
||||
BallSprite ballSprite = _ballSprites.Single(s => s._rackPosition == BALL._rackPosition);
|
||||
int pottedCount = _ballReturn._returnCount;
|
||||
ballSprite.Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (pottedCount + 1));
|
||||
|
||||
|
||||
ballSprite._active = true;
|
||||
if (!GetChildren().Contains(ballSprite))
|
||||
{
|
||||
AddChild(ballSprite);
|
||||
}
|
||||
_ballReturn._returnCount = _balls.Where(b=>b._potted).ToList().Count;
|
||||
}
|
||||
|
||||
public void SetHovered(Node NODE, bool HOVERED)
|
||||
{
|
||||
if (HOVERED)
|
||||
{
|
||||
if (_hoveredNode == null)
|
||||
{
|
||||
if (NODE is Ball)
|
||||
{
|
||||
_hoveredNode = (Ball)NODE;
|
||||
}
|
||||
else if (NODE is BallSprite)
|
||||
{
|
||||
_hoveredNode = (BallSprite)NODE;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_hoveredNode = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetRack()
|
||||
{
|
||||
for (int i = 0; i < _ballSprites.Count; i++)
|
||||
{
|
||||
if ((int)_ballSprites[i]._rackPosition.Y > 0 && (int)_ballSprites[i]._rackPosition.X > 0)
|
||||
{
|
||||
_rack.SetSprite((int)_ballSprites[i]._rackPosition.Y, (int)_ballSprites[i]._rackPosition.X, _ballSprites[i]._imagePath);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _opponent._ballSprites.Count; i++)
|
||||
{
|
||||
if ((int)_opponent._ballSprites[i]._rackPosition.Y > 0 && (int)_opponent._ballSprites[i]._rackPosition.X > 0)
|
||||
{
|
||||
|
||||
_rack.SetSprite((int)_opponent._ballSprites[i]._rackPosition.Y, (int)_opponent._ballSprites[i]._rackPosition.X, _opponent._ballSprites[i]._imagePath);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
|
||||
PotBall(_balls[0]);
|
||||
// for (int i = 0; i < _ballSprites.Count; i++)
|
||||
// {
|
||||
// GD.Print(_ballSprites[i]._rackPosition);
|
||||
// // _ballSprites[i].Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (i + 1));
|
||||
// // _ballSprites[i].AddChild(_ballSprites[i]);
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://c2vdynoqccjtg
|
||||
22
Gameplay/Pocket.cs
Normal file
22
Gameplay/Pocket.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Pocket : Area2D
|
||||
{
|
||||
[Signal]
|
||||
public delegate void OnBallPottedEventHandler(Ball BALL, Pocket THIS);
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
|
||||
BodyEntered += BallPotted;
|
||||
}
|
||||
|
||||
public void BallPotted(Node NODE)
|
||||
{
|
||||
if (NODE is Ball)
|
||||
{
|
||||
EmitSignal(SignalName.OnBallPotted, (Ball)NODE, this);
|
||||
}
|
||||
}
|
||||
}
|
||||
1
Gameplay/Pocket.cs.uid
Normal file
1
Gameplay/Pocket.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cyem70f52xfps
|
||||
@@ -1,14 +1,33 @@
|
||||
using Godot;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
public partial class Table : Sprite2D
|
||||
|
||||
{
|
||||
public static Table _Create()
|
||||
[Signal]
|
||||
public delegate void OnBallPottedEventHandler(Ball THIS, Pocket POCKET);
|
||||
List<Pocket> _pockets;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/table.tscn");
|
||||
Table newTable = scene.Instantiate<Table>();
|
||||
|
||||
return newTable;
|
||||
_pockets = GetNode<Node2D>("Pockets")
|
||||
.GetChildren()
|
||||
.Select(n => (Pocket)n)
|
||||
.ToList<Pocket>();
|
||||
|
||||
for (int i = 0; i < _pockets.Count; i++)
|
||||
{
|
||||
_pockets[i].OnBallPotted += BallPotted;
|
||||
}
|
||||
}
|
||||
|
||||
public void BallPotted(Node NODE, Pocket POCKET)
|
||||
{
|
||||
if (NODE is Ball)
|
||||
{
|
||||
EmitSignal(SignalName.OnBallPotted, (Ball)NODE, POCKET);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://bfxav1txgaxo5"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bbcrvn06t2aem" path="res://BallReturn.cs" id="1_omsmb"]
|
||||
[ext_resource type="Script" uid="uid://bbcrvn06t2aem" path="res://Gameplay/BallReturn.cs" id="1_omsmb"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_3x8cv"]
|
||||
bg_color = Color(0.501407, 0.501406, 0.501406, 1)
|
||||
@@ -1,11 +1,9 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cu06nw3ndwacc"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cyvwahpr2gqi6"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d03s3a1jvn6cn" path="res://Gameplay/ComputerManager.cs" id="1_rwbwa"]
|
||||
[ext_resource type="Script" path="res://Gameplay/ComputerManager.cs" id="1_rwbwa"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm4xk16ce0j" path="res://Gameplay/cue.tscn" id="4_ugtcs"]
|
||||
|
||||
[node name="ComputerManager" type="Node"]
|
||||
script = ExtResource("1_rwbwa")
|
||||
|
||||
[node name="Cue" parent="." instance=ExtResource("4_ugtcs")]
|
||||
|
||||
[connection signal="Shoot" from="Cue" to="." method="OnCueShoot"]
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
[gd_scene load_steps=5 format=3 uid="uid://yqtgkxjjexag"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://yqtgkxjjexag"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://v6ovq4snxruc" path="res://Gameplay/Main.cs" id="1_0xm2m"]
|
||||
[ext_resource type="PackedScene" uid="uid://5ymxo45j4ryt" path="res://Gameplay/battle.tscn" id="2_7rujl"]
|
||||
[ext_resource type="PackedScene" uid="uid://k6jghetyc3cj" path="res://Gameplay/player_manager.tscn" id="3_u78cq"]
|
||||
[ext_resource type="PackedScene" uid="uid://cu06nw3ndwacc" path="res://Gameplay/computer_manager.tscn" id="4_tivnh"]
|
||||
[ext_resource type="PackedScene" uid="uid://cdaxqopr35lll" path="res://Gameplay/manager.tscn" id="3_vkc8e"]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
script = ExtResource("1_0xm2m")
|
||||
|
||||
[node name="Battle" parent="." instance=ExtResource("2_7rujl")]
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("3_u78cq")]
|
||||
|
||||
[node name="Computer" parent="." instance=ExtResource("4_tivnh")]
|
||||
[node name="Player" parent="." instance=ExtResource("3_vkc8e")]
|
||||
|
||||
@@ -1,6 +1,35 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://cdaxqopr35lll"]
|
||||
[gd_scene load_steps=7 format=3 uid="uid://cdaxqopr35lll"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b66ysicyh0m1s" path="res://Gameplay/Manager.cs" id="1_ivgep"]
|
||||
[ext_resource type="Script" uid="uid://dbfpn1p62siat" path="res://Gameplay/PowerBar.cs" id="2_2skxn"]
|
||||
[ext_resource type="PackedScene" uid="uid://8kv00jc35dma" path="res://Gameplay/manager_panel.tscn" id="3_xooeg"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm4xk16ce0j" path="res://Gameplay/cue.tscn" id="4_bcsor"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_8y33v"]
|
||||
bg_color = Color(1, 1, 1, 0.458824)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_vnsqa"]
|
||||
bg_color = Color(0.92549, 0.0901961, 0.0627451, 1)
|
||||
|
||||
[node name="Manager" type="Node"]
|
||||
script = ExtResource("1_ivgep")
|
||||
|
||||
[node name="PowerBar" type="ProgressBar" parent="."]
|
||||
visible = false
|
||||
z_index = 1
|
||||
offset_right = 100.0
|
||||
offset_bottom = 30.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_8y33v")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_vnsqa")
|
||||
show_percentage = false
|
||||
script = ExtResource("2_2skxn")
|
||||
|
||||
[node name="Panel" parent="." instance=ExtResource("3_xooeg")]
|
||||
offset_left = 101.0
|
||||
offset_top = 150.0
|
||||
offset_right = 551.0
|
||||
offset_bottom = 280.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
|
||||
[node name="Cue" parent="." instance=ExtResource("4_bcsor")]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://8kv00jc35dma"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c4ekvurl6q7jn" path="res://Gameplay/ManagerPanel.cs" id="1_8n1hc"]
|
||||
[ext_resource type="PackedScene" uid="uid://cudhpkje2ax2g" path="res://rack.tscn" id="2_20uuj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfxav1txgaxo5" path="res://ball_return.tscn" id="3_sx67n"]
|
||||
[ext_resource type="PackedScene" uid="uid://cudhpkje2ax2g" path="res://Gameplay/rack.tscn" id="2_20uuj"]
|
||||
[ext_resource type="PackedScene" uid="uid://bfxav1txgaxo5" path="res://Gameplay/ball_return.tscn" id="3_sx67n"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_e1ofl"]
|
||||
bg_color = Color(1, 1, 1, 1)
|
||||
@@ -130,10 +130,10 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_j2own")
|
||||
|
||||
[node name="T1" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 13.0
|
||||
offset_top = 25.0
|
||||
offset_right = 63.0
|
||||
offset_bottom = 75.0
|
||||
offset_left = 79.0
|
||||
offset_top = 28.0
|
||||
offset_right = 129.0
|
||||
offset_bottom = 78.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T1"]
|
||||
@@ -141,10 +141,10 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T2" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 88.0
|
||||
offset_top = 25.0
|
||||
offset_right = 138.0
|
||||
offset_bottom = 75.0
|
||||
offset_left = 154.0
|
||||
offset_top = 28.0
|
||||
offset_right = 204.0
|
||||
offset_bottom = 78.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T2"]
|
||||
@@ -152,10 +152,10 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T3" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 163.0
|
||||
offset_top = 25.0
|
||||
offset_right = 213.0
|
||||
offset_bottom = 75.0
|
||||
offset_left = 229.0
|
||||
offset_top = 28.0
|
||||
offset_right = 279.0
|
||||
offset_bottom = 78.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T3"]
|
||||
@@ -163,10 +163,10 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T4" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 238.0
|
||||
offset_top = 25.0
|
||||
offset_right = 288.0
|
||||
offset_bottom = 75.0
|
||||
offset_left = 304.0
|
||||
offset_top = 28.0
|
||||
offset_right = 354.0
|
||||
offset_bottom = 78.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T4"]
|
||||
@@ -174,10 +174,10 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T5" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 13.0
|
||||
offset_top = 100.0
|
||||
offset_right = 63.0
|
||||
offset_bottom = 150.0
|
||||
offset_left = 79.0
|
||||
offset_top = 103.0
|
||||
offset_right = 129.0
|
||||
offset_bottom = 153.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T5"]
|
||||
@@ -185,10 +185,10 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T6" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 88.0
|
||||
offset_top = 100.0
|
||||
offset_right = 138.0
|
||||
offset_bottom = 150.0
|
||||
offset_left = 154.0
|
||||
offset_top = 103.0
|
||||
offset_right = 204.0
|
||||
offset_bottom = 153.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T6"]
|
||||
@@ -196,10 +196,10 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T7" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 163.0
|
||||
offset_top = 100.0
|
||||
offset_right = 213.0
|
||||
offset_bottom = 150.0
|
||||
offset_left = 229.0
|
||||
offset_top = 103.0
|
||||
offset_right = 279.0
|
||||
offset_bottom = 153.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T7"]
|
||||
@@ -207,18 +207,17 @@ position = Vector2(25, 25)
|
||||
|
||||
[node name="T8" type="Panel" parent="Team"]
|
||||
layout_mode = 0
|
||||
offset_left = 238.0
|
||||
offset_top = 100.0
|
||||
offset_right = 288.0
|
||||
offset_bottom = 150.0
|
||||
offset_left = 304.0
|
||||
offset_top = 103.0
|
||||
offset_right = 354.0
|
||||
offset_bottom = 153.0
|
||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="Team/T8"]
|
||||
position = Vector2(25, 25)
|
||||
|
||||
[node name="Rack" parent="." instance=ExtResource("2_20uuj")]
|
||||
position = Vector2(14, 312)
|
||||
scale = Vector2(3.384, 3.384)
|
||||
position = Vector2(107, 346)
|
||||
|
||||
[node name="BallReturn" parent="." instance=ExtResource("3_sx67n")]
|
||||
layout_mode = 0
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
[gd_scene load_steps=7 format=3 uid="uid://k6jghetyc3cj"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://dbfpn1p62siat" path="res://Gameplay/PowerBar.cs" id="2_f0t22"]
|
||||
[ext_resource type="Script" uid="uid://c2vdynoqccjtg" path="res://Gameplay/PlayerManager.cs" id="2_jkbx3"]
|
||||
[ext_resource type="PackedScene" uid="uid://8kv00jc35dma" path="res://Gameplay/manager_panel.tscn" id="3_6k61e"]
|
||||
[ext_resource type="PackedScene" uid="uid://dm4xk16ce0j" path="res://Gameplay/cue.tscn" id="4_g87t0"]
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_i3pqv"]
|
||||
bg_color = Color(1, 1, 1, 0.458824)
|
||||
|
||||
[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_hqtel"]
|
||||
bg_color = Color(0.92549, 0.0901961, 0.0627451, 1)
|
||||
|
||||
[node name="PlayerManager" type="Node"]
|
||||
script = ExtResource("2_jkbx3")
|
||||
|
||||
[node name="PowerBar" type="ProgressBar" parent="."]
|
||||
visible = false
|
||||
z_index = 1
|
||||
offset_right = 100.0
|
||||
offset_bottom = 30.0
|
||||
theme_override_styles/background = SubResource("StyleBoxFlat_i3pqv")
|
||||
theme_override_styles/fill = SubResource("StyleBoxFlat_hqtel")
|
||||
show_percentage = false
|
||||
script = ExtResource("2_f0t22")
|
||||
|
||||
[node name="Panel" parent="." instance=ExtResource("3_6k61e")]
|
||||
offset_left = 101.0
|
||||
offset_top = 150.0
|
||||
offset_right = 551.0
|
||||
offset_bottom = 280.0
|
||||
grow_horizontal = 1
|
||||
grow_vertical = 1
|
||||
|
||||
[node name="Cue" parent="." instance=ExtResource("4_g87t0")]
|
||||
|
||||
[connection signal="Shoot" from="Cue" to="." method="OnCueShoot"]
|
||||
13
Gameplay/pocket.tscn
Normal file
13
Gameplay/pocket.tscn
Normal file
@@ -0,0 +1,13 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://dl1qsemhbxaoh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://cyem70f52xfps" path="res://Gameplay/Pocket.cs" id="1_f316g"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_kcs3t"]
|
||||
radius = 74.0
|
||||
height = 264.0
|
||||
|
||||
[node name="Pocket" type="Area2D"]
|
||||
script = ExtResource("1_f316g")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CapsuleShape2D_kcs3t")
|
||||
@@ -1,7 +1,7 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cudhpkje2ax2g"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cgnwfc387vche" path="res://art/rack.png" id="1_re2um"]
|
||||
[ext_resource type="Script" uid="uid://blwghh5lu3w3r" path="res://Rack.cs" id="2_tsiik"]
|
||||
[ext_resource type="Script" uid="uid://blwghh5lu3w3r" path="res://Gameplay/Rack.cs" id="2_tsiik"]
|
||||
[ext_resource type="PackedScene" uid="uid://tmer0me1qpaa" path="res://Gameplay/ball_sprite.tscn" id="3_ydd72"]
|
||||
|
||||
[node name="Rack" type="Sprite2D"]
|
||||
@@ -13,73 +13,58 @@ script = ExtResource("2_tsiik")
|
||||
position = Vector2(0, 4)
|
||||
|
||||
[node name="C1" parent="R1" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(18, 11)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(37, 15)
|
||||
|
||||
[node name="C2" parent="R1" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(40.25, 11)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(73, 15)
|
||||
|
||||
[node name="C3" parent="R1" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(62.5, 11)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(109, 15)
|
||||
|
||||
[node name="C4" parent="R1" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(84.75, 11)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(145, 15)
|
||||
|
||||
[node name="C5" parent="R1" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(107, 11)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(181, 15)
|
||||
|
||||
[node name="R2" type="Node2D" parent="."]
|
||||
position = Vector2(0, 4)
|
||||
|
||||
[node name="C1" parent="R2" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(30, 30)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(55, 46)
|
||||
|
||||
[node name="C2" parent="R2" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(51.5, 30)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(91, 46)
|
||||
|
||||
[node name="C3" parent="R2" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(73.5, 30)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(127, 46)
|
||||
|
||||
[node name="C4" parent="R2" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(96, 30)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(163, 46)
|
||||
|
||||
[node name="R3" type="Node2D" parent="."]
|
||||
position = Vector2(0, 4)
|
||||
|
||||
[node name="C1" parent="R3" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(41, 49)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(73, 77)
|
||||
|
||||
[node name="C2" parent="R3" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(63, 49)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(109, 77)
|
||||
|
||||
[node name="C3" parent="R3" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(85, 49)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(145, 77)
|
||||
|
||||
[node name="R4" type="Node2D" parent="."]
|
||||
position = Vector2(0, 4)
|
||||
|
||||
[node name="C1" parent="R4" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(52, 68)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(91, 108)
|
||||
|
||||
[node name="C2" parent="R4" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(74, 68)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(127, 108)
|
||||
|
||||
[node name="R5" type="Node2D" parent="."]
|
||||
position = Vector2(0, 4)
|
||||
|
||||
[node name="C1" parent="R5" instance=ExtResource("3_ydd72")]
|
||||
position = Vector2(63, 87)
|
||||
scale = Vector2(0.6, 0.6)
|
||||
position = Vector2(109, 139)
|
||||
@@ -1,32 +1,13 @@
|
||||
[gd_scene load_steps=10 format=3 uid="uid://dsprg4uahkylm"]
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dsprg4uahkylm"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://brbok0al4e1ab" path="res://art/tableTemplate.png" id="1_s3o1g"]
|
||||
[ext_resource type="Script" uid="uid://82h0dmyohfj1" path="res://Gameplay/Table.cs" id="1_v5i0k"]
|
||||
[ext_resource type="PackedScene" uid="uid://dl1qsemhbxaoh" path="res://Gameplay/pocket.tscn" id="3_3wy0c"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_v5i0k"]
|
||||
bounce = 1.0
|
||||
absorbent = true
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_v5i0k"]
|
||||
radius = 74.0
|
||||
height = 264.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_kl0hw"]
|
||||
radius = 74.0
|
||||
height = 264.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_67vji"]
|
||||
radius = 74.0
|
||||
height = 264.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_jry6c"]
|
||||
radius = 74.0
|
||||
height = 264.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_bhh2s"]
|
||||
radius = 24.0
|
||||
height = 154.0
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_s3o1g"]
|
||||
size = Vector2(394, 182)
|
||||
|
||||
@@ -35,74 +16,69 @@ texture_filter = 1
|
||||
texture = ExtResource("1_s3o1g")
|
||||
script = ExtResource("1_v5i0k")
|
||||
|
||||
[node name="Cushions" type="StaticBody2D" parent="."]
|
||||
[node name="Cushions" type="Node2D" parent="."]
|
||||
|
||||
[node name="TL" type="StaticBody2D" parent="Cushions"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_v5i0k")
|
||||
|
||||
[node name="TL" type="CollisionPolygon2D" parent="Cushions"]
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Cushions/TL"]
|
||||
position = Vector2(-600, -339)
|
||||
polygon = PackedVector2Array(160, -87, 360, -86, 380, -64, 379, 303, 360, 314, 158, 314)
|
||||
|
||||
[node name="TR" type="CollisionPolygon2D" parent="Cushions"]
|
||||
[node name="TR" type="StaticBody2D" parent="Cushions"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_v5i0k")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Cushions/TR"]
|
||||
polygon = PackedVector2Array(220, -404, 240, -427, 449, -427, 448, -26, 241, -26, 220, -36)
|
||||
|
||||
[node name="BL" type="CollisionPolygon2D" parent="Cushions"]
|
||||
[node name="BL" type="StaticBody2D" parent="Cushions"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_v5i0k")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Cushions/BL"]
|
||||
polygon = PackedVector2Array(-221, 35, -240, 24, -436, 25, -434, 425, -241, 426, -221, 405)
|
||||
|
||||
[node name="BR" type="CollisionPolygon2D" parent="Cushions"]
|
||||
[node name="BR" type="StaticBody2D" parent="Cushions"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_v5i0k")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Cushions/BR"]
|
||||
polygon = PackedVector2Array(219, 36, 239, 24, 447, 24, 448, 426, 240, 426, 219, 403)
|
||||
|
||||
[node name="B" type="CollisionPolygon2D" parent="Cushions"]
|
||||
[node name="B" type="StaticBody2D" parent="Cushions"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_v5i0k")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Cushions/B"]
|
||||
polygon = PackedVector2Array(-186, 440, -206, 459, -207, 644, 206, 655, 205, 460, 186, 440)
|
||||
|
||||
[node name="T" type="CollisionPolygon2D" parent="Cushions"]
|
||||
[node name="T" type="StaticBody2D" parent="Cushions"]
|
||||
physics_material_override = SubResource("PhysicsMaterial_v5i0k")
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Cushions/T"]
|
||||
polygon = PackedVector2Array(-186, -441, -206, -459, -206, -630, 205, -631, 205, -459, 186, -440)
|
||||
|
||||
[node name="PocketTL" type="Area2D" parent="."]
|
||||
position = Vector2(-279, -559)
|
||||
[node name="Pockets" type="Node2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PocketTL"]
|
||||
shape = SubResource("CapsuleShape2D_v5i0k")
|
||||
[node name="TL" parent="Pockets" instance=ExtResource("3_3wy0c")]
|
||||
position = Vector2(-282, -557)
|
||||
|
||||
[node name="PocketTR" type="Area2D" parent="."]
|
||||
position = Vector2(281, -562)
|
||||
[node name="TR" parent="Pockets" instance=ExtResource("3_3wy0c")]
|
||||
position = Vector2(281, -559)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PocketTR"]
|
||||
shape = SubResource("CapsuleShape2D_kl0hw")
|
||||
|
||||
[node name="PocketBR" type="Area2D" parent="."]
|
||||
position = Vector2(281, 558)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PocketBR"]
|
||||
shape = SubResource("CapsuleShape2D_67vji")
|
||||
|
||||
[node name="PocketBL" type="Area2D" parent="."]
|
||||
position = Vector2(-281, 558)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PocketBL"]
|
||||
shape = SubResource("CapsuleShape2D_jry6c")
|
||||
|
||||
[node name="PocketR" type="Area2D" parent="."]
|
||||
position = Vector2(314, -2)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PocketR"]
|
||||
[node name="R" parent="Pockets" instance=ExtResource("3_3wy0c")]
|
||||
position = Vector2(373, -3)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_bhh2s")
|
||||
|
||||
[node name="PocketL" type="Area2D" parent="."]
|
||||
position = Vector2(-315, -1)
|
||||
[node name="BR" parent="Pockets" instance=ExtResource("3_3wy0c")]
|
||||
position = Vector2(279, 557)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PocketL"]
|
||||
[node name="BL" parent="Pockets" instance=ExtResource("3_3wy0c")]
|
||||
position = Vector2(-280, 557)
|
||||
|
||||
[node name="L" parent="Pockets" instance=ExtResource("3_3wy0c")]
|
||||
position = Vector2(-373, 4)
|
||||
rotation = 1.5708
|
||||
shape = SubResource("CapsuleShape2D_bhh2s")
|
||||
|
||||
[node name="PlayerStartArea" type="Area2D" parent="."]
|
||||
[node name="Kitchen" type="Area2D" parent="."]
|
||||
position = Vector2(-1, 312)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="PlayerStartArea"]
|
||||
shape = SubResource("RectangleShape2D_s3o1g")
|
||||
|
||||
[node name="EnemyStartArea" type="Area2D" parent="."]
|
||||
position = Vector2(-1, -312)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="EnemyStartArea"]
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Kitchen"]
|
||||
shape = SubResource("RectangleShape2D_s3o1g")
|
||||
|
||||
BIN
art/rack.png
BIN
art/rack.png
Binary file not shown.
|
Before Width: | Height: | Size: 998 B After Width: | Height: | Size: 4.0 KiB |
Reference in New Issue
Block a user