7-29-25 @ 2:57am
This commit is contained in:
124
Gameplay/Ball.cs
124
Gameplay/Ball.cs
@@ -1,10 +1,19 @@
|
|||||||
using Godot;
|
using Godot;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Runtime;
|
||||||
|
|
||||||
public partial class Ball : RigidBody2D
|
public partial class Ball : RigidBody2D
|
||||||
{
|
{
|
||||||
|
|
||||||
[Signal]
|
[Signal]
|
||||||
public delegate void OnHitEventHandler();
|
public delegate void OnCollisionEventHandler(Ball TARGET);
|
||||||
|
[Signal]
|
||||||
|
public delegate void OnLaunchEventHandler();
|
||||||
|
[Signal]
|
||||||
|
public delegate void OnMovementEventHandler();
|
||||||
|
[Signal]
|
||||||
|
public delegate void OnStopEventHandler();
|
||||||
|
|
||||||
public bool _active = false, _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _launched = false, _moving = false, _isCue = false;
|
public bool _active = false, _placed = false, _potted = false, _available = false, _hovered = false, _selected = false, _aimed = false, _launched = false, _moving = false, _isCue = false;
|
||||||
public float _moveThreshold = 5.0f;
|
public float _moveThreshold = 5.0f;
|
||||||
public Vector2 _newPosition = new Vector2(-1, -1);
|
public Vector2 _newPosition = new Vector2(-1, -1);
|
||||||
@@ -18,13 +27,11 @@ public partial class Ball : RigidBody2D
|
|||||||
return newBall;
|
return newBall;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void _Process(double DELTA_)
|
public override void _Process(double DELTA_)
|
||||||
{
|
{
|
||||||
if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold)
|
if (LinearVelocity.Length() > 0 && LinearVelocity.Length() < _moveThreshold)
|
||||||
@@ -32,6 +39,7 @@ public partial class Ball : RigidBody2D
|
|||||||
Sleeping = true;
|
Sleeping = true;
|
||||||
if (_moving)
|
if (_moving)
|
||||||
{
|
{
|
||||||
|
ProcessOnStop();
|
||||||
_moving = false;
|
_moving = false;
|
||||||
if (_launched)
|
if (_launched)
|
||||||
{
|
{
|
||||||
@@ -41,6 +49,7 @@ public partial class Ball : RigidBody2D
|
|||||||
}
|
}
|
||||||
else if (LinearVelocity.Length() >= _moveThreshold)
|
else if (LinearVelocity.Length() >= _moveThreshold)
|
||||||
{
|
{
|
||||||
|
ProcessOnMovement();
|
||||||
if (!_moving)
|
if (!_moving)
|
||||||
{
|
{
|
||||||
_moving = true;
|
_moving = true;
|
||||||
@@ -63,11 +72,17 @@ public partial class Ball : RigidBody2D
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Launch()
|
||||||
|
{
|
||||||
|
ProcessOnLaunch();
|
||||||
|
}
|
||||||
|
|
||||||
public void Pot()
|
public void Pot()
|
||||||
{
|
{
|
||||||
|
Sleeping = true;
|
||||||
|
_active = false;
|
||||||
_placed = false;
|
_placed = false;
|
||||||
_potted = true;
|
_potted = true;
|
||||||
Sleeping = true;
|
|
||||||
_moving = false;
|
_moving = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +93,11 @@ public partial class Ball : RigidBody2D
|
|||||||
|
|
||||||
private void OnBodyEntered(Node2D TARGET)
|
private void OnBodyEntered(Node2D TARGET)
|
||||||
{
|
{
|
||||||
|
if (TARGET is Ball)
|
||||||
|
{
|
||||||
|
Ball target = (Ball)TARGET;
|
||||||
|
ProcessOnCollision(target);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseEntered()
|
private void OnMouseEntered()
|
||||||
@@ -99,85 +118,86 @@ public partial class Ball : RigidBody2D
|
|||||||
|
|
||||||
|
|
||||||
//Processes
|
//Processes
|
||||||
public virtual void ProcessOnAdd()
|
// public virtual void ProcessOnAdd()
|
||||||
{
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public virtual void ProcessOnBattleStart()
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public virtual void ProcessOnBattleEnd()
|
||||||
|
// {
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
|
public virtual void ProcessOnCollision(Ball TARGET)
|
||||||
|
{
|
||||||
|
EmitSignal(SignalName.OnCollision, TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessOnBattleStart()
|
// public virtual void ProcessOnCreation()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnBattleEnd()
|
// public virtual void ProcessOnCritical()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnCollision()
|
// public virtual void ProcessOnDeath()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnCreation()
|
// public virtual void ProcessOnDefend()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnCritical()
|
// public virtual void ProcessOnExpiration()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnDeath()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ProcessOnDefend()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ProcessOnExpiration()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ProcessOnLaunch()
|
public virtual void ProcessOnLaunch()
|
||||||
{
|
{
|
||||||
|
_launched = true;
|
||||||
|
EmitSignal(SignalName.OnLaunch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessOnMovement()
|
public virtual void ProcessOnMovement()
|
||||||
{
|
{
|
||||||
|
EmitSignal(SignalName.OnMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessOnRemove()
|
// public virtual void ProcessOnRemove()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnSell()
|
// public virtual void ProcessOnSell()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnStop()
|
public virtual void ProcessOnStop()
|
||||||
{
|
{
|
||||||
|
EmitSignal(SignalName.OnStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void ProcessOnTurnEnd()
|
// public virtual void ProcessOnTurnEnd()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
public virtual void ProcessOnTurnStart()
|
// public virtual void ProcessOnTurnStart()
|
||||||
{
|
// {
|
||||||
|
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,41 +8,43 @@ public partial class Battle : Node
|
|||||||
|
|
||||||
public bool _current;
|
public bool _current;
|
||||||
public Vector2 _startPosition = new Vector2(890, 340);
|
public Vector2 _startPosition = new Vector2(890, 340);
|
||||||
public Manager _player;
|
|
||||||
public Manager _computer;
|
|
||||||
public Manager _turn;
|
public Manager _turn;
|
||||||
public List<Sprite2D> _potted = new();
|
public List<Sprite2D> _potted = new();
|
||||||
public List<Ball> _balls = new();
|
public List<Ball> _balls = new();
|
||||||
public Table _table;
|
public Table _table;
|
||||||
|
|
||||||
public static Battle _Create()
|
// public static Battle _Create()
|
||||||
{
|
// {
|
||||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/battle.tscn");
|
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/battle.tscn");
|
||||||
Battle newBattle = scene.Instantiate<Battle>();
|
// Battle newBattle = scene.Instantiate<Battle>();
|
||||||
|
|
||||||
Manager newManager = Manager._Create();
|
// Manager newPlayerManager = Manager._Create();
|
||||||
newBattle._player = newManager;
|
// newBattle._player = newPlayerManager;
|
||||||
newBattle.AddChild(newManager);
|
// newBattle.AddChild(newPlayerManager);
|
||||||
|
|
||||||
Table newTable = Table._Create();
|
// Manager newComputerManager = Manager._Create();
|
||||||
newTable.Position = Globals.Instance._screenCenter;
|
// newBattle._player = newComputerManager;
|
||||||
newBattle._table = newTable;
|
// newBattle.AddChild(newComputerManager);
|
||||||
|
|
||||||
List<Area2D> pockets = newBattle._table.GetChildren()
|
// Table newTable = Table._Create();
|
||||||
.Where(n => n.GetName().ToString().ToLower().Contains("pocket"))
|
// newTable.Position = Globals.Instance._screenCenter;
|
||||||
.Select(n => (Area2D)n)
|
// newBattle._table = newTable;
|
||||||
.ToList<Area2D>();
|
|
||||||
for (int i = 0; i < pockets.Count; i++)
|
|
||||||
{
|
|
||||||
pockets[i].BodyEntered += newBattle.PotBall;
|
|
||||||
}
|
|
||||||
newBattle.AddChild(newTable);
|
|
||||||
|
|
||||||
return newBattle;
|
// 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 _Ready()
|
||||||
{
|
{
|
||||||
Start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double DELTA_)
|
public override void _Process(double DELTA_)
|
||||||
@@ -100,31 +102,31 @@ public partial class Battle : Node
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PotBall(Node2D BODY)
|
// public void PotBall(Node2D BODY)
|
||||||
{
|
// {
|
||||||
if (BODY is Ball)
|
// if (BODY is Ball)
|
||||||
{
|
// {
|
||||||
Ball ball = (Ball)BODY;
|
// Ball ball = (Ball)BODY;
|
||||||
if (ball.GetParentOrNull<Manager>() == _player)
|
// if (ball.GetParentOrNull<Manager>() == _player)
|
||||||
{
|
// {
|
||||||
_player.PotWorker(ball.GetParent<Worker>());
|
// // _player.PotWorker(ball.GetParent<Worker>());
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
ball.Pot();
|
// ball.Pot();
|
||||||
_balls.Remove(ball);
|
// _balls.Remove(ball);
|
||||||
RemoveChild(ball);
|
// RemoveChild(ball);
|
||||||
ball.QueueFree();
|
// ball.QueueFree();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
_current = true;
|
// _current = true;
|
||||||
GenerateBalls();
|
// // GenerateBalls();
|
||||||
Globals.Instance._currentBattle = this;
|
// Globals.Instance._currentBattle = this;
|
||||||
_player.Start();
|
// _player.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,14 +11,14 @@ public partial class Cue : Sprite2D
|
|||||||
Vector2 _direction;
|
Vector2 _direction;
|
||||||
public ProgressBar _progressBar;
|
public ProgressBar _progressBar;
|
||||||
|
|
||||||
public static Cue _Create()
|
// public static Cue _Create()
|
||||||
{
|
// {
|
||||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/cue.tscn");
|
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/cue.tscn");
|
||||||
Cue newCue = scene.Instantiate<Cue>();
|
// Cue newCue = scene.Instantiate<Cue>();
|
||||||
Texture2D image = GD.Load<Texture2D>("res://art/cue.png");
|
// Texture2D image = GD.Load<Texture2D>("res://art/cue.png");
|
||||||
newCue.Texture = image;
|
// newCue.Texture = image;
|
||||||
return newCue;
|
// return newCue;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,13 +3,22 @@ using System;
|
|||||||
|
|
||||||
public partial class Main : Node
|
public partial class Main : Node
|
||||||
{
|
{
|
||||||
|
public Battle _currentBattle;
|
||||||
|
public Manager _player;
|
||||||
|
public Manager _computer;
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
Globals.Instance._screenSize = GetViewport().GetVisibleRect().Size;
|
Globals.Instance._screenSize = GetViewport().GetVisibleRect().Size;
|
||||||
Globals.Instance._screenCenter = new Vector2(Globals.Instance._screenSize.X / 2, Globals.Instance._screenSize.Y / 2);
|
Globals.Instance._screenCenter = new Vector2(Globals.Instance._screenSize.X / 2, Globals.Instance._screenSize.Y / 2);
|
||||||
Battle newBattle = Battle._Create();
|
// Battle newBattle = Battle._Create();
|
||||||
Globals.Instance._currentBattle = newBattle;
|
_currentBattle = GetNode<Battle>("Battle");
|
||||||
AddChild(newBattle);
|
_player = GetNode<Manager>("Player");
|
||||||
|
_computer = GetNode<Manager>("Computer");
|
||||||
|
// AddChild(newBattle);
|
||||||
|
_currentBattle.Start();
|
||||||
|
_player.Start();
|
||||||
|
_computer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double DELTA_)
|
public override void _Process(double DELTA_)
|
||||||
|
|||||||
@@ -13,31 +13,45 @@ public partial class Manager : Node
|
|||||||
public Worker _hoveredWorker = null;
|
public Worker _hoveredWorker = null;
|
||||||
public Worker _selectedWorker = null;
|
public Worker _selectedWorker = null;
|
||||||
public Worker _heldWorker = null;
|
public Worker _heldWorker = null;
|
||||||
|
public ManagerPanel _managerPanel = null;
|
||||||
|
public Panel _ballReturn = null;
|
||||||
|
|
||||||
public static Manager _Create()
|
// public static Manager _Create()
|
||||||
{
|
// {
|
||||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/manager.tscn");
|
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/manager.tscn");
|
||||||
Manager newManager = scene.Instantiate<Manager>();
|
// Manager newManager = scene.Instantiate<Manager>();
|
||||||
|
|
||||||
Worker newWorker = Worker._Create();
|
// Worker newWorker = Worker._Create();
|
||||||
newWorker.GetNode<Ball>("Ball").SetSprite("res://art/cue_ball.png");
|
|
||||||
newWorker.GetNode<TempBall>("TempBall").SetSprite("res://art/cue_ball.png");
|
|
||||||
// newWorker.ChangeBallPosition(new Vector2(100, 100));
|
|
||||||
newManager._lead = newWorker;
|
|
||||||
newManager._team.Add(newWorker);
|
|
||||||
newManager.AddChild(newWorker);
|
|
||||||
|
|
||||||
newManager._health = 10;
|
// newWorker.GetNode<Ball>("Ball").SetSprite("res://art/cue_ball.png");
|
||||||
newManager._healthMax = newManager._health;
|
// newWorker.GetNode<TempBall>("TempBall").SetSprite("res://art/cue_ball.png");
|
||||||
|
|
||||||
|
// newManager._lead = newWorker;
|
||||||
|
// newManager._team.Add(newWorker);
|
||||||
|
// newManager.AddChild(newWorker);
|
||||||
|
|
||||||
|
|
||||||
|
// 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");
|
||||||
|
}
|
||||||
|
|
||||||
newManager.GetNode<ManagerPanel>("Panel").SetSprite("res://art/ness.png");
|
|
||||||
newManager.GetNode<ManagerPanel>("Panel").SetMax(newManager._healthMax);
|
|
||||||
newManager.GetNode<ManagerPanel>("Panel").SetValue(newManager._health);
|
|
||||||
return newManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void _Process(double DELTA_)
|
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 (_team.Any(w => w._hovered))
|
if (_team.Any(w => w._hovered))
|
||||||
{
|
{
|
||||||
_hoveredWorker = _team.Single(w => w._hovered);
|
_hoveredWorker = _team.Single(w => w._hovered);
|
||||||
@@ -49,7 +63,31 @@ public partial class Manager : Node
|
|||||||
|
|
||||||
if (_ready)
|
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
|
else
|
||||||
{
|
{
|
||||||
@@ -79,73 +117,6 @@ public partial class Manager : Node
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (!Globals.Instance._anyMovement)
|
|
||||||
// {
|
|
||||||
// if (_team.Any(w => w._hovered))
|
|
||||||
// {
|
|
||||||
// _hoveredWorker = _team.Single(w => w._hovered);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// _hoveredWorker = null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (!_ready)
|
|
||||||
// {
|
|
||||||
// if (_heldWorker == null)
|
|
||||||
// {
|
|
||||||
// if (Input.IsActionJustReleased("left_click"))
|
|
||||||
// {
|
|
||||||
// if (!_hoveredWorker._placed)
|
|
||||||
// {
|
|
||||||
// _heldWorker = _hoveredWorker;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// Vector2 mousePosition = GetViewport().GetMousePosition();
|
|
||||||
// _heldWorker.Position = mousePosition;
|
|
||||||
// if (Input.IsActionJustReleased("left_click"))
|
|
||||||
// {
|
|
||||||
// PlaceWorker(_heldWorker, mousePosition);
|
|
||||||
// _heldWorker = null;
|
|
||||||
// if (_team.Where(w => w._placed).ToList().Count >= _team.Count)
|
|
||||||
// {
|
|
||||||
// _ready = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// if ((_selectedWorker == null || _selectedWorker != _hoveredWorker) && (_hoveredWorker?._available ?? false))
|
|
||||||
// {
|
|
||||||
// if (Input.IsActionJustReleased("left_click"))
|
|
||||||
// {
|
|
||||||
// _selectedWorker = _hoveredWorker;
|
|
||||||
// _selectedWorker._selected = true;
|
|
||||||
// _cue.Don(_selectedWorker.GetNode<Ball>("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();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ChangeHealth(int CHANGE)
|
public void ChangeHealth(int CHANGE)
|
||||||
@@ -173,22 +144,6 @@ public partial class Manager : Node
|
|||||||
// AddChild(WORKER);
|
// AddChild(WORKER);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
public void PlaceWorker(Worker WORKER, Vector2 POSITION)
|
|
||||||
{
|
|
||||||
WORKER._placed = true;
|
|
||||||
WORKER._potted = false;
|
|
||||||
WORKER.ChangeBallPosition(POSITION);
|
|
||||||
WORKER.GetNode<CollisionShape2D>("Bounds").Disabled = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void PotWorker(Worker WORKER)
|
|
||||||
{
|
|
||||||
Panel ballReturn = GetNode<ManagerPanel>("Panel").GetNode<Panel>("BallReturn");
|
|
||||||
WORKER.PotBall();
|
|
||||||
WORKER.ChangeBallPosition(new Vector2(ballReturn.GlobalPosition.X + ballReturn.Size.X / 2, ballReturn.GlobalPosition.Y + 50));
|
|
||||||
_ready = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetSprite(string PATH)
|
public void SetSprite(string PATH)
|
||||||
{
|
{
|
||||||
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
||||||
@@ -196,20 +151,11 @@ public partial class Manager : Node
|
|||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
Panel ballReturn = GetNode<ManagerPanel>("Panel").GetNode<Panel>("BallReturn");
|
|
||||||
|
|
||||||
for (int i = 0; i < _team.Count; i++)
|
for (int i = 0; i < _team.Count; i++)
|
||||||
{
|
{
|
||||||
_team[i]._ball.GetNode<CollisionShape2D>("Bounds").Disabled = true;
|
_team[i]._tempBall.Position = new Vector2(_ballReturn.GlobalPosition.X + _ballReturn.Size.X / 2, _ballReturn.GlobalPosition.Y + 50 * (i + 1));
|
||||||
if (_team[i].GetNodeOrNull<Ball>("Ball") != null)
|
_team[i].TempBallShow();
|
||||||
{
|
|
||||||
_team[i].RemoveChild(_team[i]._ball);
|
|
||||||
}
|
|
||||||
_team[i].AddChild(_team[i]._tempBall);
|
|
||||||
_team[i]._tempBall.Position = new Vector2(ballReturn.GlobalPosition.X + ballReturn.Size.X / 2, ballReturn.GlobalPosition.Y + 50 * (i + 1));
|
|
||||||
// _team[i].Position = new Vector2(ballReturn.GlobalPosition.X + ballReturn.Size.X / 2, ballReturn.GlobalPosition.Y + 50 * (i + 1));
|
|
||||||
|
|
||||||
// AddChild(_team[i]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,7 +165,7 @@ public partial class Manager : Node
|
|||||||
{
|
{
|
||||||
_selectedWorker.GetNode<Ball>("Ball").ApplyCentralImpulse(IMPULSE);
|
_selectedWorker.GetNode<Ball>("Ball").ApplyCentralImpulse(IMPULSE);
|
||||||
_selectedWorker._selected = false;
|
_selectedWorker._selected = false;
|
||||||
_selectedWorker._launched = true;
|
_selectedWorker.Launch();
|
||||||
_selectedWorker = null;
|
_selectedWorker = null;
|
||||||
_cue.Doff();
|
_cue.Doff();
|
||||||
}
|
}
|
||||||
|
|||||||
7
Gameplay/Procables.cs
Normal file
7
Gameplay/Procables.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class Procables : Node
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
1
Gameplay/Procables.cs.uid
Normal file
1
Gameplay/Procables.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://d1sbv0yepmvrf
|
||||||
@@ -10,7 +10,7 @@ public partial class TempBall : Area2D
|
|||||||
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnMouseEntered()
|
private void OnMouseEntered()
|
||||||
{
|
{
|
||||||
if (_active)
|
if (_active)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ public partial class Worker : Node2D
|
|||||||
public TempBall _tempBall;
|
public TempBall _tempBall;
|
||||||
public Ball _ball;
|
public Ball _ball;
|
||||||
|
|
||||||
public static Worker _Create()
|
// public static Worker _Create()
|
||||||
{
|
// {
|
||||||
PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/worker.tscn");
|
// PackedScene scene = ResourceLoader.Load<PackedScene>("res://Gameplay/worker.tscn");
|
||||||
Worker newWorker = scene.Instantiate<Worker>();
|
// Worker newWorker = scene.Instantiate<Worker>();
|
||||||
return newWorker;
|
// return newWorker;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
@@ -28,18 +28,25 @@ public partial class Worker : Node2D
|
|||||||
RemoveChild(_tempBall);
|
RemoveChild(_tempBall);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void _Process(double delta)
|
public override void _Process(double delta)
|
||||||
{
|
|
||||||
_hovered = _ball._hovered || _tempBall._hovered;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void ChangeBallPosition(Vector2 NEWPOSITION)
|
|
||||||
{
|
{
|
||||||
RemoveChild(_ball);
|
_hovered = (_ball._active && _ball._hovered) || (_tempBall._active && _tempBall._hovered);
|
||||||
_ball.Position = NEWPOSITION;
|
if (_launched)
|
||||||
AddChild(_ball);
|
{
|
||||||
|
if (!_ball._launched)
|
||||||
|
{
|
||||||
|
_launched = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public virtual void ChangeBallPosition(Vector2 NEWPOSITION)
|
||||||
|
// {
|
||||||
|
// RemoveChild(_ball);
|
||||||
|
// _ball.Position = NEWPOSITION;
|
||||||
|
// AddChild(_ball);
|
||||||
|
// }
|
||||||
|
|
||||||
public virtual void ChangeDefense(int CHANGE)
|
public virtual void ChangeDefense(int CHANGE)
|
||||||
{
|
{
|
||||||
_defense += CHANGE;
|
_defense += CHANGE;
|
||||||
@@ -47,14 +54,16 @@ public partial class Worker : Node2D
|
|||||||
if (_defense < 0)
|
if (_defense < 0)
|
||||||
{
|
{
|
||||||
EmitSignal(SignalName.DamageOverflow, _defense);
|
EmitSignal(SignalName.DamageOverflow, _defense);
|
||||||
if (!_isLead)
|
|
||||||
{
|
|
||||||
PotBall();
|
|
||||||
}
|
|
||||||
_defense = 0;
|
_defense = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Launch()
|
||||||
|
{
|
||||||
|
_launched = true;
|
||||||
|
_ball.Launch();
|
||||||
|
}
|
||||||
|
|
||||||
public void SetSprite(string PATH)
|
public void SetSprite(string PATH)
|
||||||
{
|
{
|
||||||
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
GetNode<Sprite2D>("Image").Texture = GD.Load<Texture2D>(PATH);
|
||||||
@@ -62,25 +71,55 @@ public partial class Worker : Node2D
|
|||||||
|
|
||||||
public void PlaceBall(Vector2 POSITION)
|
public void PlaceBall(Vector2 POSITION)
|
||||||
{
|
{
|
||||||
|
_available = true;
|
||||||
|
_placed = true;
|
||||||
|
_potted = false;
|
||||||
_ball.Position = POSITION;
|
_ball.Position = POSITION;
|
||||||
|
_ball._active = true;
|
||||||
|
_ball._placed = true;
|
||||||
|
_ball._potted = false;
|
||||||
|
_ball._active = true;
|
||||||
|
|
||||||
AddChild(_ball);
|
AddChild(_ball);
|
||||||
|
TempBallHide();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PotBall()
|
public void PotBall()
|
||||||
{
|
{
|
||||||
_ball.Pot();
|
_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);
|
RemoveChild(_ball);
|
||||||
|
TempBallShow();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnBallHit()
|
public void TempBallHide()
|
||||||
{
|
{
|
||||||
// if (!_launched)
|
_tempBall._active = false;
|
||||||
// {
|
RemoveChild(_tempBall);
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// Ball target = (Ball)TARGET;
|
|
||||||
// target.ChangeDefense(-1);
|
|
||||||
// ChangeDefense(-6);
|
|
||||||
// GD.Print("Defense: " + _defense);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,10 @@
|
|||||||
[gd_scene load_steps=2 format=3 uid="uid://5ymxo45j4ryt"]
|
[gd_scene load_steps=3 format=3 uid="uid://5ymxo45j4ryt"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://0c1u4l8lu07h" path="res://Gameplay/Battle.cs" id="1_i431l"]
|
[ext_resource type="Script" uid="uid://0c1u4l8lu07h" path="res://Gameplay/Battle.cs" id="1_i431l"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://dsprg4uahkylm" path="res://Gameplay/table.tscn" id="2_fkh6t"]
|
||||||
|
|
||||||
[node name="Battle" type="Node" groups=["battles"]]
|
[node name="Battle" type="Node" groups=["battles"]]
|
||||||
script = ExtResource("1_i431l")
|
script = ExtResource("1_i431l")
|
||||||
|
|
||||||
|
[node name="Table" parent="." instance=ExtResource("2_fkh6t")]
|
||||||
|
position = Vector2(960, 540)
|
||||||
|
|||||||
@@ -1,6 +1,14 @@
|
|||||||
[gd_scene load_steps=2 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="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"]
|
||||||
|
|
||||||
[node name="Main" type="Node"]
|
[node name="Main" type="Node"]
|
||||||
script = ExtResource("1_0xm2m")
|
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_vkc8e")]
|
||||||
|
|||||||
@@ -138,97 +138,13 @@ theme_override_styles/panel = SubResource("StyleBoxFlat_j2own")
|
|||||||
layout_mode = 0
|
layout_mode = 0
|
||||||
offset_left = 50.0
|
offset_left = 50.0
|
||||||
offset_top = 50.0
|
offset_top = 50.0
|
||||||
offset_right = 150.0
|
offset_right = 100.0
|
||||||
offset_bottom = 150.0
|
offset_bottom = 100.0
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament1"]
|
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament1"]
|
||||||
position = Vector2(50, 50)
|
position = Vector2(50, 50)
|
||||||
scale = Vector2(1.5, 1.5)
|
scale = Vector2(1.5, 1.5)
|
||||||
|
|
||||||
[node name="DeskOrnament2" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 50.0
|
|
||||||
offset_top = 200.0
|
|
||||||
offset_right = 150.0
|
|
||||||
offset_bottom = 300.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament2"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[node name="DeskOrnament3" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 50.0
|
|
||||||
offset_top = 350.0
|
|
||||||
offset_right = 150.0
|
|
||||||
offset_bottom = 450.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament3"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[node name="DeskOrnament4" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 50.0
|
|
||||||
offset_top = 500.0
|
|
||||||
offset_right = 150.0
|
|
||||||
offset_bottom = 600.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament4"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[node name="DeskOrnament5" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 300.0
|
|
||||||
offset_top = 50.0
|
|
||||||
offset_right = 400.0
|
|
||||||
offset_bottom = 150.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament5"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[node name="DeskOrnament6" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 300.0
|
|
||||||
offset_top = 200.0
|
|
||||||
offset_right = 400.0
|
|
||||||
offset_bottom = 300.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament6"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[node name="DeskOrnament7" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 300.0
|
|
||||||
offset_top = 350.0
|
|
||||||
offset_right = 400.0
|
|
||||||
offset_bottom = 450.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament7"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[node name="DeskOrnament8" type="Panel" parent="Desk"]
|
|
||||||
layout_mode = 0
|
|
||||||
offset_left = 300.0
|
|
||||||
offset_top = 500.0
|
|
||||||
offset_right = 400.0
|
|
||||||
offset_bottom = 600.0
|
|
||||||
theme_override_styles/panel = SubResource("StyleBoxFlat_058dj")
|
|
||||||
|
|
||||||
[node name="Sprite2D" type="Sprite2D" parent="Desk/DeskOrnament8"]
|
|
||||||
position = Vector2(50, 50)
|
|
||||||
scale = Vector2(1.5, 1.5)
|
|
||||||
|
|
||||||
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
|
||||||
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
|
||||||
|
|||||||
6
Gameplay/procables.tscn
Normal file
6
Gameplay/procables.tscn
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[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")
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
radius = 18.0
|
radius = 18.0
|
||||||
|
|
||||||
[node name="TempBall" type="Area2D"]
|
[node name="TempBall" type="Area2D"]
|
||||||
|
z_index = 2
|
||||||
script = ExtResource("1_y0oty")
|
script = ExtResource("1_y0oty")
|
||||||
|
|
||||||
[node name="Image" type="Sprite2D" parent="."]
|
[node name="Image" type="Sprite2D" parent="."]
|
||||||
|
|||||||
@@ -14,4 +14,4 @@ visible = false
|
|||||||
|
|
||||||
[node name="TempBall" parent="." instance=ExtResource("3_4poc8")]
|
[node name="TempBall" parent="." instance=ExtResource("3_4poc8")]
|
||||||
|
|
||||||
[connection signal="OnHit" from="Ball" to="." method="OnHit"]
|
[connection signal="OnCollision" from="Ball" to="." method="ProcessOnCollision"]
|
||||||
|
|||||||
7
Proc.cs
Normal file
7
Proc.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using Godot;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class Proc : Node
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
1
Proc.cs.uid
Normal file
1
Proc.cs.uid
Normal file
@@ -0,0 +1 @@
|
|||||||
|
uid://blyqty3080pjv
|
||||||
Reference in New Issue
Block a user