undergoing a shift to change movement into another action that a peg can perform and giving pegs a list of actions order by priority

This commit is contained in:
2026-06-29 02:43:25 -04:00
parent f6c54e0730
commit ebdff1b200
16 changed files with 148 additions and 110 deletions
+41
View File
@@ -0,0 +1,41 @@
using Godot;
using System;
using System.Collections.Generic;
public partial class BasicMovement : PegAction
{
public override void _Ready()
{
base._Ready();
_healthChange = 0;
_cost = 1;
_range = 2^32;
_usesMax = 2^32;
_usesRemaining = _usesMax;
}
public override Tween CreateAnimation(Peg PEG)
{
List<Vector2I> path = PEG.GetBestPath();
PegController pegController = PEG._pegController;
Map map = pegController._playArea._map;
if (path?.Count == 0)
{
return null;
}
Vector2I cell = path[0];
map.SetCellPeg(cell, PEG);
PEG._path.Add(cell);
Tween subtween = CreateTween();
subtween.TweenProperty(this, "global_position", map.GetCellPositionFromAddress(cell), 0.25f);
return subtween;
}
public override bool MeetsCriteria(Peg PEG)
{
return base.MeetsCriteria(PEG) && PEG._address.Y > PEG._pegController._playArea._map._firstOpenRow;
}
}
+1
View File
@@ -0,0 +1 @@
uid://hp5iucbq5brg
+1 -1
View File
@@ -7,13 +7,13 @@ public partial class Shortbow : PegAction
public override void _Ready()
{
base._Ready();
_priority = 1000;
_healthChange = -1;
_cost = 2;
_range = 1;
_usesMax = 1;
_usesRemaining = _usesMax;
}
public override Tween CreateAnimation(Peg PEG)
{
Vector2 target = PEG._pegController._playerController._towers.OrderBy(t => (t.GlobalPosition - GlobalPosition).Length()).ToList()[0].GlobalPosition;
+3 -3
View File
@@ -7,19 +7,19 @@ public partial class Shortsword : PegAction
public override void _Ready()
{
base._Ready();
_priority = 1000;
_healthChange = -2;
_cost = 2;
_range = 0;
_usesMax = 1;
_usesRemaining = _usesMax;
}
public override Tween CreateAnimation(Peg PEG)
{
Vector2 target = PEG.GlobalPosition + (Vector2.Up * 50);
Vector2 target = Vector2.Up * PEG._pegController._playArea._map._cellSize;
Tween subtween = CreateTween();
subtween.TweenProperty(_image, "visible", true, 0.0f);
subtween.TweenProperty(_image, "global_position", target, 0.5f);
subtween.TweenProperty(_image, "position", target, 0.5f);
subtween.TweenCallback(Callable.From(() =>
{
PEG._pegController._playerController.ChangeHealth(_healthChange, this);
+9
View File
@@ -0,0 +1,9 @@
[gd_scene format=3 uid="uid://bup5oli00p3lg"]
[ext_resource type="Script" uid="uid://hp5iucbq5brg" path="res://Pegs/Actions/BasicMovement.cs" id="1_u1rld"]
[node name="BasicMovement" type="Node2D" unique_id=460007250]
script = ExtResource("1_u1rld")
[node name="Image" type="Sprite2D" parent="." unique_id=1133735272]
visible = false
+4
View File
@@ -1,8 +1,12 @@
[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="Texture2D" uid="uid://32m5teus1cjj" path="res://Art/tower.png" id="2_uaien"]
[node name="Shortbow" type="Node2D" unique_id=518048625]
script = ExtResource("1_yhiab")
[node name="Image" type="Sprite2D" parent="." unique_id=944294157]
visible = false
scale = Vector2(0.1, 0.1)
texture = ExtResource("2_uaien")
-1
View File
@@ -7,6 +7,5 @@ public partial class Archer : HostilePeg
{
base._Ready();
_stamina = 2;
_action = GetNode<Shortbow>("Shortbow");
}
}
-1
View File
@@ -7,6 +7,5 @@ public partial class Infantry : HostilePeg
{
base._Ready();
_stamina = 3;
_action = GetNode<Shortsword>("Shortsword");
}
}
+6 -1
View File
@@ -3,6 +3,7 @@
[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="PackedScene" uid="uid://duspilwelsiy3" path="res://Pegs/Actions/shortbow.tscn" id="3_c81uf"]
[ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="3_j7but"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
bounce = 0.5
@@ -27,7 +28,11 @@ texture_filter = 1
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_j7but")
[node name="Shortbow" parent="." unique_id=518048625 instance=ExtResource("3_c81uf")]
[node name="Actions" type="Node" parent="." unique_id=614093526]
[node name="BasicMovement" parent="Actions" unique_id=460007250 instance=ExtResource("3_j7but")]
[node name="Shortbow" parent="Actions" unique_id=518048625 instance=ExtResource("3_c81uf")]
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
+6 -1
View File
@@ -3,6 +3,7 @@
[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="PackedScene" uid="uid://c6df6ib0qan5g" path="res://Pegs/Actions/shortsword.tscn" id="3_lwlv5"]
[ext_resource type="PackedScene" uid="uid://bup5oli00p3lg" path="res://Pegs/Actions/basic_movement.tscn" id="4_b77ka"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
bounce = 0.5
@@ -27,7 +28,11 @@ texture_filter = 1
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_b77ka")
[node name="Shortsword" parent="." unique_id=518048625 instance=ExtResource("3_lwlv5")]
[node name="Actions" type="Node" parent="." unique_id=2081138574]
[node name="Shortsword" parent="Actions" unique_id=518048625 instance=ExtResource("3_lwlv5")]
[node name="BasicMovement" parent="Actions" unique_id=460007250 instance=ExtResource("4_b77ka")]
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
+12
View File
@@ -16,4 +16,16 @@ public partial class PegAction : Node2D
{
return null;
}
public virtual bool MeetsCriteria(Peg PEG)
{
return PEG._staminaRemaining >= _cost
&& _usesRemaining > 0
&& PEG._address.Y <= _range;
}
public virtual void Reset()
{
_usesRemaining = _usesMax;
}
}
+1 -2
View File
@@ -2,7 +2,6 @@
[ext_resource type="Script" uid="uid://dfba4vq6jv0a6" path="res://Pegs/HostilePeg.cs" id="1_nc8fp"]
[ext_resource type="Texture2D" uid="uid://nwj4n7if8kqd" path="res://Art/circle25r.png" id="2_0icqg"]
[ext_resource type="PackedScene" uid="uid://bj2qrn0l01us1" path="res://Pegs/peg_action.tscn" id="3_nc8fp"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_7k104"]
bounce = 0.5
@@ -26,7 +25,7 @@ texture_filter = 1
scale = Vector2(0.5, 0.5)
texture = ExtResource("2_0icqg")
[node name="PegAction" parent="." unique_id=637569115 instance=ExtResource("3_nc8fp")]
[node name="Actions" type="Node" parent="." unique_id=218609326]
[node name="HoverBounds" type="Area2D" parent="." unique_id=937525982]
+1
View File
@@ -6,3 +6,4 @@
script = ExtResource("1_8o8tf")
[node name="Image" type="Sprite2D" parent="." unique_id=1133735272]
visible = false