Wednesday, 20 August 2025 02:02:40

This commit is contained in:
2025-08-20 02:02:42 -04:00
parent dfbad40739
commit 2eb95b18fd
32 changed files with 242 additions and 167 deletions

28
Gameplay/Action.cs Normal file
View File

@@ -0,0 +1,28 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class Action : Node
{
public Node _target;
public List<Trigger.On> _triggers = new();
public List<Trigger.On> _expirations = new();
public Node2D _owner;
public Action(Node2D OWNER)
{
_owner = OWNER;
}
public virtual void Fire()
{
}
public virtual void Target(Node TARGET)
{
_target = TARGET;
}
}

View File

@@ -0,0 +1,35 @@
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 / 2;
target.ChangeHealth(damage, owner);
}
}
}
_target = null;
}
}
}

View File

@@ -0,0 +1,26 @@
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;
target._rotationalForce += 10;
Vector2 targetDistanceNormal = (target.Position - _owner.Position).Normalized();
target.ApplyCentralForce(targetDistanceNormal * 10);
target.ChangeHealth(-1, _owner);
}
_target = null;
}
}
}

View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://bo2rj0albmkkw"]
[ext_resource type="Script" path="res://Gameplay/Effects/Caffeinate.cs" id="1_l8me6"]
[node name="Caffeinate" type="Node"]
script = ExtResource("1_l8me6")

29
Gameplay/Condition.cs Normal file
View File

@@ -0,0 +1,29 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class Condition : Node
{
public bool _canExpire;
public int _countdown;
public Node _target;
public List<Trigger.On> _triggers = new();
public List<Trigger.On> _expirations = new();
public Node2D _owner;
public Condition(Node2D OWNER)
{
_owner = OWNER;
}
public virtual void Fire()
{
}
public virtual void Target(Node TARGET)
{
_target = TARGET;
}
}

View File

@@ -0,0 +1 @@
uid://vj2qucjwah5y

View File

@@ -0,0 +1,24 @@
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;
}
}
}

View File

@@ -0,0 +1,6 @@
[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")

View File

@@ -1,35 +0,0 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class Effect : Node
{
public List<Trigger> _trigger = new();
public List<Trigger> _expirations = new();
public Node2D _owner;
public Effect(Node2D OWNER)
{
_owner = OWNER;
}
public virtual void TriggerEffect(Node TARGET = null)
{
}
public enum Trigger
{
Movement,
Collision,
WallCollision,
Death,
Launch,
Stop,
BattleStart,
BattleEnd,
Critical,
Defend,
Time
}
}

View File

@@ -1,30 +0,0 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class BasicAttack : Effect
{
public BasicAttack(Node2D OWNER) : base(OWNER)
{
_trigger.Add(Trigger.Collision);
}
public override void TriggerEffect(Node 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 / 2;
target.ChangeHealth(damage, owner);
}
}
}
}
}

View File

@@ -1,22 +0,0 @@
using Godot;
using System;
public partial class Caffeinate : Effect
{
public Caffeinate(Node2D OWNER) : base(OWNER)
{
_trigger.Add(Trigger.Collision);
}
public override void TriggerEffect(Node TARGET = null)
{
if (TARGET is Worker)
{
Worker target = (Worker)TARGET;
target._rotationalForce += 10;
Vector2 targetDistanceNormal = (target.Position - _owner.Position).Normalized();
target.ApplyCentralForce(targetDistanceNormal * 10);
target.ChangeHealth(-1, _owner);
}
}
}

View File

@@ -1,20 +0,0 @@
using Godot;
using System;
public partial class Spiky : Effect
{
public Spiky(Node2D OWNER) : base(OWNER)
{
_trigger.Add(Trigger.Collision);
}
public override void TriggerEffect(Node TARGET = null)
{
if (TARGET is Worker)
{
Worker target = (Worker)TARGET;
target._rotationalForce += 10;
target.ChangeHealth(-1, _owner);
}
}
}

View File

@@ -1,6 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://bo2rj0albmkkw"]
[ext_resource type="Script" uid="uid://cbk76ik5o17nx" path="res://Gameplay/Effects/Caffeinate.cs" id="1_2f3ha"]
[node name="Caffeinate" type="Node"]
script = ExtResource("1_2f3ha")

View File

@@ -1,6 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://cchjk4lohg8k3"]
[ext_resource type="Script" uid="uid://ciwja82k4ihw6" path="res://Gameplay/Effects/Spiky.cs" id="1_levtu"]
[node name="Spiky" type="Node"]
script = ExtResource("1_levtu")

View File

@@ -41,11 +41,10 @@ public partial class Manager : Node
for (int i = 0; i < _workers.Count; i++)
{
GD.Print(i + 1);
_workers[i]._healthBar.Position = _managerPanel.GetNode<Panel>("Team").GetNode<Panel>("T"+(i+1)).GlobalPosition;
}
AwfullyHotCoffeePot newTchotchke = ResourceLoader.Load<PackedScene>("res://Gameplay/Tchotchkes/awfully_hot_coffee_pot.tscn").Instantiate<AwfullyHotCoffeePot>();
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);

View File

