Thursday, 11 September 2025 02:29:56
This commit is contained in:
@@ -15,16 +15,12 @@ public partial class Desk : Node2D
|
||||
_dark = GetNode<Sprite2D>("Dark");
|
||||
|
||||
_cellDimensions = new Vector2(50, 50);
|
||||
_gridDimensions = new Vector2(10, 20);
|
||||
_topLeft = Globals.Instance._screenCenter - _cellDimensions * _gridDimensions / 2 + _cellDimensions / 2;
|
||||
GD.Print(_topLeft);
|
||||
Setup();
|
||||
|
||||
}
|
||||
|
||||
public Vector2 GetPositionFromAddress(int ROW, int COLUMN)
|
||||
{
|
||||
|
||||
|
||||
|
||||
if (_grid.HasNode("R" + ROW))
|
||||
{
|
||||
Node2D row = _grid.GetNode<Node2D>("R" + ROW);
|
||||
@@ -37,8 +33,10 @@ public partial class Desk : Node2D
|
||||
return new Vector2(-1, -1);
|
||||
}
|
||||
|
||||
public void Setup()
|
||||
public void Setup(int ROWS, int COLUMNS)
|
||||
{
|
||||
_gridDimensions = new Vector2(COLUMNS, ROWS);
|
||||
_topLeft = Globals.Instance._screenCenter - _cellDimensions * _gridDimensions / 2 + _cellDimensions / 2;
|
||||
Vector2 position;
|
||||
Node2D row;
|
||||
Sprite2D column;
|
||||
|
||||
@@ -28,22 +28,23 @@ public partial class Manager : Node2D
|
||||
|
||||
SetSprite("res://art/ness.png");
|
||||
|
||||
_managerPanel = GetNode<ManagerPanel>("Panel");
|
||||
// _managerPanel = GetNode<ManagerPanel>("Panel");
|
||||
_desk = GetNode<Desk>("Desk");
|
||||
_desk.Setup(15, 20);
|
||||
|
||||
_deskPosition = new Vector2(1, 1);
|
||||
// _movements.Insert(0, _deskPosition);
|
||||
_image = GetNode<Sprite2D>("Image");
|
||||
_image.GlobalPosition = _desk.GetPositionFromAddress(1, 1);
|
||||
|
||||
_managerPanel.SetManager(this);
|
||||
// _managerPanel.SetManager(this);
|
||||
for (int i = 0; i < Globals.Instance._random.Next(3, 6); i++)
|
||||
{
|
||||
AddWorker(null);
|
||||
}
|
||||
}
|
||||
|
||||
public override void _PhysicsProcess(double DELTA_)
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
ChainMovement();
|
||||
ChainSelection();
|
||||
@@ -89,6 +90,7 @@ public partial class Manager : Node2D
|
||||
{
|
||||
for (int i = 0; i < _workers.Count && i < _movements.Count; i++)
|
||||
{
|
||||
_workers[i]._deskPosition = _movements[i];
|
||||
_workers[i].GlobalPosition = _desk.GetPositionFromAddress((int)_movements[i].Y, (int)_movements[i].X);
|
||||
}
|
||||
}
|
||||
@@ -112,7 +114,7 @@ public partial class Manager : Node2D
|
||||
}
|
||||
if (Input.IsActionJustReleased("left_click"))
|
||||
{
|
||||
_heldWorker.GlobalPosition = _heldWorker._chainPosition;
|
||||
_heldWorker.GlobalPosition = _desk.GetPositionFromAddress((int)_heldWorker._deskPosition.Y, (int)_heldWorker._deskPosition.X);
|
||||
_heldWorker._held = false;
|
||||
_heldWorker = null;
|
||||
}
|
||||
@@ -169,13 +171,12 @@ public partial class Manager : Node2D
|
||||
|
||||
public void SwapPositions(Worker A, Worker B)
|
||||
{
|
||||
Vector2 chainPositionA = A._chainPosition, chainPositionB = B._chainPosition;
|
||||
List<Vector2> movesA = new(A._moves), movesB = new(B._moves);
|
||||
B.Position = chainPositionA;
|
||||
A._chainPosition = chainPositionB;
|
||||
B._chainPosition = chainPositionA;
|
||||
A._moves = movesB;
|
||||
B._moves = movesA;
|
||||
Vector2 deskPositionA = A._deskPosition, deskPositionB = B._deskPosition;
|
||||
|
||||
B.GlobalPosition = _desk.GetPositionFromAddress((int)deskPositionA.Y, (int)deskPositionA.X);
|
||||
A._deskPosition = deskPositionB;
|
||||
B._deskPosition = deskPositionA;
|
||||
|
||||
int indexA = _workers.IndexOf(A), indexB = _workers.IndexOf(B);
|
||||
Worker C = A;
|
||||
_workers[indexA] = B;
|
||||
|
||||
@@ -48,14 +48,9 @@ public partial class Worker : CharacterBody2D
|
||||
|
||||
public override void _Process(double DELTA_)
|
||||
{
|
||||
if (Globals.Instance._battleRunning)
|
||||
{
|
||||
_chainPosition = GlobalPosition;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// _chainPosition = GlobalPosition;
|
||||
|
||||
}
|
||||
|
||||
// public void ChangeHealth(int CHANGE, Node CHANGEMAKER)
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
script = ExtResource("1_ivgep")
|
||||
|
||||
[node name="Panel" parent="." instance=ExtResource("3_xooeg")]
|
||||
visible = false
|
||||
offset_left = 101.0
|
||||
offset_top = 150.0
|
||||
offset_right = 551.0
|
||||
|
||||
Reference in New Issue
Block a user