7-31-25 @ 3:05AM
This commit is contained in:
@@ -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<PackedScene>("res://Gameplay/ball.tscn");
|
||||
Ball newBall = scene.Instantiate<Ball>();
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,39 +12,10 @@ public partial class Battle : Node
|
||||
public List<Sprite2D> _potted = new();
|
||||
public List<Ball> _balls = new();
|
||||
public Table _table;
|
||||
|
||||
// public static Battle _Create()
|
||||
// {
|
||||
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/battle.tscn");
|
||||
// Battle newBattle = scene.Instantiate<Battle>();
|
||||
|
||||
// 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<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 += 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>("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<CollisionShape2D>("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>("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);
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
26
Gameplay/ComputerManager.cs
Normal file
26
Gameplay/ComputerManager.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class ComputerManager : Manager
|
||||
{
|
||||
public override void _Ready()
|
||||
{
|
||||
Ball newBall;
|
||||
// newBall = _ballScene.Instantiate<Ball>();
|
||||
// newBall.SetSprite("res://art/cue_ball.png");
|
||||
// _balls.Add(0, newBall);
|
||||
|
||||
for (int i = 8; i <= 15; i++)
|
||||
{
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/ball_" + i + ".png");
|
||||
_balls.Add(i - 8, newBall);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
1
Gameplay/ComputerManager.cs.uid
Normal file
1
Gameplay/ComputerManager.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://d03s3a1jvn6cn
|
||||
@@ -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<PackedScene>("res://Gameplay/cue.tscn");
|
||||
// Cue newCue = scene.Instantiate<Cue>();
|
||||
// Texture2D image = GD.Load<Texture2D>("res://art/cue.png");
|
||||
// newCue.Texture = image;
|
||||
// return newCue;
|
||||
// }
|
||||
|
||||
public override void _Ready()
|
||||
|
||||
public Cue()
|
||||
{
|
||||
//_progressBar = GetParent().GetNode<ProgressBar>("PowerBar");
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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>("Battle");
|
||||
_player = GetNode<Manager>("Player");
|
||||
_computer = GetNode<Manager>("Computer");
|
||||
// AddChild(newBattle);
|
||||
_currentBattle.Start();
|
||||
_player = GetNode<PlayerManager>("Player");
|
||||
_computer = GetNode<ComputerManager>("Computer");
|
||||
|
||||
_currentBattle.Start(_player, _computer);
|
||||
_player.Start();
|
||||
_computer.Start();
|
||||
}
|
||||
|
||||
@@ -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<Worker> _team = new();
|
||||
public Worker _hoveredWorker = null;
|
||||
public Worker _selectedWorker = null;
|
||||
public Worker _heldWorker = null;
|
||||
public ManagerPanel _managerPanel = null;
|
||||
public Panel _ballReturn = null;
|
||||
public Dictionary<int, Worker> _workers = new();
|
||||
public Dictionary<int, Ball> _balls = new();
|
||||
public Dictionary<int, PlaceholderBall> _placeholderBalls = new();
|
||||
public Ball _selectedBall = null;
|
||||
public CollisionShape2D _startArea;
|
||||
|
||||
|
||||
// public static Manager _Create()
|
||||
// {
|
||||
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/manager.tscn");
|
||||
// Manager newManager = scene.Instantiate<Manager>();
|
||||
|
||||
// Worker newWorker = Worker._Create();
|
||||
|
||||
// newWorker.GetNode<Ball>("Ball").SetSprite("res://art/cue_ball.png");
|
||||
// newWorker.GetNode<TempBall>("TempBall").SetSprite("res://art/cue_ball.png");
|
||||
|
||||
// newManager._lead = newWorker;
|
||||
// newManager._team.Add(newWorker);
|
||||
// newManager.AddChild(newWorker);
|
||||
public PackedScene _ballScene = ResourceLoader.Load<PackedScene>("res://Gameplay/ball.tscn");
|
||||
public PackedScene _placeholdeBallScene = ResourceLoader.Load<PackedScene>("res://Gameplay/ball.tscn");
|
||||
public PackedScene _cueScene = ResourceLoader.Load<PackedScene>("res://Gameplay/cue.tscn");
|
||||
public PackedScene _workerScene = ResourceLoader.Load<PackedScene>("res://Gameplay/worker.tscn");
|
||||
|
||||
|
||||
// return newManager;
|
||||
// }
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_managerPanel = GetNode<ManagerPanel>("Panel");
|
||||
_ballReturn = _managerPanel.GetNode<Panel>("BallReturn");
|
||||
_health = 10;
|
||||
_healthMax = _health;
|
||||
_managerPanel.SetSprite("res://art/ness.png");
|
||||
_managerPanel.SetMax(_healthMax);
|
||||
_managerPanel.SetValue(_health);
|
||||
_cue = GetNode<Cue>("Cue");
|
||||
}
|
||||
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
public override void _Ready()
|
||||
{
|
||||
// Panel ballReturn = GetNode<ManagerPanel>("Panel").GetNode<Panel>("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>("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<ManagerPanel>("Panel").SetValue(_health);
|
||||
}
|
||||
|
||||
// public void ReturnWorker(Worker WORKER)
|
||||
// {
|
||||
// Panel ballReturn = GetNode<ManagerPanel>("Panel").GetNode<Panel>("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>("Ball").Position = ;
|
||||
// WORKER.GetNode<Ball>("Ball").GetNode<CollisionShape2D>("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<Sprite2D>("Image").Texture = GD.Load<Texture2D>(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>("Ball").ApplyCentralImpulse(IMPULSE);
|
||||
_selectedWorker._selected = false;
|
||||
_selectedWorker.Launch();
|
||||
_selectedWorker = null;
|
||||
_selectedBall.GetNode<Ball>("Ball").ApplyCentralImpulse(IMPULSE);
|
||||
_selectedBall._selected = false;
|
||||
_selectedBall.Launch();
|
||||
_selectedBall = null;
|
||||
_cue.Doff();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@ public partial class ManagerPanel : Panel
|
||||
{
|
||||
Position = POSITION;
|
||||
}
|
||||
public void SetSprite(string PATH)
|
||||
public void SetSprite(string IMAGEPATH)
|
||||
{
|
||||
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
||||
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(IMAGEPATH);
|
||||
}
|
||||
public void SetValue(int VALUE)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
132
Gameplay/PlayerManager.cs
Normal file
132
Gameplay/PlayerManager.cs
Normal file
@@ -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<ManagerPanel>("Panel");
|
||||
_managerPanel.SetPosition(new Vector2(100, 150));
|
||||
_managerPanel.SetSprite(_imagePath);
|
||||
_managerPanel.SetValue(_health);
|
||||
_managerPanel.SetMax(_healthMax);
|
||||
|
||||
Ball newBall;
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/cue_ball.png");
|
||||
_balls.Add(0, newBall);
|
||||
|
||||
for (int i = 1; i <= 7; i++)
|
||||
{
|
||||
newBall = _ballScene.Instantiate<Ball>();
|
||||
newBall.SetSprite("res://art/ball_" + i + ".png");
|
||||
_balls.Add(i, newBall);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
// Panel ballReturn = GetNode<ManagerPanel>("Panel").GetNode<Panel>("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<ManagerPanel>("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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
1
Gameplay/PlayerManager.cs.uid
Normal file
1
Gameplay/PlayerManager.cs.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://c2vdynoqccjtg
|
||||
@@ -1,7 +0,0 @@
|
||||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class Procables : Node
|
||||
{
|
||||
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
uid://d1sbv0yepmvrf
|
||||
@@ -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<PackedScene>("res://Gameplay/worker.tscn");
|
||||
// Worker newWorker = scene.Instantiate<Worker>();
|
||||
// return newWorker;
|
||||
// }
|
||||
public bool _dead = false, _hovered = false;
|
||||
public int _health = 5, _healthMax;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_ball = GetNode<Ball>("Ball");
|
||||
_tempBall = GetNode<TempBall>("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<Sprite2D>("Image").Texture = GD.Load<Texture2D>(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<Worker>();
|
||||
if (_launched)
|
||||
{
|
||||
TARGETWORKER.ChangeDefense(-3);
|
||||
}
|
||||
}
|
||||
// public virtual void ProcessOnCollision(Ball TARGET)
|
||||
// {
|
||||
// Worker TARGETWORKER = TARGET.GetParent<Worker>();
|
||||
// if (_launched)
|
||||
// {
|
||||
// TARGETWORKER.ChangeDefense(-3);
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
@@ -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"]
|
||||
|
||||
11
Gameplay/computer_manager.tscn
Normal file
11
Gameplay/computer_manager.tscn
Normal file
@@ -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"]
|
||||
@@ -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")]
|
||||
|
||||
@@ -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"]
|
||||
|
||||
@@ -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="."]
|
||||
|
||||
37
Gameplay/player_manager.tscn
Normal file
37
Gameplay/player_manager.tscn
Normal file
@@ -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"]
|
||||
@@ -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")
|
||||
@@ -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"]
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
uid://blyqty3080pjv
|
||||
Reference in New Issue
Block a user