implemented more code for adding more pegs, but still a lot of work to do on pathfinding, targeting, map etc.

This commit is contained in:
2026-07-02 03:15:15 -04:00
parent 909f466f92
commit cbdca6f3cb
16 changed files with 170 additions and 50 deletions
+7 -4
View File
@@ -12,12 +12,15 @@ public partial class Spearman : FriendlyPeg
_visibility = 4;
}
public override List<Vector2I> Target()
public override Vector2I Goal()
{
Map map = _pegController._playArea._map;
List<Peg> enemies = [.. _pegController._pegs.Where(p => p._disposition == -_disposition)];
List<Vector2I> neighboring = [.. map._cells.Where(c => enemies.Any(e => (e._address - c).Length() <= 1f))];
List<Vector2I> closest = [.. neighboring.OrderBy(c => (c - _address).Length())];
return closest;
if (enemies.Count == 0)
{
return _address;
}
List<Vector2I> closest = [.. enemies.OrderBy(e => (e._address - _address).Length()).Select(e => e._address)];
return closest[0];
}
}
+7
View File
@@ -2,6 +2,8 @@
[ext_resource type="Script" uid="uid://dd4k8egcg3r2v" path="res://Pegs/FriendlyPegs/Spearman.cs" id="1_rd6ui"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_v2nt8"]
[ext_resource type="PackedScene" uid="uid://xx4n81m8hbxv" path="res://Pegs/Actions/thrust_spear.tscn" id="3_ig48t"]
[ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="4_gi7y5"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
bounce = 0.5
@@ -21,12 +23,17 @@ script = ExtResource("1_rd6ui")
shape = SubResource("CircleShape2D_4gyqm")
[node name="Sprite2D" type="Sprite2D" parent="." unique_id=1941012605]
modulate = Color(1, 1, 0, 1)
texture_filter = 1
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_v2nt8")
[node name="Actions" type="Node2D" parent="." unique_id=2023031702]
[node name="ThrustSpear" parent="Actions" unique_id=460007250 instance=ExtResource("3_ig48t")]
[node name="BasicMovement" parent="Actions" unique_id=791425339 instance=ExtResource("4_gi7y5")]
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
[node name="CollisionShape2D" type="CollisionShape2D" parent="HoverBounds" unique_id=2142666816]