Wednesday, 27 August 2025 01:54:42

This commit is contained in:
2025-08-27 01:54:43 -04:00
parent 4fe431a8e0
commit ac25e55bf3
12 changed files with 244 additions and 203 deletions

View File

@@ -17,7 +17,7 @@ public partial class Caffeinate : Action
Worker target = (Worker)_target;
if (!target.HasCondition(GetType().ToString()))
{
target._conditions.Add(new Caffeinated(target));
target._conditions.AddChild(new Caffeinated(target));
}
}
_target = null;

View File

@@ -11,26 +11,20 @@ public partial class Caffeinated : Condition
_timer.WaitTime = _countdown;
_timer.Autostart = true;
AddChild(_timer);
// GetNode<Timer>("Timer").Timeout += Fire;
if (OWNER is Worker)
_timer.Timeout += Fire;
if (_owner is Worker)
{
((Worker)OWNER)._staminaCanDrain = false;
((Worker)_owner)._agility._effective += 3;
}
}
public override void Fire()
{
_expired = true;
if (_target != null)
if (_owner is Worker)
{
if (_target is Worker)
{
Worker target = (Worker)_target;
target._stamina -= 1;
target._staminaCanDrain = true;
target._conditions.Remove(this);
}
_target = null;
((Worker)_owner)._agility._effective -= 3;
((Worker)_owner)._conditions.RemoveChild(this);
}
}
}

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
public partial class Globals : Node
{
public static Globals Instance;
public bool _battleRunning = false;
public Viewport _viewport;
public Vector2 _screenSize;
public Vector2 _screenCenter;

View File

@@ -17,12 +17,16 @@ public partial class Main : Node
_currentBattle.Start();
}
public override void _Process(double DELTA_)
{
public override void _Process(double DELTA_)
{
if (Input.IsActionJustReleased("quit_game"))
{
GetTree().Quit();
}
if (Input.IsActionJustPressed("space"))
{
Globals.Instance._battleRunning = !Globals.Instance._battleRunning;
}
}
}

View File

