diff --git a/Gameplay/Actions/BasicAttack.cs b/Gameplay/Actions/BasicAttack.cs deleted file mode 100644 index feea09e..0000000 --- a/Gameplay/Actions/BasicAttack.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Godot; -using System; -using System.Collections.Generic; - -public partial class BasicAttack : Action -{ - public BasicAttack(Node2D OWNER) : base(OWNER) - { - _triggers.Add(Trigger.On.Collision); - } - - public override void Fire() - { - if (_target != null) - { - if (_target is Worker) - { - Worker target = (Worker)_target; - if (_owner is Worker) - { - Worker owner = (Worker)_owner; - if (target._manager != owner._manager) - { - int damage = -owner._aptitude._default / 2; - // target.ChangeHealth(damage, owner); - } - } - - } - _target = null; - } - - } - -} diff --git a/Gameplay/Actions/Caffeinate.cs b/Gameplay/Actions/Caffeinate.cs deleted file mode 100644 index 2b74a9f..0000000 --- a/Gameplay/Actions/Caffeinate.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Godot; -using System; - -public partial class Caffeinate : Action -{ - public Caffeinate(Node2D OWNER) : base(OWNER) - { - _triggers.Add(Trigger.On.Collision); - } - - public override void Fire() - { - if (_target != null) - { - if (_target is Worker) - { - Worker target = (Worker)_target; - if (!target.HasCondition(GetType().ToString())) - { - target._conditions.AddChild(new Caffeinated(target)); - } - } - _target = null; - } - } -} diff --git a/Gameplay/Actions/basic_attack.tscn b/Gameplay/Actions/basic_attack.tscn deleted file mode 100644 index 6b22c6e..0000000 --- a/Gameplay/Actions/basic_attack.tscn +++ /dev/null @@ -1,3 +0,0 @@ -[gd_scene format=3 uid="uid://bih70e65g1108"] - -[node name="BasicAttack" type="Node"] diff --git a/Gameplay/Conditions/Caffeinated.cs b/Gameplay/Conditions/Caffeinated.cs deleted file mode 100644 index a1ea63e..0000000 --- a/Gameplay/Conditions/Caffeinated.cs +++ /dev/null @@ -1,30 +0,0 @@ -using Godot; -using System; - -public partial class Caffeinated : Condition -{ - public Caffeinated(Node2D OWNER) : base(OWNER) - { - _triggers.Add(Trigger.On.Time); - _countdown = 2; - _timer.OneShot = true; - _timer.WaitTime = _countdown; - _timer.Autostart = true; - AddChild(_timer); - _timer.Timeout += Fire; - if (_owner is Worker) - { - ((Worker)_owner)._agility._effective += 3; - } - } - - public override void Fire() - { - _expired = true; - if (_owner is Worker) - { - ((Worker)_owner)._agility._effective -= 3; - ((Worker)_owner)._conditions.RemoveChild(this); - } - } -} diff --git a/Gameplay/Conditions/Caffeinated.cs.uid b/Gameplay/Conditions/Caffeinated.cs.uid deleted file mode 100644 index 80866ae..0000000 --- a/Gameplay/Conditions/Caffeinated.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ciwja82k4ihw6 diff --git a/Gameplay/Conditions/Spiky.cs b/Gameplay/Conditions/Spiky.cs deleted file mode 100644 index 6707617..0000000 --- a/Gameplay/Conditions/Spiky.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Godot; -using System; - -public partial class Spiky : Condition -{ - public Spiky(Node2D OWNER) : base(OWNER) - { - _triggers.Add(Trigger.On.Collision); - } - - public override void Fire() - { - if (_target != null) - { - if (_target is Worker) - { - Worker target = (Worker)_target; - target._rotationalForce += 10; - // target.ChangeHealth(-1, _owner); - } - _target = null; - } - } -} diff --git a/Gameplay/Conditions/Spiky.cs.uid b/Gameplay/Conditions/Spiky.cs.uid deleted file mode 100644 index 80866ae..0000000 --- a/Gameplay/Conditions/Spiky.cs.uid +++ /dev/null @@ -1 +0,0 @@ -uid://ciwja82k4ihw6 diff --git a/Gameplay/Conditions/caffeinated.tscn b/Gameplay/Conditions/caffeinated.tscn deleted file mode 100644 index 91642d0..0000000 --- a/Gameplay/Conditions/caffeinated.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://dtnwf7i53hix6"] - -[ext_resource type="Script" path="res://Gameplay/Effects/Spiky.cs" id="1_pcknv"] - -[node name="Spiky" type="Node"] -script = ExtResource("1_pcknv") diff --git a/Gameplay/Conditions/spiky.tscn b/Gameplay/Conditions/spiky.tscn deleted file mode 100644 index 0767fed..0000000 --- a/Gameplay/Conditions/spiky.tscn +++ /dev/null @@ -1,6 +0,0 @@ -[gd_scene load_steps=2 format=3 uid="uid://devvkr2joh1u2"] - -[ext_resource type="Script" path="res://Gameplay/Effects/Spiky.cs" id="1_pcknv"] - -[node name="Spiky" type="Node"] -script = ExtResource("1_pcknv") diff --git a/Gameplay/Desk.cs b/Gameplay/Desk.cs index 0791594..06dd875 100644 --- a/Gameplay/Desk.cs +++ b/Gameplay/Desk.cs @@ -1,13 +1,66 @@ using Godot; using System; +using System.Collections.Generic; -public partial class Desk : Sprite2D +public partial class Desk : Node2D { + public Vector2 _topLeft, _cellDimensions, _gridDimensions; + public Sprite2D _light, _dark; + Node2D _grid; + public override void _Ready() + { + _grid = GetNode("Cells"); + _light = GetNode("Light"); + _dark = GetNode("Dark"); - public override void _Ready() - { - Position = Globals.Instance._screenCenter; - } + _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("R" + ROW); + if (row.HasNode("C" + COLUMN)) + { + Sprite2D column = row.GetNode("C" + COLUMN); + return column.GlobalPosition; + } + } + return new Vector2(-1, -1); + } + + public void Setup() + { + Vector2 position; + Node2D row; + Sprite2D column; + for (int i = 0; i < _gridDimensions.Y; i++) + { + if (i <= _grid.GetChildCount()) + { + row = new(); + row.Name = "R" + (i + 1); + _grid.AddChild(row); + } + for (int j = 0; j < _gridDimensions.X; j++) + { + position = _topLeft + new Vector2(_cellDimensions.X * j, _cellDimensions.Y * i); + column = (Sprite2D)((i + j) % 2 == 0 ? _light : _dark).Duplicate(); + column.Name = "C" + (j + 1); + column.GlobalPosition = position; + column.Visible = true; + row = _grid.GetNode("R" + (i + 1)); + row.AddChild(column); + } + } + } } diff --git a/Gameplay/Globals.cs b/Gameplay/Globals.cs index 3800164..7a8fb63 100644 --- a/Gameplay/Globals.cs +++ b/Gameplay/Globals.cs @@ -20,6 +20,5 @@ public partial class Globals : Node _screenSize = _viewport.GetVisibleRect().Size; _screenCenter = _screenSize / 2; } - - + } diff --git a/Gameplay/Manager.cs b/Gameplay/Manager.cs index a5dde84..d1e5300 100644 --- a/Gameplay/Manager.cs +++ b/Gameplay/Manager.cs @@ -6,16 +6,20 @@ using System.Linq; /// TODO alter code to player vs computer to account for differing logic public partial class Manager : Node2D { - public bool _dead, _ready; + public bool _dead, _ready, _moving; public int _ballsMoving = 0, _health = 10, _healthMax, _speed = 5; public string _imagePath; + public Vector2 _deskPosition; + public List _movements = new(); public CollisionShape2D _startArea; public ManagerPanel _managerPanel = null; + public Sprite2D _image; + public Desk _desk = null; public Manager _opponent; public List _workers = new(); - public Worker _hoveredWorker, _selectedWorker, _heldWorker; public Node _workerNode; - public List _tchotckes = new(); + public Worker _hoveredWorker, _selectedWorker, _heldWorker; + // public List _tchotckes = new(); public override void _Ready() { @@ -25,103 +29,82 @@ public partial class Manager : Node2D SetSprite("res://art/ness.png"); _managerPanel = GetNode("Panel"); + _desk = GetNode("Desk"); + + _deskPosition = new Vector2(1, 1); + // _movements.Insert(0, _deskPosition); + _image = GetNode("Image"); + _image.GlobalPosition = _desk.GetPositionFromAddress(1, 1); _managerPanel.SetManager(this); - - Worker newWorker = Globals.Instance._workerScene.Instantiate(); - newWorker.Position = Globals.Instance._screenCenter; - newWorker._manager = this; - _workerNode.AddChild(newWorker); - _workers.Add(newWorker); - - newWorker = Globals.Instance._workerScene.Instantiate(); - newWorker.Position = Globals.Instance._screenCenter; - newWorker._manager = this; - _workerNode.AddChild(newWorker); - _workers.Add(newWorker); - - newWorker = Globals.Instance._workerScene.Instantiate(); - newWorker.Position = Globals.Instance._screenCenter; - newWorker._manager = this; - _workerNode.AddChild(newWorker); - _workers.Add(newWorker); - - newWorker = Globals.Instance._workerScene.Instantiate(); - newWorker.Position = Globals.Instance._screenCenter; - newWorker._manager = this; - _workerNode.AddChild(newWorker); - _workers.Add(newWorker); - - // for (int i = 0; i < _workers.Count; i++) - // { - // _workers[i]._healthBar.Position = _managerPanel.GetNode("Team").GetNode("T"+(i+1)).GlobalPosition; - // } - - // Tchotchke newTchotchke = ResourceLoader.Load("res://Gameplay/Tchotchkes/awfully_hot_coffee_pot.tscn").Instantiate(); - // newTchotchke.Position = new Vector2(Globals.Instance._screenSize.X - 100, Globals.Instance._screenCenter.Y); - // AddChild(newTchotchke); - // _tchotckes.Add(newTchotchke); + for (int i = 0; i < Globals.Instance._random.Next(3, 6); i++) + { + AddWorker(null); + } } - public override void _Process(double DELTA_) + public override void _PhysicsProcess(double DELTA_) { - if (Globals.Instance._battleRunning) - { - ChainMovement(); - } - else - { - MoveChain(); - } + ChainMovement(); + ChainSelection(); + } + + public void AddWorker(Worker NEWWORKER) + { + Worker newWorker = NEWWORKER ?? Globals.Instance._workerScene.Instantiate(); + newWorker._deskPosition = new Vector2(1, 1); + newWorker.Position = _desk.GetPositionFromAddress(1, 1); + newWorker._manager = this; + _workers.Add(newWorker); + _workerNode.AddChild(newWorker); + newWorker.SetHovered += SetHoveredWorker; } public void ChainMovement() { - Vector2 mousePosition = GetGlobalMousePosition(); - // _workers[0].LookAt(mousePosition); - Vector2 mouseOffset = mousePosition - _workers[0].GlobalPosition; - if (mouseOffset.Length() > _workers[0]._size) + Vector2 direction = Vector2.Zero; + if (Input.IsActionJustPressed("move_up")) { - Vector2 mouseOffsetNormal = mouseOffset.Normalized(); - _workers[0].GlobalPosition += mouseOffsetNormal * _speed; - _workers[0]._distanceTraveled += _speed; - _workers[0]._moves.Insert(0, _workers[0].GlobalPosition); + direction = Vector2.Up; + } + else if (Input.IsActionJustPressed("move_down")) + { + direction = Vector2.Down; + } + else if (Input.IsActionJustPressed("move_left")) + { + direction = Vector2.Left; + } + else if (Input.IsActionJustPressed("move_right")) + { + direction = Vector2.Right; + } - for (int i = 1; i < _workers.Count; i++) + if (direction != Vector2.Zero) + { + Vector2 newPostion = _desk.GetPositionFromAddress((int)(_deskPosition.Y + direction.Y), (int)(_deskPosition.X + direction.X)); + if (newPostion != new Vector2(-1, -1)) { - if (_workers[i - 1]._distanceTraveled > (_workers[i - 1]._size + _workers[i]._size) * 1.2f) + if (_movements.Count > 0) { - _workers[i]._distanceTraveled += _speed; - _workers[i].GlobalPosition = _workers[i - 1]._moves[^1]; - _workers[i]._moves.Insert(0, _workers[i - 1]._moves[^1]); - _workers[i - 1]._moves.RemoveAt(_workers[i - 1]._moves.Count - 1); + for (int i = 0; i < _workers.Count && i < _movements.Count; i++) + { + _workers[i].GlobalPosition = _desk.GetPositionFromAddress((int)_movements[i].Y, (int)_movements[i].X); + } } + _deskPosition += direction; + _movements.Insert(0, _deskPosition); + _image.GlobalPosition = newPostion; } } } - public void ChangeHealth(int CHANGE) + public void ChainSelection() { - _health += CHANGE; - _health = Math.Min(_health, _healthMax); - - if (_health < 0) - { - _dead = true; - _health = 0; - } - - GetNode("Panel").SetValue(_health); - } - - public void MoveChain() - { - _hoveredWorker = _workers.SingleOrDefault(w => !w._selected && !w._held && w._hovered, null); - if (_heldWorker != null) { _heldWorker.GlobalPosition = GetGlobalMousePosition(); - if (_hoveredWorker != null) + if (_hoveredWorker != null && _heldWorker != _hoveredWorker) { SwapPositions(_heldWorker, _hoveredWorker); _hoveredWorker._hovered = false; @@ -160,16 +143,34 @@ public partial class Manager : Node2D } } + public void ChangeHealth(int CHANGE) + { + _health += CHANGE; + _health = Math.Min(_health, _healthMax); + + if (_health < 0) + { + _dead = true; + _health = 0; + } + + GetNode("Panel").SetValue(_health); + } + public void SetSprite(string PATH) { _imagePath = PATH; } + // public void Start() + // { + // _workers[0].GlobalPosition = _desk.GetPositionFromAddress(1, 1); + // } + public void SwapPositions(Worker A, Worker B) { - Vector2 positionA = A.Position, positionB = B.Position, chainPositionA = A._chainPosition, chainPositionB = B._chainPosition; + Vector2 chainPositionA = A._chainPosition, chainPositionB = B._chainPosition; List movesA = new(A._moves), movesB = new(B._moves); - // A.Position = positionB; B.Position = chainPositionA; A._chainPosition = chainPositionB; B._chainPosition = chainPositionA; @@ -180,5 +181,17 @@ public partial class Manager : Node2D _workers[indexA] = B; _workers[indexB] = C; } + + private void SetHoveredWorker(Worker HOVEREDWORKER) + { + if (HOVEREDWORKER._hovered) + { + _hoveredWorker = HOVEREDWORKER; + } + else + { + _hoveredWorker = null; + } + } } diff --git a/Gameplay/Tchotchke.cs b/Gameplay/Tchotchke.cs index 319ba05..989ba2a 100644 --- a/Gameplay/Tchotchke.cs +++ b/Gameplay/Tchotchke.cs @@ -1,92 +1,92 @@ -using Godot; -using System; -using System.Collections.Generic; -using System.Linq; +// using Godot; +// using System; +// using System.Collections.Generic; +// using System.Linq; -public partial class Tchotchke : StaticBody2D -{ - public bool _hovered = false, _held = false; - public List _actions = new(); - public Node _target; +// public partial class Tchotchke : StaticBody2D +// { +// public bool _hovered = false, _held = false; +// public List _actions = new(); +// public Node _target; - public override void _Ready() - { - MouseEntered += OnMouseEntered; - MouseExited += OnMouseExited; - } +// public override void _Ready() +// { +// MouseEntered += OnMouseEntered; +// MouseExited += OnMouseExited; +// } - public override void _Process(double DELTA_) - { - if (_held) - { - GlobalPosition = GetGlobalMousePosition(); - if (Input.IsActionJustReleased("left_click")) - { - Transform2D newTransform = GlobalTransform; - newTransform.Origin = Position; - GlobalTransform = newTransform; - Drop(); - } - } - else - { - if (_hovered) - { - if (Input.IsActionJustPressed("left_click")) - { - Hold(); - } - if (Input.IsActionJustPressed("scroll_up")) - { - Rotation -= 1.0f * (float)(Math.PI) / 180.0f; - } - if (Input.IsActionJustPressed("scroll_down")) - { - Rotation += 1.0f * (float)(Math.PI) / 180.0f; - } - } - } - } +// public override void _Process(double DELTA_) +// { +// if (_held) +// { +// GlobalPosition = GetGlobalMousePosition(); +// if (Input.IsActionJustReleased("left_click")) +// { +// Transform2D newTransform = GlobalTransform; +// newTransform.Origin = Position; +// GlobalTransform = newTransform; +// Drop(); +// } +// } +// else +// { +// if (_hovered) +// { +// if (Input.IsActionJustPressed("left_click")) +// { +// Hold(); +// } +// if (Input.IsActionJustPressed("scroll_up")) +// { +// Rotation -= 1.0f * (float)(Math.PI) / 180.0f; +// } +// if (Input.IsActionJustPressed("scroll_down")) +// { +// Rotation += 1.0f * (float)(Math.PI) / 180.0f; +// } +// } +// } +// } - public void Drop() - { - if (_held) - { - _held = false; - } - } +// public void Drop() +// { +// if (_held) +// { +// _held = false; +// } +// } - public void FireActions(Trigger.On TRIGGER, Node TARGET = null) - { - List triggeredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList(); - for (int i = 0; i < triggeredActions.Count; i++) - { - triggeredActions[i].Target(TARGET); - triggeredActions[i].Fire(); - } - List expiredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList(); - _actions.Except(expiredActions); - } +// public void FireActions(Trigger.On TRIGGER, Node TARGET = null) +// { +// List triggeredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList(); +// for (int i = 0; i < triggeredActions.Count; i++) +// { +// triggeredActions[i].Target(TARGET); +// triggeredActions[i].Fire(); +// } +// List expiredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList(); +// _actions.Except(expiredActions); +// } - public void Hold() - { - if (_held) - { - return; - } - _held = true; - } +// public void Hold() +// { +// if (_held) +// { +// return; +// } +// _held = true; +// } - // PRIVATE METHODS - private void OnMouseEntered() - { - _hovered = true; - } +// // PRIVATE METHODS +// private void OnMouseEntered() +// { +// _hovered = true; +// } - private void OnMouseExited() - { - _hovered = false; - } +// private void OnMouseExited() +// { +// _hovered = false; +// } -} +// } diff --git a/Gameplay/Tchotchkes/AwfullyHotCoffeePot.cs b/Gameplay/Tchotchkes/AwfullyHotCoffeePot.cs index c0fc52e..0ea2df2 100644 --- a/Gameplay/Tchotchkes/AwfullyHotCoffeePot.cs +++ b/Gameplay/Tchotchkes/AwfullyHotCoffeePot.cs @@ -1,10 +1,10 @@ -using Godot; -using System; +// using Godot; +// using System; -public partial class AwfullyHotCoffeePot : Tchotchke -{ - public AwfullyHotCoffeePot() : base() - { - _actions.Add(new Caffeinate(this)); - } -} +// public partial class AwfullyHotCoffeePot : Tchotchke +// { +// public AwfullyHotCoffeePot() : base() +// { +// // _actions.Add(new Caffeinate(this)); +// } +// } diff --git a/Gameplay/Tchotchkes/RedStapler.cs b/Gameplay/Tchotchkes/RedStapler.cs index 603b4d0..2aa60f1 100644 --- a/Gameplay/Tchotchkes/RedStapler.cs +++ b/Gameplay/Tchotchkes/RedStapler.cs @@ -1,7 +1,7 @@ -using Godot; -using System; +// using Godot; +// using System; -public partial class RedStapler : Tchotchke -{ +// public partial class RedStapler : Tchotchke +// { -} +// } diff --git a/Gameplay/Action.cs b/Gameplay/Trait.cs similarity index 63% rename from Gameplay/Action.cs rename to Gameplay/Trait.cs index e07032b..01e4fa4 100644 --- a/Gameplay/Action.cs +++ b/Gameplay/Trait.cs @@ -2,14 +2,13 @@ using Godot; using System; using System.Collections.Generic; -public partial class Action : Node +public partial class Trait : Node { - public Node _target; + public Worker _target, _owner; public List _triggers = new(); public List _expirations = new(); - public Node2D _owner; - public Action(Node2D OWNER) + public Trait(Worker OWNER) { _owner = OWNER; } @@ -19,7 +18,7 @@ public partial class Action : Node } - public virtual void Target(Node TARGET) + public virtual void Target(Worker TARGET) { _target = TARGET; } diff --git a/Gameplay/Action.cs.uid b/Gameplay/Trait.cs.uid similarity index 100% rename from Gameplay/Action.cs.uid rename to Gameplay/Trait.cs.uid diff --git a/Gameplay/Traits/BasicAttack.cs b/Gameplay/Traits/BasicAttack.cs new file mode 100644 index 0000000..2651f3e --- /dev/null +++ b/Gameplay/Traits/BasicAttack.cs @@ -0,0 +1,26 @@ +using Godot; +using System; +using System.Collections.Generic; + +public partial class BasicAttack : Trait +{ + public BasicAttack(Worker OWNER) : base(OWNER) + { + _triggers.Add(Trigger.On.Collision); + } + + public override void Fire() + { + if (_target != null) + { + + if (_target._manager != _owner._manager) + { + int damage = -_owner._aptitude._default / 2; + // target.ChangeHealth(damage, owner); + } + } + _target = null; + } + +} diff --git a/Gameplay/Actions/BasicAttack.cs.uid b/Gameplay/Traits/BasicAttack.cs.uid similarity index 100% rename from Gameplay/Actions/BasicAttack.cs.uid rename to Gameplay/Traits/BasicAttack.cs.uid diff --git a/Gameplay/Traits/Caffeinate.cs b/Gameplay/Traits/Caffeinate.cs new file mode 100644 index 0000000..5b34719 --- /dev/null +++ b/Gameplay/Traits/Caffeinate.cs @@ -0,0 +1,15 @@ +using Godot; +using System; + +public partial class Caffeinate : Trait +{ + public Caffeinate(Worker OWNER) : base(OWNER) + { + _triggers.Add(Trigger.On.Collision); + } + + public override void Fire() + { + + } +} diff --git a/Gameplay/Actions/Caffeinate.cs.uid b/Gameplay/Traits/Caffeinate.cs.uid similarity index 100% rename from Gameplay/Actions/Caffeinate.cs.uid rename to Gameplay/Traits/Caffeinate.cs.uid diff --git a/Gameplay/Traits/basic_attack.tscn b/Gameplay/Traits/basic_attack.tscn new file mode 100644 index 0000000..4e785fe --- /dev/null +++ b/Gameplay/Traits/basic_attack.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bih70e65g1108"] + +[ext_resource type="Script" uid="uid://2ilonmgvkayp" path="res://Gameplay/Traits/BasicAttack.cs" id="1_egsn3"] + +[node name="BasicAttack" type="Node"] +script = ExtResource("1_egsn3") diff --git a/Gameplay/Actions/caffeinate.tscn b/Gameplay/Traits/caffeinate.tscn similarity index 100% rename from Gameplay/Actions/caffeinate.tscn rename to Gameplay/Traits/caffeinate.tscn diff --git a/Gameplay/Worker.cs b/Gameplay/Worker.cs index 8b136c9..fd546af 100644 --- a/Gameplay/Worker.cs +++ b/Gameplay/Worker.cs @@ -1,28 +1,26 @@ using Godot; using System; using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.Diagnostics; using System.Linq; public partial class Worker : CharacterBody2D { + [Signal] + public delegate void SetHoveredEventHandler(Worker THIS); + public bool _dead = false, _hovered = false, _held = false, _selected = false; public int _size, _health, _healthMax; public float _distanceTraveled, _stamina, _staminaMax; public Stat _aptitude = new(), _agility = new(), _ardor = new(), _accumen = new(), _awareness = new(), _appeal = new(); public float _rotationalForce = 0; - public Vector2 _chainPosition = new Vector2(-1, -1); + public Vector2 _chainPosition = new Vector2(-1, -1), _deskPosition; public List _moves = new(); public Sprite2D _image; public ProgressBar _healthBar; public Manager _manager; - public Node _actions; - public Node _conditions; + public List _traits = new(); public override void _Ready() { - _actions = GetNode("Actions"); - _conditions = GetNode("Conditions"); _size = (int)(((CircleShape2D)GetNode("Bounds").Shape).Radius); _aptitude._default = 5; @@ -41,7 +39,7 @@ public partial class Worker : CharacterBody2D _image = GetNode("Sprite2D"); - _actions.AddChild(new BasicAttack(this)); + _traits.Add(new BasicAttack(this)); // _healthBar = GetNode("HealthBar"); // _healthBar.MaxValue = _healthMax; @@ -86,28 +84,23 @@ public partial class Worker : CharacterBody2D } } - public void FireActions(Trigger.On TRIGGER, Node TARGET = null) + public void FireActions(Trigger.On TRIGGER, Worker TARGET = null) { - List children = _actions.GetChildren().ToList(); - for (int i = 0; i < children.Count; i++) + for (int i = 0; i < _traits.Count; i++) { - if (children[i] is Action) + if (_traits[i]._triggers.Contains(TRIGGER)) { - Action action = (Action)children[i]; - if (action._triggers.Contains(TRIGGER)) - { - action.Target(TARGET); - action.Fire(); - } + _traits[i].Target(TARGET); + _traits[i].Fire(); } } } - public bool HasCondition(string CONDITION) - { - List conditionNames = _conditions.GetChildren().Select(c => c.GetType().ToString()).ToList(); - return conditionNames.Contains(CONDITION); - } + // public bool HasCondition(string CONDITION) + // { + // List conditionNames = _conditions.GetChildren().Select(c => c.GetType().ToString()).ToList(); + // return conditionNames.Contains(CONDITION); + // } public void Hold() { @@ -132,11 +125,13 @@ public partial class Worker : CharacterBody2D private void OnMouseEntered() { _hovered = true; + EmitSignal(SignalName.SetHovered, this); } private void OnMouseExited() { _hovered = false; + EmitSignal(SignalName.SetHovered, this); } // private void OnBodyEntered(Node NODE) diff --git a/Gameplay/battle.tscn b/Gameplay/battle.tscn index 9e1a229..150e8fd 100644 --- a/Gameplay/battle.tscn +++ b/Gameplay/battle.tscn @@ -1,11 +1,6 @@ -[gd_scene load_steps=3 format=3 uid="uid://5ymxo45j4ryt"] +[gd_scene load_steps=2 format=3 uid="uid://5ymxo45j4ryt"] [ext_resource type="Script" uid="uid://0c1u4l8lu07h" path="res://Gameplay/Battle.cs" id="1_i431l"] -[ext_resource type="PackedScene" uid="uid://demwh8ek37mnx" path="res://Gameplay/desk.tscn" id="2_fkh6t"] [node name="Battle" type="Node" groups=["battles"]] script = ExtResource("1_i431l") - -[node name="Desk" parent="." instance=ExtResource("2_fkh6t")] -position = Vector2(960, 540) -rotation = 1.5708 diff --git a/Gameplay/desk.tscn b/Gameplay/desk.tscn index afeafa0..09b01ee 100644 --- a/Gameplay/desk.tscn +++ b/Gameplay/desk.tscn @@ -1,29 +1,20 @@ -[gd_scene load_steps=4 format=3 uid="uid://demwh8ek37mnx"] +[gd_scene load_steps=3 format=3 uid="uid://demwh8ek37mnx"] -[ext_resource type="Texture2D" uid="uid://w4cxyhjvmkq1" path="res://art/desk.png" id="1_21bwm"] [ext_resource type="Script" uid="uid://pxi753iie75t" path="res://Gameplay/Desk.cs" id="2_15p4t"] -[ext_resource type="Texture2D" uid="uid://c5yof13kvayxo" path="res://art/deskBounds.png" id="3_15p4t"] +[ext_resource type="Texture2D" uid="uid://dy4lmwn1dit26" path="res://art/shade.png" id="2_21bwm"] -[node name="Desk" type="Sprite2D"] -texture = ExtResource("1_21bwm") +[node name="Desk" type="Node2D"] script = ExtResource("2_15p4t") -[node name="StaticBody2D" type="StaticBody2D" parent="."] - -[node name="Sprite2D" type="Sprite2D" parent="StaticBody2D"] +[node name="Light" type="Sprite2D" parent="."] visible = false -texture = ExtResource("3_15p4t") +scale = Vector2(0.195, 0.195) +texture = ExtResource("2_21bwm") -[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"] -polygon = PackedVector2Array(750, -750, 1, -750, 1, -373.1, 157, -370, 163.1, -370, 252.1, -337, 253.2, -337, 288.3, -310, 289.7, -310, 333.7, -258, 359.8, -203, 371, -152, 373, -131.6, 373, 131.3, 367, 174.7, 367, 179.1, 351, 224.1, 351, 226.4, 310, 288.5, 310, 289.7, 257.9, 333.7, 194.1, 362.7, 127, 372.7, -131.4, 373, -217.5, 354, -219.6, 354, -265.7, 328, -267.1, 328, -317, 281, -352.2, 223, -369.1, 165.8, -372, -132, -372, -147.4, -359, -204.4, -359, -206.9, -328, -265.8, -328, -266.9, -264.1, -329.9, -194.2, -362.8, -127, -372.7, 0, -373, 0, -750, -750, -750, -750, 750, 750, 750) +[node name="Dark" type="Sprite2D" parent="."] +visible = false +modulate = Color(0, 0, 0, 1) +scale = Vector2(0.195, 0.195) +texture = ExtResource("2_21bwm") -[node name="Gravity" type="Area2D" parent="."] -gravity_space_override = 1 -gravity_point = true -gravity_point_unit_distance = 375.0 -gravity_point_center = Vector2(0, 0) -gravity_direction = Vector2(0, 0) -gravity = 5.0 - -[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="Gravity"] -polygon = PackedVector2Array(157.2, -375, -153, -375, -174.3, -372, -179.3, -372, -218.3, -359, -221.5, -359, -256.6, -340, -258.7, -340, -285.7, -319, -287.8, -319, -316.8, -289, -318.1, -289, -341.1, -255, -342.3, -255, -359.3, -218, -360.5, -218, -370.5, -181, -371.8, -181, -375, -154.6, -375, 160.5, -368, 191, -368, 195.4, -356, 225.4, -356, 228.6, -332, 268.5, -332, 270.7, -312, 293.7, -312, 295.9, -284, 320.8, -284, 322.1, -248, 345.1, -248, 346.3, -218, 359.2, -218, 360.5, -197, 366.4, -197, 367.7, -165, 373.7, -165, 374.8, -163.3, 375, 157.4, 375, 174.4, 372, 179.3, 372, 218.3, 359, 221.5, 359, 256.6, 340, 258.7, 340, 293.7, 312, 295.9, 312, 316.9, 289, 318.1, 289, 341.1, 255, 342.3, 255, 357.2, 223, 358.5, 223, 370.5, 181, 371.8, 181, 375, 154.6, 375, -163.2, 368, -191, 368, -195.4, 356, -225.5, 356, -228.6, 332, -268.6, 332, -270.7, 312, -293.8, 312, -295.9, 284, -320.9, 284, -322.1, 248, -345.2, 248, -346.3, 218, -359.3, 218, -360.6, 171, -372.6, 171, -373.8) +[node name="Cells" type="Node2D" parent="."] diff --git a/Gameplay/manager.tscn b/Gameplay/manager.tscn index f65f62a..cefeb55 100644 --- a/Gameplay/manager.tscn +++ b/Gameplay/manager.tscn @@ -1,7 +1,9 @@ -[gd_scene load_steps=3 format=3 uid="uid://cdaxqopr35lll"] +[gd_scene load_steps=5 format=3 uid="uid://cdaxqopr35lll"] [ext_resource type="Script" uid="uid://b66ysicyh0m1s" path="res://Gameplay/Manager.cs" id="1_ivgep"] +[ext_resource type="PackedScene" uid="uid://demwh8ek37mnx" path="res://Gameplay/desk.tscn" id="3_muxv4"] [ext_resource type="PackedScene" uid="uid://8kv00jc35dma" path="res://Gameplay/manager_panel.tscn" id="3_xooeg"] +[ext_resource type="Texture2D" uid="uid://n0e2tlnwq3e2" path="res://art/manager.png" id="4_2skxn"] [node name="Manager" type="Node2D"] script = ExtResource("1_ivgep") @@ -15,3 +17,9 @@ grow_horizontal = 1 grow_vertical = 1 [node name="Workers" type="Node" parent="."] + +[node name="Desk" parent="." instance=ExtResource("3_muxv4")] + +[node name="Image" type="Sprite2D" parent="."] +scale = Vector2(0.5, 0.5) +texture = ExtResource("4_2skxn") diff --git a/Gameplay/action.tscn b/Gameplay/trait.tscn similarity index 55% rename from Gameplay/action.tscn rename to Gameplay/trait.tscn index 4ead980..31760a1 100644 --- a/Gameplay/action.tscn +++ b/Gameplay/trait.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=2 format=3 uid="uid://dti20yu8jfujq"] -[ext_resource type="Script" uid="uid://dtccp5uxgkjwm" path="res://Gameplay/Action.cs" id="1_lk435"] +[ext_resource type="Script" uid="uid://dtccp5uxgkjwm" path="res://Gameplay/Trait.cs" id="1_wtks1"] -[node name="Action" type="Node"] -script = ExtResource("1_lk435") +[node name="Trait" type="Node"] +script = ExtResource("1_wtks1") diff --git a/Gameplay/worker.tscn b/Gameplay/worker.tscn index 9c28e77..02d8261 100644 --- a/Gameplay/worker.tscn +++ b/Gameplay/worker.tscn @@ -21,6 +21,7 @@ step = 1.0 shape = SubResource("CircleShape2D_4poc8") [node name="Sprite2D" type="Sprite2D" parent="."] +texture_filter = 1 scale = Vector2(0.5, 0.5) texture = ExtResource("2_m3kx1") diff --git a/art/manager.png b/art/manager.png new file mode 100644 index 0000000..e0fc8d0 Binary files /dev/null and b/art/manager.png differ diff --git a/art/manager.png.import b/art/manager.png.import new file mode 100644 index 0000000..792e267 --- /dev/null +++ b/art/manager.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://n0e2tlnwq3e2" +path="res://.godot/imported/manager.png-4597b8f1ec81670b0cb0a529dbc77f73.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/manager.png" +dest_files=["res://.godot/imported/manager.png-4597b8f1ec81670b0cb0a529dbc77f73.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/art/tiles.png b/art/tiles.png new file mode 100644 index 0000000..ac47929 Binary files /dev/null and b/art/tiles.png differ diff --git a/art/tiles.png.import b/art/tiles.png.import new file mode 100644 index 0000000..df241e0 --- /dev/null +++ b/art/tiles.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://c5bxy01morx2o" +path="res://.godot/imported/tiles.png-4bebe0e5cdfc7faf322603713a4a3f81.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://art/tiles.png" +dest_files=["res://.godot/imported/tiles.png-4bebe0e5cdfc7faf322603713a4a3f81.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1