implemented visibility, so pegs can only scope out as far as they can see.

This commit is contained in:
2026-06-30 18:24:11 -04:00
parent c8e81e4f48
commit b1625b15a0
8 changed files with 53 additions and 32 deletions
+9 -9
View File
@@ -5,6 +5,8 @@ using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection.Metadata;
using System.Reflection.Metadata.Ecma335;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
@@ -52,6 +54,7 @@ public partial class PegController : TurnController
{
HostilePeg newHostilePeg = Globals.GetRandomFromList(_hostilePegScenes).Instantiate<HostilePeg>();
newHostilePeg._id = _pegsCreated;
newHostilePeg.Scale *= _pegsCreated == 4 ? 1.5f : 1f;
newHostilePeg.Death += HandlePegRemoval;
newHostilePeg.Click += HandlePegClick;
@@ -80,6 +83,7 @@ public partial class PegController : TurnController
if (action != null)
{
action.DoImmediately(peg);
string key = action._priority + ":" + loop;
if (!_tweenStages.ContainsKey(key))
{
@@ -90,24 +94,23 @@ public partial class PegController : TurnController
{
anyPegsActed = true;
}
peg._staminaRemaining -= action._cost;
}
}
loop++;
}
ProcessTween();
}
public void HandlePegClick(Node CLICKED_NODE, int CLICK_TYPE)
{
TileMapLayer pathLayer = _playArea.GetNode<TileMapLayer>("PathLayer");
if (CLICKED_NODE is not Peg peg)
{
return;
}
if (CLICK_TYPE == 0)
{
if (peg._staminaRemaining <= 0){
return;
}
TileMapLayer pathLayer = _playArea.GetNode<TileMapLayer>("PathLayer");
List<Vector2I> newPath = peg.GetBestPath();
pathLayer.GetUsedCells().ToList().ForEach(c => pathLayer.SetCell(c,0,Vector2I.Down*4));
@@ -138,7 +141,7 @@ public partial class PegController : TurnController
public void Initiate()
{
List<Vector2I> positions = [.. _playArea.GetNode<TileMapLayer>("InitialPositions").GetUsedCells()];
List<Vector2I> positions = [.. _playArea.GetNode<TileMapLayer>("InitialPositions").GetUsedCells().OrderBy(c => c.Y).ThenBy(c => c.X)];
AddHostilePegs(positions);
}
@@ -181,12 +184,9 @@ public partial class PegController : TurnController
{
_pegs[i].StartTurn();
}
HandlePegSort();
HandlePegTurn();
ProcessTween();
}
public void SetPeg(Peg PEG, Vector2I CELL)