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:
+49
-4
@@ -13,7 +13,7 @@ using System.Xml;
|
||||
public partial class PegController : TurnController
|
||||
{
|
||||
public int _pegsCreated = 0, _pegsDestroyed = 0;
|
||||
public List<PackedScene> _hostilePegScenes;
|
||||
public List<PackedScene> _hostilePegScenes, _friendlyPegScenes, _neutralPegScenes;
|
||||
public List<Peg> _pegs = new();
|
||||
public PlayerController _playerController;
|
||||
public Dictionary<string, List<Tuple<Peg, PegAction>>> _tweenStages = new();
|
||||
@@ -24,10 +24,51 @@ public partial class PegController : TurnController
|
||||
{
|
||||
base._Ready();
|
||||
_hostilePegScenes = [.. Directory.GetFiles("Pegs/HostilePegs/", "*.tscn").Select(f => GD.Load<PackedScene>(f))];
|
||||
_friendlyPegScenes = [.. Directory.GetFiles("Pegs/FriendlyPegs/", "*.tscn").Select(f => GD.Load<PackedScene>(f))];
|
||||
// _neutralPegScenes = [.. Directory.GetFiles("Pegs/NeutralPegs/", "*.tscn").Select(f => GD.Load<PackedScene>(f))];
|
||||
|
||||
// _pegProbabilities.Load("res://PegProbabilities.xml");
|
||||
}
|
||||
|
||||
public void AddFriendlyPegs(int PEG_COUNT = 1)
|
||||
{
|
||||
for (int i = 0; i < PEG_COUNT; i++)
|
||||
{
|
||||
FriendlyPeg newFriendlyPeg = Globals.GetRandomFromList(_friendlyPegScenes).Instantiate<FriendlyPeg>();
|
||||
newFriendlyPeg._id = _pegsCreated;
|
||||
newFriendlyPeg.Death += HandlePegRemoval;
|
||||
newFriendlyPeg.Click += HandlePegClick;
|
||||
|
||||
newFriendlyPeg._pegController = this;
|
||||
|
||||
List<Vector2I> unoccupied = [.. _playArea._map._bottomRow.Where(c => _pegs.All(e => e._address != c))];
|
||||
Vector2I randomCell = unoccupied[Globals._rng.Next(unoccupied.Count)];
|
||||
|
||||
SetPeg(newFriendlyPeg, randomCell);
|
||||
_pegs.Add(newFriendlyPeg);
|
||||
AddChild(newFriendlyPeg);
|
||||
_pegsCreated++;
|
||||
}
|
||||
}
|
||||
public void AddFriendlyPegs(List<Vector2I> POSITIONS)
|
||||
{
|
||||
for (int i = 0; i < POSITIONS.Count; i++)
|
||||
{
|
||||
FriendlyPeg newFriendlyPeg = Globals.GetRandomFromList(_friendlyPegScenes).Instantiate<FriendlyPeg>();
|
||||
newFriendlyPeg._id = _pegsCreated;
|
||||
newFriendlyPeg.Scale *= _pegsCreated == 4 ? 1.5f : 1f;
|
||||
newFriendlyPeg.Death += HandlePegRemoval;
|
||||
newFriendlyPeg.Click += HandlePegClick;
|
||||
|
||||
newFriendlyPeg._pegController = this;
|
||||
|
||||
SetPeg(newFriendlyPeg, POSITIONS[i]);
|
||||
_pegs.Add(newFriendlyPeg);
|
||||
AddChild(newFriendlyPeg);
|
||||
_pegsCreated++;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddHostilePegs(int PEG_COUNT = 1)
|
||||
{
|
||||
for (int i = 0; i < PEG_COUNT; i++)
|
||||
@@ -152,9 +193,13 @@ public partial class PegController : TurnController
|
||||
|
||||
public void Initiate()
|
||||
{
|
||||
List<Vector2I> positions = [.. _playArea.GetNode<TileMapLayer>("InitialPositions").GetUsedCells().OrderBy(c => c.Y).ThenBy(c => c.X)];
|
||||
|
||||
AddHostilePegs(positions);
|
||||
TileMapLayer init = _playArea.GetNode<TileMapLayer>("InitialPositions");
|
||||
List<Vector2I> initPos = [.. init.GetUsedCells()];
|
||||
List<Vector2I> positions = [.. initPos.OrderBy(c => c.Y).ThenBy(c => c.X)];
|
||||
List<Vector2I> hPositions = [.. positions.Where(c => (int)init.GetCellTileData(c).GetCustomData("disposition") == -1)];
|
||||
List<Vector2I> fPositions = [.. positions.Where(c => (int)init.GetCellTileData(c).GetCustomData("disposition") == 1)];
|
||||
AddHostilePegs(hPositions);
|
||||
AddFriendlyPegs(fPositions);
|
||||
}
|
||||
|
||||
public void ProcessTween()
|
||||
|
||||
Reference in New Issue
Block a user