starting to build out more actions and pegs, first thing to do tho is rework movement / targeting a little bit

This commit is contained in:
2026-07-02 00:20:52 -04:00
parent bbe9eefcfa
commit 909f466f92
15 changed files with 52 additions and 14 deletions
+2 -2
View File
@@ -47,7 +47,7 @@ public partial class Peg : HoverableNode
public virtual List<Vector2I> GetBestPath(bool PARTIAL = false) public virtual List<Vector2I> GetBestPath(bool PARTIAL = false)
{ {
Map map = _pegController._playArea._map; Map map = _pegController._playArea._map;
List<Vector2I> goals = GetGoals(); List<Vector2I> goals = Target();
for (int i = 0; i < goals.Count; i++) for (int i = 0; i < goals.Count; i++)
{ {
@@ -67,7 +67,7 @@ public partial class Peg : HoverableNode
return [.. map._cells.Where(c => (c - _address).Length() <= _visibility)]; return [.. map._cells.Where(c => (c - _address).Length() <= _visibility)];
} }
public virtual List<Vector2I> GetGoals() public virtual List<Vector2I> Target()
{ {
Map map = _pegController._playArea._map; Map map = _pegController._playArea._map;
List<Vector2I> visible = GetVisibleCells(); List<Vector2I> visible = GetVisibleCells();
@@ -2,7 +2,7 @@ using Godot;
using System; using System;
using System.Linq; using System.Linq;
public partial class Shortbow : PegAction public partial class ShootShortbow : PegAction
{ {
public override void _Ready() public override void _Ready()
{ {
@@ -17,7 +17,7 @@ public partial class Shortbow : PegAction
public override Tween CreateAnimation(Peg PEG) public override Tween CreateAnimation(Peg PEG)
{ {
Vector2 target = PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition; Vector2 target = Target(PEG);
Tween subtween = CreateTween(); Tween subtween = CreateTween();
subtween.TweenProperty(_image, "visible", true, 0.0f); subtween.TweenProperty(_image, "visible", true, 0.0f);
subtween.TweenProperty(_image, "global_position", target, 0.5f); subtween.TweenProperty(_image, "global_position", target, 0.5f);
@@ -30,4 +30,9 @@ public partial class Shortbow : PegAction
return subtween; return subtween;
} }
public override Vector2 Target(Peg PEG)
{
return PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
}
} }
@@ -2,7 +2,7 @@ using Godot;
using System; using System;
using System.Linq; using System.Linq;
public partial class Shortsword : PegAction public partial class SwingShortsword : PegAction
{ {
public override void _Ready() public override void _Ready()
{ {
+18
View File
@@ -0,0 +1,18 @@
using Godot;
using System;
public partial class ThrustSpear : PegAction
{
public override void _Ready()
{
base._Ready();
_category = "attack";
_priority = 1;
_cost = 2;
_range = 0;
_usesMax = 1;
_usesRemaining = _usesMax;
}
}
+1
View File
@@ -0,0 +1 @@
uid://bj2lg1voxioq7
@@ -1,9 +1,9 @@
[gd_scene format=3 uid="uid://duspilwelsiy3"] [gd_scene format=3 uid="uid://duspilwelsiy3"]
[ext_resource type="Script" uid="uid://dt7qbvowj1sm4" path="res://Pegs/Actions/Shortbow.cs" id="1_yhiab"] [ext_resource type="Script" uid="uid://dt7qbvowj1sm4" path="res://Pegs/Actions/ShootShortbow.cs" id="1_yhiab"]
[ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="2_uaien"] [ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="2_uaien"]
[node name="Shortbow" type="Node2D" unique_id=518048625] [node name="ShootShortbow" type="Node2D" unique_id=518048625]
script = ExtResource("1_yhiab") script = ExtResource("1_yhiab")
[node name="Image" type="Sprite2D" parent="." unique_id=944294157] [node name="Image" type="Sprite2D" parent="." unique_id=944294157]
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://c6df6ib0qan5g"] [gd_scene format=3 uid="uid://c6df6ib0qan5g"]
[ext_resource type="Script" uid="uid://td6dv1t4y5os" path="res://Pegs/Actions/Shortsword.cs" id="1_rflgk"] [ext_resource type="Script" uid="uid://td6dv1t4y5os" path="res://Pegs/Actions/SwingShortsword.cs" id="1_rflgk"]
[ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="2_fs74r"] [ext_resource type="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="2_fs74r"]
[node name="Shortsword" type="Node2D" unique_id=518048625] [node name="Shortsword" type="Node2D" unique_id=518048625]
+9
View File
@@ -0,0 +1,9 @@
[gd_scene format=3 uid="uid://xx4n81m8hbxv"]
[ext_resource type="Script" uid="uid://bj2lg1voxioq7" path="res://Pegs/Actions/ThrustSpear.cs" id="1_revbx"]
[node name="ThrustSpear" type="Node2D" unique_id=460007250]
script = ExtResource("1_revbx")
[node name="Image" type="Sprite2D" parent="." unique_id=1133735272]
visible = false
+1 -1
View File
@@ -12,7 +12,7 @@ public partial class Spearman : FriendlyPeg
_visibility = 4; _visibility = 4;
} }
public override List<Vector2I> GetGoals() public override List<Vector2I> Target()
{ {
Map map = _pegController._playArea._map; Map map = _pegController._playArea._map;
List<Peg> enemies = [.. _pegController._pegs.Where(p => p._disposition == -_disposition)]; List<Peg> enemies = [.. _pegController._pegs.Where(p => p._disposition == -_disposition)];
+1 -1
View File
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://b3a0x3r3yx861" path="res://Pegs/HostilePegs/Archer.cs" id="1_ij48w"] [ext_resource type="Script" uid="uid://b3a0x3r3yx861" path="res://Pegs/HostilePegs/Archer.cs" id="1_ij48w"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_j7but"] [ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_j7but"]
[ext_resource type="PackedScene" uid="uid://duspilwelsiy3" path="res://Pegs/Actions/shortbow.tscn" id="3_c81uf"] [ext_resource type="PackedScene" uid="uid://duspilwelsiy3" path="res://Pegs/Actions/shoot_shortbow.tscn" id="3_c81uf"]
[ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="3_j7but"] [ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="3_j7but"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
+1 -1
View File
@@ -2,7 +2,7 @@
[ext_resource type="Script" uid="uid://xlg4cblo1vf1" path="res://Pegs/HostilePegs/Infantry.cs" id="1_wlksp"] [ext_resource type="Script" uid="uid://xlg4cblo1vf1" path="res://Pegs/HostilePegs/Infantry.cs" id="1_wlksp"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_b77ka"] [ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_b77ka"]
[ext_resource type="PackedScene" uid="uid://c6df6ib0qan5g" path="res://Pegs/Actions/shortsword.tscn" id="3_lwlv5"] [ext_resource type="PackedScene" uid="uid://c6df6ib0qan5g" path="res://Pegs/Actions/swing_shortsword.tscn" id="3_lwlv5"]
[ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="4_b77ka"] [ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="4_b77ka"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"] [sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
+5
View File
@@ -34,4 +34,9 @@ public partial class PegAction : Node2D
{ {
_usesRemaining = _usesMax; _usesRemaining = _usesMax;
} }
public virtual Vector2 Target(Peg PEG)
{
return PEG.GlobalPosition;
}
} }
+2 -2
View File
File diff suppressed because one or more lines are too long