still working out movement
This commit is contained in:
@@ -20,10 +20,10 @@ public partial class BasicMovement : PegAction
|
||||
{
|
||||
PegController pegController = PEG._pegController;
|
||||
Map map = pegController._playArea._map;
|
||||
Vector2I cell = PEG._path[0];
|
||||
MapCell cell = PEG._path[0];
|
||||
|
||||
Tween subtween = CreateTween();
|
||||
Vector2 target = map.GetCellPositionFromAddress(cell);
|
||||
Vector2 target = cell.GlobalPosition;
|
||||
|
||||
subtween.TweenProperty(PEG, "global_position", target, 0.25f);
|
||||
PEG._path.RemoveAt(0);
|
||||
@@ -32,23 +32,23 @@ public partial class BasicMovement : PegAction
|
||||
|
||||
public override void DoImmediately(Peg PEG)
|
||||
{
|
||||
List<Vector2I> path = PEG.GetBestPath(true);
|
||||
List<MapCell> path = PEG.GetBestPath(true);
|
||||
PegController pegController = PEG._pegController;
|
||||
Map map = pegController._playArea._map;
|
||||
if (path?.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Vector2I cell = path[0];
|
||||
MapCell cell = path[0];
|
||||
|
||||
map.SetCellPeg(map._cells[cell], PEG);
|
||||
map.SetCellPeg(cell, PEG);
|
||||
PEG._path.Add(cell);
|
||||
}
|
||||
|
||||
public override bool MeetsCriteria(Peg PEG)
|
||||
{
|
||||
List<Vector2I> bestPath = PEG.GetBestPath(true);
|
||||
return base.MeetsCriteria(PEG) && bestPath.Count > 0 && (int)PEG._pegController._playArea._map.GetCellTileData(bestPath[0]).GetCustomData("disposition") != -(int)PEG._disposition;
|
||||
List<MapCell> bestPath = PEG.GetBestPath(true);
|
||||
return base.MeetsCriteria(PEG) && bestPath.Count > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,10 @@ public partial class ThrustSpear : PegAction
|
||||
public override Tween CreateAnimation(Peg PEG)
|
||||
{
|
||||
MapCell target = Target(PEG);
|
||||
if (target == PEG._cell)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
Tween subtween = CreateTween();
|
||||
|
||||
subtween.TweenProperty(_image, "visible", true, 0.0f);
|
||||
@@ -36,5 +40,4 @@ public partial class ThrustSpear : PegAction
|
||||
return PEG.Goal();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
script = ExtResource("1_revbx")
|
||||
|
||||
[node name="Image" type="Sprite2D" parent="." unique_id=1133735272]
|
||||
visible = false
|
||||
position = Vector2(0, -4.999999)
|
||||
scale = Vector2(0.1, 0.1)
|
||||
texture = ExtResource("2_nwcvh")
|
||||
|
||||
@@ -14,11 +14,10 @@ public partial class Spearman : FriendlyPeg
|
||||
|
||||
public override MapCell Goal()
|
||||
{
|
||||
Map map = _pegController._playArea._map;
|
||||
Dictionary<Vector2I, MapCell> enemies = GetVisibleEnemies();
|
||||
if (enemies.Count == 0)
|
||||
{
|
||||
return _map._cells[_address];
|
||||
return _cell;
|
||||
}
|
||||
Dictionary<Vector2I, MapCell> closest = enemies.OrderBy(e => (e.Value._occupant._address - _address).Length()).ToDictionary();
|
||||
return closest.ElementAt(0).Value;
|
||||
|
||||
@@ -2,7 +2,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" path="res://Pegs/Actions/swing_shortsword.tscn" id="3_b77ka"]
|
||||
[ext_resource type="PackedScene" uid="uid://c6df6ib0qan5g" path="res://Pegs/Actions/swing_shortsword.tscn" id="3_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"]
|
||||
|
||||
Reference in New Issue
Block a user