From a8373726f968ab1d39114c28507a59f984415510 Mon Sep 17 00:00:00 2001 From: cojoedmo Date: Thu, 31 Jul 2025 03:05:11 -0400 Subject: [PATCH] 7-31-25 @ 3:05AM --- Gameplay/Ball.cs | 20 +- Gameplay/Battle.cs | 109 +++++------ Gameplay/ComputerManager.cs | 26 +++ Gameplay/ComputerManager.cs.uid | 1 + Gameplay/Cue.cs | 15 +- Gameplay/Globals.cs | 2 +- Gameplay/Main.cs | 14 +- Gameplay/Manager.cs | 184 +++++------------- Gameplay/ManagerPanel.cs | 4 +- Gameplay/{TempBall.cs => PlaceholderBall.cs} | 2 +- ...TempBall.cs.uid => PlaceholderBall.cs.uid} | 0 Gameplay/PlayerManager.cs | 132 +++++++++++++ Gameplay/PlayerManager.cs.uid | 1 + Gameplay/Procables.cs | 7 - Gameplay/Procables.cs.uid | 1 - Gameplay/Worker.cs | 115 ++--------- Gameplay/ball.tscn | 13 +- Gameplay/computer_manager.tscn | 11 ++ Gameplay/main.tscn | 9 +- Gameplay/manager.tscn | 33 +--- .../{temp_ball.tscn => placeholder_ball.tscn} | 6 +- Gameplay/player_manager.tscn | 37 ++++ Gameplay/procables.tscn | 6 - Gameplay/worker.tscn | 10 +- Proc.cs | 7 - Proc.cs.uid | 1 - 26 files changed, 357 insertions(+), 409 deletions(-) create mode 100644 Gameplay/ComputerManager.cs create mode 100644 Gameplay/ComputerManager.cs.uid rename Gameplay/{TempBall.cs => PlaceholderBall.cs} (88%) rename Gameplay/{TempBall.cs.uid => PlaceholderBall.cs.uid} (100%) create mode 100644 Gameplay/PlayerManager.cs create mode 100644 Gameplay/PlayerManager.cs.uid delete mode 100644 Gameplay/Procables.cs delete mode 100644 Gameplay/Procables.cs.uid create mode 100644 Gameplay/computer_manager.tscn rename Gameplay/{temp_ball.tscn => placeholder_ball.tscn} (81%) create mode 100644 Gameplay/player_manager.tscn delete mode 100644 Gameplay/procables.tscn delete mode 100644 Proc.cs delete mode 100644 Proc.cs.uid diff --git a/Gameplay/Ball.cs b/Gameplay/Ball.cs index deacb24..6e5f9d1 100644 --- a/Gameplay/Ball.cs +++ b/Gameplay/Ball.cs @@ -1,10 +1,11 @@ using Godot; using System; using System.Runtime; - +/// TODO create a few types of balls public partial class Ball : RigidBody2D { - + [Signal] + public delegate void OnHoverEventHandler(Ball HOVEREDBALL, bool TF); [Signal] public delegate void OnCollisionEventHandler(Ball TARGET); [Signal] @@ -18,20 +19,6 @@ public partial class Ball : RigidBody2D public float _moveThreshold = 5.0f; public Vector2 _newPosition = new Vector2(-1, -1); - - public static Ball _Create() - { - PackedScene scene = ResourceLoader.Load("res://Gameplay/ball.tscn"); - Ball newBall = scene.Instantiate(); - - return newBall; - } - - public override void _Ready() - { - - } - public override void _Process(double DELTA_) { if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold) @@ -105,6 +92,7 @@ public partial class Ball : RigidBody2D if (_active) { _hovered = true; + } } diff --git a/Gameplay/Battle.cs b/Gameplay/Battle.cs index 0de54c6..afbc0ea 100644 --- a/Gameplay/Battle.cs +++ b/Gameplay/Battle.cs @@ -12,39 +12,10 @@ public partial class Battle : Node public List _potted = new(); public List _balls = new(); public Table _table; - - // public static Battle _Create() - // { - // PackedScene scene = ResourceLoader.Load("res://Gameplay/battle.tscn"); - // Battle newBattle = scene.Instantiate(); - - // Manager newPlayerManager = Manager._Create(); - // newBattle._player = newPlayerManager; - // newBattle.AddChild(newPlayerManager); - - // Manager newComputerManager = Manager._Create(); - // newBattle._player = newComputerManager; - // newBattle.AddChild(newComputerManager); - - // Table newTable = Table._Create(); - // newTable.Position = Globals.Instance._screenCenter; - // newBattle._table = newTable; - - // List pockets = newBattle._table.GetChildren() - // .Where(n => n.GetName().ToString().ToLower().Contains("pocket")) - // .Select(n => (Area2D)n) - // .ToList(); - // for (int i = 0; i < pockets.Count; i++) - // { - // pockets[i].BodyEntered += newBattle.PotBall; - // } - // newBattle.AddChild(newTable); - - // return newBattle; - // } + public override void _Ready() { - + } public override void _Process(double DELTA_) @@ -52,32 +23,6 @@ public partial class Battle : Node CheckMovement(); } - public void GenerateBalls() - { - int count = 1; - int columns = 0; - int diameter = 36; - Table table = GetNode("Table"); - for (int i = 0; i < 5; i++) - { - 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)); - Ball ball = Ball._Create(); - ball.Position = position; - ball._placed = true; - ball._potted = false; - ball.GetNode("Bounds").Disabled = false; - ball.SetSprite("res://art/ball_"+count+".png"); - _balls.Add(ball); - AddChild(ball); - - count += 1; - } - columns += 1; - - } - } public void CheckMovement() { @@ -121,12 +66,58 @@ public partial class Battle : Node // } // } - public void Start() + public void Start(PlayerManager PLAYER, ComputerManager COMPUTER) { // _current = true; // // GenerateBalls(); - // Globals.Instance._currentBattle = this; + Globals.Instance._currentBattle = this; // _player.Start(); + + int count = 1; + int columns = 0; + int diameter = 36; + Table table = GetNode
("Table"); + Ball eightBall = COMPUTER._balls[0]; + List computerBalls = COMPUTER._balls.Values.ToList(); + computerBalls.RemoveAt(0); + Ball cueBall = PLAYER._balls[0]; + List playerBalls = PLAYER._balls.Values.ToList(); + playerBalls.RemoveAt(0); + List 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); + + Ball rackBall; + for (int i = 0; i < 5; i++) + { + 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)); + rackBall = randomRack[count]; + if (PLAYER._balls.ContainsValue(rackBall)) + { + PLAYER.PlaceBall(rackBall, position); + } + if (COMPUTER._balls.ContainsValue(rackBall)) + { + COMPUTER.PlaceBall(rackBall, position); + } + + count += 1; + } + columns += 1; + + } } } diff --git a/Gameplay/ComputerManager.cs b/Gameplay/ComputerManager.cs new file mode 100644 index 0000000..fccc446 --- /dev/null +++ b/Gameplay/ComputerManager.cs @@ -0,0 +1,26 @@ +using Godot; +using System; + +public partial class ComputerManager : Manager +{ + public override void _Ready() + { + Ball newBall; + // newBall = _ballScene.Instantiate(); + // newBall.SetSprite("res://art/cue_ball.png"); + // _balls.Add(0, newBall); + + for (int i = 8; i <= 15; i++) + { + newBall = _ballScene.Instantiate(); + newBall.SetSprite("res://art/ball_" + i + ".png"); + _balls.Add(i - 8, newBall); + } + } + + public override void Start() + { + + } + +} diff --git a/Gameplay/ComputerManager.cs.uid b/Gameplay/ComputerManager.cs.uid new file mode 100644 index 0000000..c0540fa --- /dev/null +++ b/Gameplay/ComputerManager.cs.uid @@ -0,0 +1 @@ +uid://d03s3a1jvn6cn diff --git a/Gameplay/Cue.cs b/Gameplay/Cue.cs index 976e9b6..2c39bac 100644 --- a/Gameplay/Cue.cs +++ b/Gameplay/Cue.cs @@ -10,19 +10,10 @@ public partial class Cue : Sprite2D public float _power = 0.0f, _maxPower = 20.0f; Vector2 _direction; public ProgressBar _progressBar; - - // public static Cue _Create() - // { - // PackedScene scene = ResourceLoader.Load("res://Gameplay/cue.tscn"); - // Cue newCue = scene.Instantiate(); - // Texture2D image = GD.Load("res://art/cue.png"); - // newCue.Texture = image; - // return newCue; - // } - - public override void _Ready() + + public Cue() { - //_progressBar = GetParent().GetNode("PowerBar"); + } public override void _Process(double DELTA_) diff --git a/Gameplay/Globals.cs b/Gameplay/Globals.cs index b908320..53787c5 100644 --- a/Gameplay/Globals.cs +++ b/Gameplay/Globals.cs @@ -10,7 +10,7 @@ public partial class Globals : Node public Vector2 _screenSize; public Vector2 _screenCenter; public Battle _currentBattle; - public static RandomNumberGenerator _rng = new(); + public Random _random = new(); public override void _Ready() diff --git a/Gameplay/Main.cs b/Gameplay/Main.cs index 2b04785..9645520 100644 --- a/Gameplay/Main.cs +++ b/Gameplay/Main.cs @@ -4,19 +4,19 @@ using System; public partial class Main : Node { public Battle _currentBattle; - public Manager _player; - public Manager _computer; + public PlayerManager _player; + public ComputerManager _computer; public override void _Ready() { Globals.Instance._screenSize = GetViewport().GetVisibleRect().Size; Globals.Instance._screenCenter = new Vector2(Globals.Instance._screenSize.X / 2, Globals.Instance._screenSize.Y / 2); - // Battle newBattle = Battle._Create(); + _currentBattle = GetNode("Battle"); - _player = GetNode("Player"); - _computer = GetNode("Computer"); - // AddChild(newBattle); - _currentBattle.Start(); + _player = GetNode("Player"); + _computer = GetNode("Computer"); + + _currentBattle.Start(_player, _computer); _player.Start(); _computer.Start(); } diff --git a/Gameplay/Manager.cs b/Gameplay/Manager.cs index 6e22cd7..6358435 100644 --- a/Gameplay/Manager.cs +++ b/Gameplay/Manager.cs @@ -3,126 +3,35 @@ using System; using System.Collections.Generic; using System.Linq; +/// TODO alter code to player vs computer to account for differing logic public partial class Manager : Node { public bool _dead, _ready; - public int _health, _healthMax; + public int _health = 10, _healthMax, _placeLimit = 8; + public string _imagePath; public Cue _cue; - public Worker _lead; - public List _team = new(); - public Worker _hoveredWorker = null; - public Worker _selectedWorker = null; - public Worker _heldWorker = null; - public ManagerPanel _managerPanel = null; - public Panel _ballReturn = null; + public Dictionary _workers = new(); + public Dictionary _balls = new(); + public Dictionary _placeholderBalls = new(); + public Ball _selectedBall = null; + public CollisionShape2D _startArea; + - // public static Manager _Create() - // { - // PackedScene scene = ResourceLoader.Load("res://Gameplay/manager.tscn"); - // Manager newManager = scene.Instantiate(); - - // Worker newWorker = Worker._Create(); - - // newWorker.GetNode("Ball").SetSprite("res://art/cue_ball.png"); - // newWorker.GetNode("TempBall").SetSprite("res://art/cue_ball.png"); - - // newManager._lead = newWorker; - // newManager._team.Add(newWorker); - // newManager.AddChild(newWorker); + public PackedScene _ballScene = ResourceLoader.Load("res://Gameplay/ball.tscn"); + public PackedScene _placeholdeBallScene = ResourceLoader.Load("res://Gameplay/ball.tscn"); + public PackedScene _cueScene = ResourceLoader.Load("res://Gameplay/cue.tscn"); + public PackedScene _workerScene = ResourceLoader.Load("res://Gameplay/worker.tscn"); - // return newManager; - // } - - public override void _Ready() - { - _managerPanel = GetNode("Panel"); - _ballReturn = _managerPanel.GetNode("BallReturn"); - _health = 10; - _healthMax = _health; - _managerPanel.SetSprite("res://art/ness.png"); - _managerPanel.SetMax(_healthMax); - _managerPanel.SetValue(_health); - _cue = GetNode("Cue"); - } - - - public override void _Process(double DELTA_) + public override void _Ready() { - // Panel ballReturn = GetNode("Panel").GetNode("BallReturn"); - // WORKER.ChangeBallPosition(new Vector2(ballReturn.GlobalPosition.X + ballReturn.Size.X / 2, ballReturn.GlobalPosition.Y + 50)); - - if (_team.Any(w => w._hovered)) - { - _hoveredWorker = _team.Single(w => w._hovered); - } - else - { - _hoveredWorker = null; - } - - if (_ready) - { - if ((_selectedWorker == null || _selectedWorker != _hoveredWorker) && (_hoveredWorker?._available ?? false)) - { - if (Input.IsActionJustReleased("left_click")) - { - _selectedWorker = _hoveredWorker; - _selectedWorker._selected = true; - GD.Print(_selectedWorker._ball); - _cue.Don(_selectedWorker._ball.Position); - } - } - else if (Input.IsActionJustReleased("right_click")) - { - _selectedWorker._selected = false; - _selectedWorker = null; - _cue.Doff(); - } - else if (_hoveredWorker == null) - { - if (Input.IsActionJustReleased("left_click") && _selectedWorker != null && _cue._power == 0) - { - _selectedWorker._selected = false; - _selectedWorker = null; - _cue.Doff(); - } - } - } - else - { - if (_heldWorker == null) - { - if (Input.IsActionJustReleased("left_click")) - { - if (!_hoveredWorker._placed) - { - _heldWorker = _hoveredWorker; - } - } - } - else - { - Vector2 mousePosition = GetViewport().GetMousePosition(); - _heldWorker._tempBall.Position = mousePosition; - if (Input.IsActionJustReleased("left_click")) - { - _heldWorker.PlaceBall(mousePosition); - _heldWorker = null; - if (_team.Where(w => w._placed).ToList().Count >= _team.Count) - { - _ready = true; - } - } - } - } - + _healthMax = _health; + _cue = GetNode("Cue"); } - public void ChangeHealth(int CHANGE) + public virtual void ChangeHealth(int CHANGE) { _health += CHANGE; - GD.Print("Health: " + _health); _health = Math.Min(_health, _healthMax); if (_health < 0) @@ -130,43 +39,56 @@ public partial class Manager : Node _dead = true; _health = 0; } - GetNode("Panel").SetValue(_health); } - // public void ReturnWorker(Worker WORKER) - // { - // Panel ballReturn = GetNode("Panel").GetNode("BallReturn"); - // int ballsInReturn = _team.Where(b => !b._placed).ToList().Count; + public void PlaceBall(Ball BALL, Vector2 POSITION) + { + + BALL._available = true; + BALL.Position = POSITION; + BALL._active = true; + BALL._placed = true; + BALL._potted = false; + BALL._active = true; + AddChild(BALL); - // WORKER.GetNode("Ball").Position = ; - // WORKER.GetNode("Ball").GetNode("Bounds").Disabled = true; + // _placeholderBalls[BALLNUMBER]._active = false; + // RemoveChild(_placeholderBalls[BALLNUMBER]); + } - // AddChild(WORKER); - // } + public void PotBall(Ball BALL) + { + BALL.Sleeping = true; + BALL._available = false; + BALL._moving = false; + BALL._active = false; + BALL._placed = false; + BALL._potted = true; + BALL._active = false; + RemoveChild(BALL); + + // _placeholderBalls[BALLNUMBER]._active = true; + // AddChild(_placeholderBalls[BALLNUMBER]); + } public void SetSprite(string PATH) { - GetNode("Image").Texture = GD.Load(PATH); + _imagePath = PATH; } - public void Start() + public virtual void Start() { - for (int i = 0; i < _team.Count; i++) - { - _team[i]._tempBall.Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (i + 1)); - _team[i].TempBallShow(); - - } + } - + private void OnCueShoot(Vector2 IMPULSE) { - if (_selectedWorker != null && _selectedWorker._placed) + if (_selectedBall != null && _selectedBall._placed) { - _selectedWorker.GetNode("Ball").ApplyCentralImpulse(IMPULSE); - _selectedWorker._selected = false; - _selectedWorker.Launch(); - _selectedWorker = null; + _selectedBall.GetNode("Ball").ApplyCentralImpulse(IMPULSE); + _selectedBall._selected = false; + _selectedBall.Launch(); + _selectedBall = null; _cue.Doff(); } } diff --git a/Gameplay/ManagerPanel.cs b/Gameplay/ManagerPanel.cs index 4f12bd4..d078e20 100644 --- a/Gameplay/ManagerPanel.cs +++ b/Gameplay/ManagerPanel.cs @@ -9,9 +9,9 @@ public partial class ManagerPanel : Panel { Position = POSITION; } - public void SetSprite(string PATH) + public void SetSprite(string IMAGEPATH) { - GetNode("Image").Texture = GD.Load(PATH); + GetNode("Image").Texture = GD.Load(IMAGEPATH); } public void SetValue(int VALUE) { diff --git a/Gameplay/TempBall.cs b/Gameplay/PlaceholderBall.cs similarity index 88% rename from Gameplay/TempBall.cs rename to Gameplay/PlaceholderBall.cs index 951578d..4fe455f 100644 --- a/Gameplay/TempBall.cs +++ b/Gameplay/PlaceholderBall.cs @@ -1,7 +1,7 @@ using Godot; using System; -public partial class TempBall : Area2D +public partial class PlaceholderBall : Area2D { public bool _active = false, _hovered = false, _held = false; diff --git a/Gameplay/TempBall.cs.uid b/Gameplay/PlaceholderBall.cs.uid similarity index 100% rename from Gameplay/TempBall.cs.uid rename to Gameplay/PlaceholderBall.cs.uid diff --git a/Gameplay/PlayerManager.cs b/Gameplay/PlayerManager.cs new file mode 100644 index 0000000..ad18ff2 --- /dev/null +++ b/Gameplay/PlayerManager.cs @@ -0,0 +1,132 @@ +using Godot; +using System; +using System.Collections.Generic; +using System.Linq; + +public partial class PlayerManager : Manager +{ + public Ball _hoveredBall = null; + public PlaceholderBall _hoveredPlaceholderBall = null; + public PlaceholderBall _heldPlaceholderBall = null; + public Worker _hoveredWorker = null; + public ManagerPanel _managerPanel = null; + public Panel _ballReturn = null; + + public override void _Ready() + { + SetSprite("res://art/ness.png"); + + _managerPanel = GetNode("Panel"); + _managerPanel.SetPosition(new Vector2(100, 150)); + _managerPanel.SetSprite(_imagePath); + _managerPanel.SetValue(_health); + _managerPanel.SetMax(_healthMax); + + Ball newBall; + newBall = _ballScene.Instantiate(); + newBall.SetSprite("res://art/cue_ball.png"); + _balls.Add(0, newBall); + + for (int i = 1; i <= 7; i++) + { + newBall = _ballScene.Instantiate(); + newBall.SetSprite("res://art/ball_" + i + ".png"); + _balls.Add(i, newBall); + } + + } + + public override void _Process(double DELTA_) + { + // Panel ballReturn = GetNode("Panel").GetNode("BallReturn"); + // WORKER.ChangeBallPosition(new Vector2(ballReturn.GlobalPosition.X + ballReturn.Size.X / 2, ballReturn.GlobalPosition.Y + 50)); + + if (_ready) + { + if ((_selectedBall == null || _selectedBall != _hoveredBall) && (_hoveredBall?._available ?? false)) + { + if (Input.IsActionJustReleased("left_click")) + { + _selectedBall = _hoveredBall; + _selectedBall._selected = true; + _cue.Don(_selectedBall.Position); + } + } + else if (Input.IsActionJustReleased("right_click")) + { + _selectedBall._selected = false; + _selectedBall = null; + _cue.Doff(); + } + else if (_hoveredBall == null) + { + if (Input.IsActionJustReleased("left_click") && _selectedBall != null && _cue._power == 0) + { + _selectedBall._selected = false; + _selectedBall = null; + _cue.Doff(); + } + } + } + else + { + if (_heldPlaceholderBall != null) + { + Vector2 mousePosition = GetViewport().GetMousePosition(); + _heldPlaceholderBall.Position = mousePosition; + if (Input.IsActionJustReleased("left_click")) + { + int index = _placeholderBalls.Single(p => p.Value == _heldPlaceholderBall).Key; + PlaceBall(_balls[index], mousePosition); + _heldPlaceholderBall = null; + if (_balls.Where(b => b.Value._placed).ToList().Count >= _placeLimit) + { + _ready = true; + } + } + } + else + { + if (Input.IsActionJustReleased("left_click")) + { + _heldPlaceholderBall = _hoveredPlaceholderBall; + } + } + } + + } + + public override void ChangeHealth(int CHANGE) + { + base.ChangeHealth(CHANGE); + GetNode("Panel").SetValue(_health); + } + + public override void Start() + { + for (int i = 0; i < _placeholderBalls.Count; i++) + { + _placeholderBalls[i].Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (i + 1)); + _placeholderBalls[i].AddChild(_placeholderBalls[i]); + } + } + + public void HoverBall(Ball BALL, bool HOVERED) + { + if (HOVERED) + { + if (_hoveredBall == null) + { + _hoveredBall = BALL; + } + } + else + { + if (_hoveredBall == BALL) + { + _hoveredBall = null; + } + } + + } +} diff --git a/Gameplay/PlayerManager.cs.uid b/Gameplay/PlayerManager.cs.uid new file mode 100644 index 0000000..1b0abfc --- /dev/null +++ b/Gameplay/PlayerManager.cs.uid @@ -0,0 +1 @@ +uid://c2vdynoqccjtg diff --git a/Gameplay/Procables.cs b/Gameplay/Procables.cs deleted file mode 100644 index 4f4cca0..0000000 --- a/Gameplay/Procables.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Godot; -using System; - -public partial class Procables : Node -{ - -} diff --git a/Gameplay/Procables.cs.uid b/Gameplay/Procables.cs.uid deleted file mode 100644 index aac2188..0000000 --- a/Gameplay/Procables.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://d1sbv0yepmvrf diff --git a/Gameplay/Worker.cs b/Gameplay/Worker.cs index 328855c..0496b48 100644 --- a/Gameplay/Worker.cs +++ b/Gameplay/Worker.cs @@ -1,125 +1,44 @@ using Godot; using System; using System.Collections.Generic; +using System.Reflection; public partial class Worker : Node2D { [Signal] public delegate void DamageOverflowEventHandler(int OVERFLOW); - public bool _dead = false, _available = false, _hovered = false, _selected = false, _launched = false, _placed = false, _potted = false, _isLead = false; - public int _defense = 5, _defenseMax = 5; - public CollisionShape2D _startArea; - public TempBall _tempBall; - public Ball _ball; - - // public static Worker _Create() - // { - // PackedScene scene = ResourceLoader.Load("res://Gameplay/worker.tscn"); - // Worker newWorker = scene.Instantiate(); - // return newWorker; - // } + public bool _dead = false, _hovered = false; + public int _health = 5, _healthMax; public override void _Ready() { - _ball = GetNode("Ball"); - _tempBall = GetNode("TempBall"); - - RemoveChild(_ball); - RemoveChild(_tempBall); + _healthMax = _health; } - public override void _Process(double delta) - { - _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; - _defense = Math.Min(_defense, _defenseMax); - if (_defense < 0) + _health += CHANGE; + _health = Math.Min(_health, _healthMax); + if (_health < 0) { - EmitSignal(SignalName.DamageOverflow, _defense); - _defense = 0; + EmitSignal(SignalName.DamageOverflow, _health); + _health = 0; } } - public void Launch() - { - _launched = true; - _ball.Launch(); - } - public void SetSprite(string PATH) { GetNode("Image").Texture = GD.Load(PATH); } - 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() - { - _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 TempBallHide() - { - _tempBall._active = false; - RemoveChild(_tempBall); - } - - public void TempBallShow() - { - _tempBall._active = true; - AddChild(_tempBall); - } - // Processes - public virtual void ProcessOnCollision(Ball TARGET) - { - Worker TARGETWORKER = TARGET.GetParent(); - if (_launched) - { - TARGETWORKER.ChangeDefense(-3); - } - } + // public virtual void ProcessOnCollision(Ball TARGET) + // { + // Worker TARGETWORKER = TARGET.GetParent(); + // if (_launched) + // { + // TARGETWORKER.ChangeDefense(-3); + // } + // } } diff --git a/Gameplay/ball.tscn b/Gameplay/ball.tscn index c8d50c4..49ffb47 100644 --- a/Gameplay/ball.tscn +++ b/Gameplay/ball.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=7 format=3 uid="uid://c8n4lue2bn25n"] +[gd_scene load_steps=6 format=3 uid="uid://c8n4lue2bn25n"] [ext_resource type="Script" uid="uid://dgdxx8tceiljg" path="res://Gameplay/Ball.cs" id="1_7ritg"] [ext_resource type="Shader" uid="uid://b6vvt5o0008ob" path="res://shaders/globe.gdshader" id="2_6v01e"] @@ -16,9 +16,6 @@ shader_parameter/globe_magnitude = 0.0 [sub_resource type="CircleShape2D" id="CircleShape2D_803qd"] radius = 18.0 -[sub_resource type="CircleShape2D" id="CircleShape2D_wmcg2"] -radius = 18.0 - [node name="Ball" type="RigidBody2D" groups=["balls"]] z_index = 1 input_pickable = true @@ -36,14 +33,6 @@ material = SubResource("ShaderMaterial_yj7wd") position = Vector2(0, -7.10543e-15) shape = SubResource("CircleShape2D_803qd") -[node name="Area2D" type="Area2D" parent="."] -disable_mode = 2 - -[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] -shape = SubResource("CircleShape2D_wmcg2") - [connection signal="body_entered" from="." to="." method="OnBodyEntered"] [connection signal="mouse_entered" from="." to="." method="OnMouseEntered"] [connection signal="mouse_exited" from="." to="." method="OnMouseExited"] -[connection signal="mouse_entered" from="Area2D" to="." method="OnMouseEntered"] -[connection signal="mouse_exited" from="Area2D" to="." method="OnMouseExited"] diff --git a/Gameplay/computer_manager.tscn b/Gameplay/computer_manager.tscn new file mode 100644 index 0000000..8d9aeff --- /dev/null +++ b/Gameplay/computer_manager.tscn @@ -0,0 +1,11 @@ +[gd_scene load_steps=3 format=3 uid="uid://cu06nw3ndwacc"] + +[ext_resource type="Script" uid="uid://d03s3a1jvn6cn" 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"] diff --git a/Gameplay/main.tscn b/Gameplay/main.tscn index be2658c..4942bb1 100644 --- a/Gameplay/main.tscn +++ b/Gameplay/main.tscn @@ -1,14 +1,15 @@ -[gd_scene load_steps=4 format=3 uid="uid://yqtgkxjjexag"] +[gd_scene load_steps=5 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://cdaxqopr35lll" path="res://Gameplay/manager.tscn" id="3_vkc8e"] +[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"] [node name="Main" type="Node"] script = ExtResource("1_0xm2m") [node name="Battle" parent="." instance=ExtResource("2_7rujl")] -[node name="Computer" parent="." instance=ExtResource("3_vkc8e")] +[node name="Player" parent="." instance=ExtResource("3_u78cq")] -[node name="Player" parent="." instance=ExtResource("3_vkc8e")] +[node name="Computer" parent="." instance=ExtResource("4_tivnh")] diff --git a/Gameplay/manager.tscn b/Gameplay/manager.tscn index 078eef2..ea54584 100644 --- a/Gameplay/manager.tscn +++ b/Gameplay/manager.tscn @@ -1,37 +1,6 @@ -[gd_scene load_steps=7 format=3 uid="uid://cdaxqopr35lll"] +[gd_scene load_steps=2 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_muxv4"] -[ext_resource type="PackedScene" uid="uid://8kv00jc35dma" path="res://Gameplay/manager_panel.tscn" id="3_muxv4"] -[ext_resource type="PackedScene" uid="uid://dm4xk16ce0j" path="res://Gameplay/cue.tscn" id="4_2skxn"] - -[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="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_i3pqv") -theme_override_styles/fill = SubResource("StyleBoxFlat_hqtel") -show_percentage = false -script = ExtResource("2_muxv4") - -[node name="Panel" parent="." instance=ExtResource("3_muxv4")] -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_2skxn")] - -[connection signal="Shoot" from="Cue" to="." method="OnCueShoot"] diff --git a/Gameplay/temp_ball.tscn b/Gameplay/placeholder_ball.tscn similarity index 81% rename from Gameplay/temp_ball.tscn rename to Gameplay/placeholder_ball.tscn index b5af655..96c440a 100644 --- a/Gameplay/temp_ball.tscn +++ b/Gameplay/placeholder_ball.tscn @@ -1,13 +1,13 @@ [gd_scene load_steps=3 format=3 uid="uid://cxvrswwjwxgxj"] -[ext_resource type="Script" uid="uid://c2rt5f831l1l1" path="res://Gameplay/TempBall.cs" id="1_y0oty"] +[ext_resource type="Script" uid="uid://c2rt5f831l1l1" path="res://Gameplay/PlaceholderBall.cs" id="1_bwons"] [sub_resource type="CircleShape2D" id="CircleShape2D_vjx3o"] radius = 18.0 -[node name="TempBall" type="Area2D"] +[node name="BallPlaceholder" type="Area2D"] z_index = 2 -script = ExtResource("1_y0oty") +script = ExtResource("1_bwons") [node name="Image" type="Sprite2D" parent="."] diff --git a/Gameplay/player_manager.tscn b/Gameplay/player_manager.tscn new file mode 100644 index 0000000..0a3a403 --- /dev/null +++ b/Gameplay/player_manager.tscn @@ -0,0 +1,37 @@ +[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"] diff --git a/Gameplay/procables.tscn b/Gameplay/procables.tscn deleted file mode 100644 index 992d16e..0000000 --- a/Gameplay/procables.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dkyt6eqw502aa"] - -[ext_resource type="Script" uid="uid://d1sbv0yepmvrf" path="res://Gameplay/Procables.cs" id="1_rwcmg"] - -[node name="Procables" type="Node"] -script = ExtResource("1_rwcmg") diff --git a/Gameplay/worker.tscn b/Gameplay/worker.tscn index e72f11c..0d589fd 100644 --- a/Gameplay/worker.tscn +++ b/Gameplay/worker.tscn @@ -1,17 +1,9 @@ -[gd_scene load_steps=4 format=3 uid="uid://72tgm5p8d32r"] +[gd_scene load_steps=2 format=3 uid="uid://72tgm5p8d32r"] [ext_resource type="Script" uid="uid://b4mr2vn8mw6r4" path="res://Gameplay/Worker.cs" id="1_e314i"] -[ext_resource type="PackedScene" uid="uid://c8n4lue2bn25n" path="res://Gameplay/ball.tscn" id="2_m3kx1"] -[ext_resource type="PackedScene" uid="uid://cxvrswwjwxgxj" path="res://Gameplay/temp_ball.tscn" id="3_4poc8"] [node name="Worker" type="Node2D"] script = ExtResource("1_e314i") [node name="Sprite" type="Sprite2D" parent="."] visible = false - -[node name="Ball" parent="." instance=ExtResource("2_m3kx1")] - -[node name="TempBall" parent="." instance=ExtResource("3_4poc8")] - -[connection signal="OnCollision" from="Ball" to="." method="ProcessOnCollision"] diff --git a/Proc.cs b/Proc.cs deleted file mode 100644 index 6d06a9d..0000000 --- a/Proc.cs +++ /dev/null @@ -1,7 +0,0 @@ -using Godot; -using System; - -public partial class Proc : Node -{ - -} diff --git a/Proc.cs.uid b/Proc.cs.uid deleted file mode 100644 index 35bd6bb..0000000 --- a/Proc.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://blyqty3080pjv