@@ -4,19 +4,22 @@ 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 partial class Manager : Node2D
{
public bool _dead, _ready;
public int _ballsMoving = 0, _health = 10, _healthMax;
public int _ballsMoving = 0, _health = 10, _healthMax, _speed = 5;
public string _imagePath;
public CollisionShape2D _startArea;
public ManagerPanel _managerPanel = null;
public Manager _opponent;
public List<Worker> _workers = new();
public Worker _hoveredWorker, _selectedWorker, _heldWorker;
public Node _workerNode;
public List<Tchotchke> _tchotckes = new();
public override void _Ready()
{
_workerNode = GetNode("Workers");
_healthMax = _health;
SetSprite("res://art/ness.png");
@@ -26,15 +29,27 @@ public partial class Manager : Node
_managerPanel.SetManager(this);
Worker newWorker = Globals.Instance._workerScene.Instantiate<Worker>();
newWorker.Position = Globals.Instance._screenCenter + new Vector2(0, 100);
newWorker.Position = Globals.Instance._screenCenter;
newWorker._manager = this;
AddChild(newWorker);
_workerNode.AddChild(newWorker);
_workers.Add(newWorker);
newWorker = Globals.Instance._workerScene.Instantiate<Worker>();
newWorker.Position = Globals.Instance._screenCenter - new Vector2(0, 100);
newWorker.Position = Globals.Instance._screenCenter;
newWorker._manager = this;
AddChild(newWorker);
_workerNode.AddChild(newWorker);
_workers.Add(newWorker);
newWorker = Globals.Instance._workerScene.Instantiate<Worker>();
newWorker.Position = Globals.Instance._screenCenter;
newWorker._manager = this;
_workerNode.AddChild(newWorker);
_workers.Add(newWorker);
newWorker = Globals.Instance._workerScene.Instantiate<Worker>();
newWorker.Position = Globals.Instance._screenCenter;
newWorker._manager = this;
_workerNode.AddChild(newWorker);
_workers.Add(newWorker);
// for (int i = 0; i < _workers.Count; i++)
@@ -42,20 +57,45 @@ public partial class Manager : Node
// _workers[i]._healthBar.Position = _managerPanel.GetNode<Panel>("Team").GetNode<Panel>("T"+(i+1)).GlobalPosition;
// }
Tchotchke newTchotchke = ResourceLoader.Load<PackedScene>("res://Gameplay/Tchotchkes/awfully_hot_coffee_pot.tscn").Instantiate<Tchotchke>();
newTchotchke.Position = new Vector2(Globals.Instance._screenSize.X - 100, Globals.Instance._screenCenter.Y);
AddChild(newTchotchke);
_tchotckes.Add(newTchotchke);
// Tchotchke newTchotchke = ResourceLoader.Load<PackedScene>("res://Gameplay/Tchotchkes/awfully_hot_coffee_pot.tscn").Instantiate<Tchotchke>();
// newTchotchke.Position = new Vector2(Globals.Instance._screenSize.X - 100, Globals.Instance._screenCenter.Y);
// AddChild(newTchotchke);
// _tchotckes.Add(newTchotchke);
}
public override void _Process(double DELTA_)
{
if (_workers.All(w => w._placed && w._primed))
if (Globals.Instance._battleRunning)
{
for (int i = 0; i < _workers.Count; i++)
ChainMovement();
}
else
{
MoveChain();
}
}
public void ChainMovement()
{
Vector2 mousePosition = GetGlobalMousePosition();
// _workers[0].LookAt(mousePosition);
Vector2 mouseOffset = mousePosition - _workers[0].GlobalPosition;
if (mouseOffset.Length() > _workers[0]._size)
{
Vector2 mouseOffsetNormal = mouseOffset.Normalized();
_workers[0].GlobalPosition += mouseOffsetNormal * _speed;
_workers[0]._distanceTraveled += _speed;
_workers[0]._moves.Insert(0, _workers[0].GlobalPosition);
for (int i = 1; i < _workers.Count; i++)
{
_workers[i].Launch();
if (_workers[i - 1]._distanceTraveled > (_workers[i - 1]._size + _workers[i]._size) * 1.2f)
{
_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);
}
}
}
}
@@ -74,10 +114,71 @@ public partial class Manager : Node
GetNode<ManagerPanel>("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)
{
SwapPositions(_heldWorker, _hoveredWorker);
_hoveredWorker._hovered = false;
_hoveredWorker = null;
}
if (Input.IsActionJustReleased("left_click"))
{
_heldWorker.GlobalPosition = _heldWorker._chainPosition;
_heldWorker._held = false;
_heldWorker = 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 SetSprite(string PATH)
{
_imagePath = PATH;
}
public void SwapPositions(Worker A, Worker B)
{
Vector2 positionA = A.Position, positionB = B.Position, chainPositionA = A._chainPosition, chainPositionB = B._chainPosition;
List<Vector2> movesA = new(A._moves), movesB = new(B._moves);
// A.Position = positionB;
B.Position = chainPositionA;
A._chainPosition = chainPositionB;
B._chainPosition = chainPositionA;
A._moves = movesB;
B._moves = movesA;
int indexA = _workers.IndexOf(A), indexB = _workers.IndexOf(B);
Worker C = A;
_workers[indexA] = B;
_workers[indexB] = C;
}
}

View File

@@ -5,22 +5,26 @@ using System.ComponentModel.DataAnnotations;
using System.Diagnostics;
using System.Linq;
public partial class Worker : RigidBody2D
public partial class Worker : CharacterBody2D
{
public bool _dead = false, _hovered = false, _held = false, _placed = false, _selected = false, _primed = false, _moving = false, _staminaCanDrain = true;
public int _health, _healthMax;
public float _stamina, _staminaMax;
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 _force = Vector2.Zero;
public Node _collisionTarget;
public Vector2 _chainPosition = new Vector2(-1, -1);
public List<Vector2> _moves = new();
public Sprite2D _image;
public ProgressBar _healthBar;
public Manager _manager;
public List<Action> _actions = new();
public List<Condition> _conditions = new();
public Node _actions;
public Node _conditions;
public override void _Ready()
{
_actions = GetNode("Actions");
_conditions = GetNode("Conditions");
_size = (int)(((CircleShape2D)GetNode<CollisionShape2D>("Bounds").Shape).Radius);
_aptitude._default = 5;
_agility._default = 5;
_ardor._default = 5;
@@ -37,7 +41,7 @@ public partial class Worker : RigidBody2D
_image = GetNode<Sprite2D>("Sprite2D");
_actions.Add(new BasicAttack(this));
_actions.AddChild(new BasicAttack(this));
// _healthBar = GetNode<ProgressBar>("HealthBar");
// _healthBar.MaxValue = _healthMax;
@@ -46,118 +50,62 @@ public partial class Worker : RigidBody2D
public override void _Process(double DELTA_)
{
if (!_moving)
if (Globals.Instance._battleRunning)
{
if (!_placed)
{
if (!_held)
{
if (_hovered)
{
if (Input.IsActionJustPressed("left_click"))
{
Hold();
}
}
}
}
else
{
if (_selected)
{
Vector2 mousePosition = GetGlobalMousePosition();
LookAt(mousePosition);
if (Input.IsActionJustReleased("left_click"))
{
_selected = false;
_force = (GlobalPosition - mousePosition) * 100;
_stamina = _agility._effective;
_primed = true;
}
}
else if (_hovered)
{
if (Input.IsActionJustPressed("left_click"))
{
_selected = true;
}
}
}
_chainPosition = GlobalPosition;
}
else
{
// Vector2 towardCenter = (Globals.Instance._screenCenter - GlobalPosition).Normalized();
// ApplyCentralForce(towardCenter * 100);
_image.Rotate(_stamina);
if (_staminaCanDrain)
{
_stamina -= 0.25f / 60;
}
if (_stamina <= 0f)
{
Stop();
}
}
}
public override void _PhysicsProcess(double DELTA_)
{
if (_held)
{
GlobalPosition = GetGlobalMousePosition();
if (Input.IsActionJustReleased("left_click"))
{
Transform2D newTransform = GlobalTransform;
newTransform.Origin = Position;
GlobalTransform = newTransform;
Drop();
}
}
}
public void ChangeHealth(int CHANGE, Node CHANGEMAKER)
{
if (_health <= 0 && CHANGE < 0)
{
// knock the piece off the board and out for the round!
// process on knockout
}
_health += CHANGE;
_healthBar.Value = _health;
if (_health <= 0)
{
Sleeping = true;
_dead = true;
_health = 0;
FireActions(Trigger.On.Death, _manager);
}
}
// public void ChangeHealth(int CHANGE, Node CHANGEMAKER)
// {
// if (_health <= 0 && CHANGE < 0)
// {
// // knock the piece off the board and out for the round!
// // process on knockout
// }
// _health += CHANGE;
// _healthBar.Value = _health;
// if (_health <= 0)
// {
// Sleeping = true;
// _dead = true;
// _health = 0;
// FireActions(Trigger.On.Death, _manager);
// }
// }
public void Drop()
{
if (_held)
{
_held = false;
_placed = true;
Freeze = false;
}
}
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
{
List<Action> triggeredActions = _actions.Where(e => e._triggers.Contains(TRIGGER)).ToList();
for (int i = 0; i < triggeredActions.Count; i++)
List<Node> children = _actions.GetChildren().ToList();
for (int i = 0; i < children.Count; i++)
{
triggeredActions[i].Target(TARGET);
triggeredActions[i].Fire();
if (children[i] is Action)
{
Action action = (Action)children[i];
if (action._triggers.Contains(TRIGGER))
{
action.Target(TARGET);
action.Fire();
}
}
}
List<Action> expiredActions = _actions.Where(e => e._triggers.Contains(TRIGGER)).ToList();
_actions.Except(expiredActions);
}
public bool HasCondition(string CONDITION)
{
List<string> conditionNames = _conditions.Select(c => c.GetType().ToString()).ToList();
List<string> conditionNames = _conditions.GetChildren().Select(c => c.GetType().ToString()).ToList();
return conditionNames.Contains(CONDITION);
}
@@ -167,29 +115,9 @@ public partial class Worker : RigidBody2D
{
return;
}
Freeze = true;
_held = true;
}
public void Launch()
{
GravityScale = 1.0f;
_moving = true;
ApplyCentralForce(_force);
_force = Vector2.Zero;
_primed = false;
FireActions(Trigger.On.Launch, _manager);
}
public void Stop()
{
GravityScale = 0.0f;
Sleeping = true;
_moving = false;
_stamina = 0f;
FireActions(Trigger.On.Stop, _manager);
}
public void ResetStats()
{
_aptitude._effective = _aptitude._default;
@@ -211,24 +139,22 @@ public partial class Worker : RigidBody2D
_hovered = false;
}
private void OnBodyEntered(Node NODE)
{
if (NODE is Worker)
{
_collisionTarget = NODE;
FireActions(Trigger.On.Collision, NODE);
// private void OnBodyEntered(Node NODE)
// {
// if (NODE is Worker)
// {
// FireActions(Trigger.On.Collision, NODE);
_rotationalForce *= 0.8f;
Vector2 rotatedForce = LinearVelocity.Rotated(((Worker)NODE)._rotationalForce);
// _rotationalForce *= 0.8f;
// Vector2 rotatedForce = LinearVelocity.Rotated(((Worker)NODE)._rotationalForce);
ApplyCentralForce(rotatedForce);
_collisionTarget = null;
}
else if (NODE is Tchotchke)
{
Tchotchke tchotchke = (Tchotchke)NODE;
tchotchke.FireActions(Trigger.On.Collision, this);
}
}
// ApplyCentralForce(rotatedForce);
// }
// else if (NODE is Tchotchke)
// {
// Tchotchke tchotchke = (Tchotchke)NODE;
// tchotchke.FireActions(Trigger.On.Collision, this);
// }
// }
}

View File

@@ -1,3 +1,6 @@
[gd_scene load_steps=0 format=3 uid="uid://becqya8l8feni"]
[gd_scene load_steps=2 format=3 uid="uid://dti20yu8jfujq"]
[node name="ProcessEffect" type="Node"]
[ext_resource type="Script" uid="uid://dtccp5uxgkjwm" path="res://Gameplay/Action.cs" id="1_lk435"]
[node name="Action" type="Node"]
script = ExtResource("1_lk435")

View File

@@ -1,3 +0,0 @@
[gd_scene format=3 uid="uid://dti20yu8jfujq"]
[node name="Action" type="Node"]

View File

@@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://b66ysicyh0m1s" path="res://Gameplay/Manager.cs" id="1_ivgep"]
[ext_resource type="PackedScene" uid="uid://8kv00jc35dma" path="res://Gameplay/manager_panel.tscn" id="3_xooeg"]
[node name="Manager" type="Node"]
[node name="Manager" type="Node2D"]
script = ExtResource("1_ivgep")
[node name="Panel" parent="." instance=ExtResource("3_xooeg")]
@@ -13,3 +13,5 @@ offset_right = 551.0
offset_bottom = 280.0
grow_horizontal = 1
grow_vertical = 1
[node name="Workers" type="Node" parent="."]

View File

@@ -1,53 +1,32 @@
[gd_scene load_steps=5 format=3 uid="uid://37hjd4v3p42o"]
[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="Texture2D" uid="uid://dmispjd3fmmks" path="res://art/worker_test.png" id="2_m3kx1"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_e314i"]
bounce = 3.0
[sub_resource type="CircleShape2D" id="CircleShape2D_4poc8"]
radius = 25.0799
[sub_resource type="CompressedTexture2D" id="CompressedTexture2D_e314i"]
load_path = "res://.godot/imported/beyblade.png-cd6ee3474fe554271afbb31b55fadfb5.ctex"
[sub_resource type="CircleShape2D" id="CircleShape2D_e314i"]
radius = 32.0
[node name="Worker" type="RigidBody2D"]
[node name="Worker" type="CharacterBody2D"]
input_pickable = true
physics_material_override = SubResource("PhysicsMaterial_e314i")
gravity_scale = 0.0
inertia = 1.0
lock_rotation = true
continuous_cd = 2
contact_monitor = true
max_contacts_reported = 1
linear_damp = 0.25
script = ExtResource("1_e314i")
[node name="HealthBar" type="ProgressBar" parent="."]
visible = false
top_level = true
offset_right = 150.0
offset_bottom = 27.0
step = 1.0
[node name="Bounds" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_4poc8")
[node name="Sprite2D" type="Sprite2D" parent="."]
scale = Vector2(0.2, 0.2)
texture = SubResource("CompressedTexture2D_e314i")
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_m3kx1")
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."]
scale = Vector2(0.2, 0.2)
polygon = PackedVector2Array(8, -171, -17, -171, -17, -169.9, -26.2, -169, -29.5, -169, -62, -151.2, -84, -152.9, -84, -154.4, -102.4, -151, -104.7, -151, -150.8, -114, -153, -114, -174, -88, -175.3, -88, -180, -77.7, -180, 44.2, -178, 46.7, -178, 48.3, -163.5, 54.9, -155, 81.2, -155, 83.9, -135.8, 102, -134.9, 102, -114, 126.7, -114, 128.2, -97.5, 137, -96.1, 137, -92, 143.6, -92, 146, -82, 152.9, -82, 154.5, -34, 167.4, -34, 168.7, -18.1, 171, 31.2, 171, 49.4, 167, 52.7, 167, 68, 155, 68, 154.2, 110.5, 134, 112.7, 134, 137.7, 114, 139.7, 114, 142, 98.1, 142, 92.9, 156.9, 79, 158.4, 79, 171.4, 45, 173.1, 45, 172, 22.9, 172, 13.6, 180, 1.10001, 180, -65.5, 159, -106.6, 159, -108.7, 134, -140.7, 134, -142.3, 121.4, -148, 112.5, -148, 101.4, -142, 97.3, -142, 75, -151.3, 75, -152.5, 50.3, -159, 47.5, -159, 39, -164.1, 39, -165.8, 8, -169.8)
[node name="Actions" type="Node" parent="."]
[node name="Gravity" type="Area2D" parent="."]
gravity_space_override = 1
gravity_point = true
gravity_point_unit_distance = 32.0
gravity_point_center = Vector2(0, 0)
gravity_direction = Vector2(0, 0)
gravity = 5.0
[node name="Conditions" type="Node" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="Gravity"]
shape = SubResource("CircleShape2D_e314i")
[connection signal="body_entered" from="." to="." method="OnBodyEntered"]
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]

BIN
art/worker_test.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://dmispjd3fmmks"
path="res://.godot/imported/worker_test.png-8eeda9167e14e3ea47d2777edc77e1ba.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/worker_test.png"
dest_files=["res://.godot/imported/worker_test.png-8eeda9167e14e3ea47d2777edc77e1ba.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