From 853960932ffe26bceb73b3f7ca342734b13291d9 Mon Sep 17 00:00:00 2001 From: Conor Edmonds Date: Tue, 16 Sep 2025 22:07:16 -0400 Subject: [PATCH] Tuesday, 16 September 2025 22:07:13 --- Gameplay/Cell.cs | 2 +- Gameplay/Desk.cs | 10 ++++--- Gameplay/Manager.cs | 66 +---------------------------------------- Gameplay/cell.tscn | 2 +- Gameplay/condition.tscn | 2 +- Gameplay/worker.tscn | 2 +- 6 files changed, 11 insertions(+), 73 deletions(-) diff --git a/Gameplay/Cell.cs b/Gameplay/Cell.cs index a651850..fa513e9 100644 --- a/Gameplay/Cell.cs +++ b/Gameplay/Cell.cs @@ -3,5 +3,5 @@ using System; public partial class Cell : Sprite2D { - public int _row, _column; + public int _row, _column, _size; } diff --git a/Gameplay/Desk.cs b/Gameplay/Desk.cs index 5dfb501..46593d3 100644 --- a/Gameplay/Desk.cs +++ b/Gameplay/Desk.cs @@ -13,9 +13,6 @@ public partial class Desk : Node2D _grid = GetNode("Cells"); _light = GetNode("Light"); _dark = GetNode("Dark"); - - _cellDimensions = new Vector2(50, 50); - } public Cell GetCellFromAddress(int ROW, int COLUMN) @@ -43,9 +40,13 @@ public partial class Desk : Node2D return new Vector2(-1, -1); } - public void Setup(int ROWS, int COLUMNS) + public void Setup(int ROWS, int COLUMNS, int CELLSIZE) { _gridDimensions = new Vector2(COLUMNS, ROWS); + _cellDimensions = new Vector2(CELLSIZE, CELLSIZE); + _light.Scale = _cellDimensions / _light.Texture.GetSize(); + _dark.Scale = _cellDimensions / _dark.Texture.GetSize(); + _topLeft = Globals.Instance._screenCenter - _cellDimensions * _gridDimensions / 2 + _cellDimensions / 2; Vector2 position; Node2D row; @@ -62,6 +63,7 @@ public partial class Desk : Node2D { position = _topLeft + new Vector2(_cellDimensions.X * j, _cellDimensions.Y * i); column = (Cell)((i + j) % 2 == 0 ? _light : _dark).Duplicate(); + column._size = (int)(column.Texture.GetSize().Y * column.Scale.Y); column.Name = "C" + (j + 1); column.GlobalPosition = position; column.Visible = true; diff --git a/Gameplay/Manager.cs b/Gameplay/Manager.cs index 298dd40..eda7c06 100644 --- a/Gameplay/Manager.cs +++ b/Gameplay/Manager.cs @@ -30,7 +30,7 @@ public partial class Manager : Node2D // _managerPanel = GetNode("Panel"); _desk = GetNode("Desk"); - _desk.Setup(15, 20); + _desk.Setup(15, 20, 50); _cell = _desk.GetCellFromAddress(1, 1); // _movements.Insert(0, _deskPosition); @@ -47,7 +47,6 @@ public partial class Manager : Node2D public override void _Process(double DELTA_) { ChainMovement(); - ChainSelection(); } public void AddWorker(Worker NEWWORKER) @@ -104,52 +103,6 @@ public partial class Manager : Node2D } } - public void ChainSelection() - { - // if (_heldWorker != null) - // { - // _heldWorker.GlobalPosition = GetGlobalMousePosition(); - // if (_hoveredWorker != null && _heldWorker != _hoveredWorker) - // { - // SwapPositions(_heldWorker, _hoveredWorker); - // _hoveredWorker._hovered = false; - // _hoveredWorker = null; - // } - // if (Input.IsActionJustReleased("left_click")) - // { - // _heldWorker.GlobalPosition = _desk.GetPositionFromAddress((int)_heldWorker._deskPosition.Y, (int)_heldWorker._deskPosition.X); - // _heldWorker._held = false; - // _heldWorker = null; - // _hoveredWorker._hovered = false; - // _hoveredWorker = null; - // } - // } - // else - // { - // if (_selectedWorker != null) - // { - // if (Input.IsActionPressed("left_click") && (GetGlobalMousePosition() - _selectedWorker._chainPosition).Length() > 5) - // { - - // _heldWorker = _selectedWorker; - // _heldWorker._held = true; - // _heldWorker._selected = false; - // _selectedWorker = null; - // } - // } - // if (_hoveredWorker != null) - // { - // if (Input.IsActionJustPressed("left_click")) - // { - // _selectedWorker = _hoveredWorker; - // _selectedWorker._selected = true; - // _selectedWorker._hovered = false; - // _hoveredWorker = null; - // } - // } - // } - } - public void ChangeHealth(int CHANGE) { _health += CHANGE; @@ -168,22 +121,5 @@ public partial class Manager : Node2D { _imagePath = PATH; } - - // public void Start() - // { - // _workers[0].GlobalPosition = _desk.GetPositionFromAddress(1, 1); - // } - - private void SetHoveredWorker(Worker HOVEREDWORKER) - { - if (HOVEREDWORKER._hovered) - { - _hoveredWorker = HOVEREDWORKER; - } - else - { - _hoveredWorker = null; - } - } } diff --git a/Gameplay/cell.tscn b/Gameplay/cell.tscn index 24244b6..717285b 100644 --- a/Gameplay/cell.tscn +++ b/Gameplay/cell.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://b7yrd35gvisom"] -[ext_resource type="Script" uid="uid://cmw4772lmwms0" path="res://Gameplay/Cell.cs" id="1_kyub7"] +[ext_resource type="Script" path="res://Gameplay/Cell.cs" id="1_kyub7"] [node name="Cell" type="Sprite2D"] script = ExtResource("1_kyub7") diff --git a/Gameplay/condition.tscn b/Gameplay/condition.tscn index e644137..27e4bf1 100644 --- a/Gameplay/condition.tscn +++ b/Gameplay/condition.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dsrjrwd1eyeu3"] -[ext_resource type="Script" uid="uid://vj2qucjwah5y" path="res://Gameplay/Condition.cs" id="1_s3ntn"] +[ext_resource type="Script" path="res://Gameplay/Condition.cs" id="1_s3ntn"] [node name="Condition" type="Node"] script = ExtResource("1_s3ntn") diff --git a/Gameplay/worker.tscn b/Gameplay/worker.tscn index 7d43f97..ef308f2 100644 --- a/Gameplay/worker.tscn +++ b/Gameplay/worker.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=4 format=3 uid="uid://37hjd4v3p42o"] -[ext_resource type="Script" uid="uid://bk6qk4rjmsvtn" path="res://Gameplay/Worker.cs" id="1_e314i"] +[ext_resource type="Script" path="res://Gameplay/Worker.cs" id="1_e314i"] [ext_resource type="Texture2D" uid="uid://dmispjd3fmmks" path="res://art/worker_test.png" id="2_m3kx1"] [sub_resource type="CircleShape2D" id="CircleShape2D_4poc8"]