@@ -1,11 +1,19 @@
using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class Tchotchke : StaticBody2D
{
public bool _hovered = false, _held = false;
public List<Effect> _effects = new();
public List<Action> _actions = new();
public Node _target;
public override void _Ready()
{
MouseEntered += OnMouseEntered;
MouseExited += OnMouseExited;
}
public override void _Process(double DELTA_)
{
@@ -47,6 +55,18 @@ public partial class Tchotchke : StaticBody2D
_held = false;
}
}
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
{
List<Action> 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<Action> expiredActions = _actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList();
_actions.Except(expiredActions);
}
public void Hold()
{
@@ -56,8 +76,6 @@ public partial class Tchotchke : StaticBody2D
}
_held = true;
}
// Processes
// PRIVATE METHODS
private void OnMouseEntered()
@@ -65,20 +83,10 @@ public partial class Tchotchke : StaticBody2D
_hovered = true;
}
private void OnMouseExited()
{
_hovered = false;
}
private void OnMouseExited()
{
_hovered = false;
}
private void OnBodyEntered(Node NODE)
{
if (NODE is Worker)
{
for (int i = 0; i < _effects.Count; i++)
{
GD.Print(1001);
_effects[i].TriggerEffect((Worker)NODE);
}
}
}
}

View File

@@ -5,6 +5,6 @@ public partial class AwfullyHotCoffeePot : Tchotchke
{
public AwfullyHotCoffeePot() : base()
{
_effects.Add(new Caffeinate(this));
_actions.Add(new Caffeinate(this));
}
}

View File

@@ -30,7 +30,3 @@ gravity = 5.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Gravity"]
shape = SubResource("CircleShape2D_yxdnl")
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
[connection signal="body_entered" from="Gravity" to="." method="OnBodyEntered"]

View File

@@ -29,7 +29,3 @@ gravity = 5.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Gravity"]
shape = SubResource("CapsuleShape2D_1dddf")
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
[connection signal="body_entered" from="Gravity" to="." method="OnBodyEntered"]

22
Gameplay/Trigger.cs Normal file
View File

@@ -0,0 +1,22 @@
using Godot;
using System;
public partial class Trigger : Node
{
public Timer _timer;
public int _distance;
public enum On
{
Movement,
Collision,
WallCollision,
Death,
Launch,
Stop,
BattleStart,
BattleEnd,
Critical,
Defend,
Time
}
}

1
Gameplay/Trigger.cs.uid Normal file
View File

@@ -0,0 +1 @@
uid://g0mmh73fptyg

View File

@@ -14,7 +14,7 @@ public partial class Worker : RigidBody2D
public Sprite2D _image;
public ProgressBar _healthBar;
public Manager _manager;
public List<Effect> _effects = new();
public List<Action> _Actions = new();
public override void _Ready()
{
_health = 10;
@@ -28,7 +28,7 @@ public partial class Worker : RigidBody2D
_healthMax = _health;
_image = GetNode<Sprite2D>("Sprite2D");
_effects.Add(new BasicAttack(this));
_Actions.Add(new BasicAttack(this));
_healthBar = GetNode<ProgressBar>("HealthBar");
_healthBar.MaxValue = _healthMax;
@@ -117,7 +117,7 @@ public partial class Worker : RigidBody2D
Sleeping = true;
_dead = true;
_health = 0;
TriggerSpecificEffects(Effect.Trigger.Death, _manager);
FireActions(Trigger.On.Death, _manager);
}
}
@@ -149,7 +149,7 @@ public partial class Worker : RigidBody2D
ApplyCentralForce(_force);
_force = Vector2.Zero;
_primed = false;
TriggerSpecificEffects(Effect.Trigger.Launch, _manager);
FireActions(Trigger.On.Launch, _manager);
}
public void Stop()
@@ -158,18 +158,19 @@ public partial class Worker : RigidBody2D
Sleeping = true;
_moving = false;
_rotationalForce = 0f;
TriggerSpecificEffects(Effect.Trigger.Stop, _manager);
FireActions(Trigger.On.Stop, _manager);
}
public void TriggerSpecificEffects(Effect.Trigger TRIGGER, Node TARGET = null)
public void FireActions(Trigger.On TRIGGER, Node TARGET = null)
{
List<Effect> triggeredEffects = _effects.Where(e => e._trigger.IndexOf(TRIGGER) > -1).ToList();
for (int i = 0; i < triggeredEffects.Count; i++)
List<Action> triggeredActions = _Actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList();
for (int i = 0; i < triggeredActions.Count; i++)
{
triggeredEffects[i].TriggerEffect(TARGET);
triggeredActions[i].Target(TARGET);
triggeredActions[i].Fire();
}
List<Effect> expiredEffects = _effects.Where(e => e._trigger.IndexOf(TRIGGER) > -1).ToList();
_effects.Except(expiredEffects);
List<Action> expiredActions = _Actions.Where(e => e._triggers.IndexOf(TRIGGER) > -1).ToList();
_Actions.Except(expiredActions);
}
// PRIVATE METHODS
@@ -188,14 +189,19 @@ public partial class Worker : RigidBody2D
if (NODE is Worker)
{
_collisionTarget = NODE;
TriggerSpecificEffects(Effect.Trigger.Collision, NODE);
FireActions(Trigger.On.Collision, NODE);
_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);
}
}
}

3
Gameplay/action.tscn Normal file
View File

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

6
Gameplay/condition.tscn Normal file
View File

@@ -0,0 +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"]
[node name="Condition" type="Node"]
script = ExtResource("1_s3ntn")

View File

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

View File

@@ -30,7 +30,3 @@ gravity = 5.0
[node name="CollisionShape2D" type="CollisionShape2D" parent="Gravity"]
shape = SubResource("CircleShape2D_d82wc")
[connection signal="mouse_entered" from="." to="." method="OnMouseEntered"]
[connection signal="mouse_exited" from="." to="." method="OnMouseExited"]
[connection signal="body_entered" from="Gravity" to="." method="OnBodyEntered"]

6
Gameplay/trigger.tscn Normal file
View File

@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3 uid="uid://dufkmbuxx2h41"]
[ext_resource type="Script" uid="uid://g0mmh73fptyg" path="res://Gameplay/Trigger.cs" id="1_opbo1"]
[node name="Trigger" type="Node"]
script = ExtResource("1_opbo1")