debugging
This commit is contained in:
+9
-8
@@ -115,19 +115,20 @@ public partial class EnemyController : TurnController
|
||||
|
||||
public void MoveEnemies()
|
||||
{
|
||||
Map map = _playArea._map;
|
||||
for (int i = 0; i < _enemies.Count; i++)
|
||||
{
|
||||
Enemy enemy = _enemies[i];
|
||||
enemy._speedRemaining = enemy._address.Y <= _playArea._map._minY ? 0 : enemy._speed;
|
||||
enemy._speedRemaining = enemy._address.Y <= map._minY ? 0 : enemy._speed;
|
||||
|
||||
if (enemy._speedRemaining > 0)
|
||||
{
|
||||
Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, _playArea._map._minY)));
|
||||
Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, map._minY)));
|
||||
if (enemy._address == Vector2I.Zero)
|
||||
{
|
||||
GD.Print(1,goal);
|
||||
}
|
||||
enemy._path = _playArea._map.GetPath(enemy._address, goal);
|
||||
enemy._path = map.GetPath(enemy._address, goal);
|
||||
if (enemy._path.Count <= 0)
|
||||
{
|
||||
enemy._speedRemaining = 0;
|
||||
@@ -151,17 +152,17 @@ public partial class EnemyController : TurnController
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (enemy._address.Y <= _playArea._map._minY)
|
||||
if (enemy._address.Y <= map._minY)
|
||||
{
|
||||
enemy._speedRemaining = 0;
|
||||
continue;
|
||||
}
|
||||
Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, _playArea._map._minY)));
|
||||
Vector2I goal = GetBestGoal(enemy, new(enemy._address.X, Math.Max(enemy._address.Y - enemy._visibilityRange, map._minY)));
|
||||
if (enemy._address == Vector2I.Zero)
|
||||
{
|
||||
GD.Print(2,goal);
|
||||
}
|
||||
List<Vector2I> path = _playArea._map.GetPath(enemy._address, goal);
|
||||
List<Vector2I> path = map.GetPath(enemy._address, goal);
|
||||
if (path.Count == 0)
|
||||
{
|
||||
continue;
|
||||
@@ -171,7 +172,7 @@ public partial class EnemyController : TurnController
|
||||
{
|
||||
GD.Print(3, enemy._address);
|
||||
}
|
||||
_playArea._map.SetCellEnemy(cell, enemy);
|
||||
map.SetCellEnemy(cell, enemy);
|
||||
enemy._path.Add(cell);
|
||||
enemy._speedRemaining--;
|
||||
}
|
||||
@@ -199,7 +200,7 @@ public partial class EnemyController : TurnController
|
||||
{
|
||||
tween.Parallel();
|
||||
}
|
||||
tween.TweenProperty(mEnemy, "global_position", _playArea._map.GetCellPositionFromAddress(mEnemy._path[i]), .25f);
|
||||
tween.TweenProperty(mEnemy, "global_position", map.GetCellPositionFromAddress(mEnemy._path[i]), .25f);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -93,11 +93,19 @@ public partial class Map : TileMapLayer
|
||||
{
|
||||
_addressOccupants[ENEMY._address] = null;
|
||||
SetCellSolid(ENEMY._address);
|
||||
if (ENEMY._address == Vector2I.Zero)
|
||||
{
|
||||
GD.Print(4,_astar.IsPointSolid(ENEMY._address));
|
||||
}
|
||||
|
||||
ENEMY._address = ADDRESS;
|
||||
|
||||
_addressOccupants[ADDRESS] = ENEMY;
|
||||
SetCellSolid(ADDRESS);
|
||||
if (ADDRESS == Vector2I.Zero)
|
||||
{
|
||||
GD.Print(5,_astar.IsPointSolid(ADDRESS));
|
||||
}
|
||||
}
|
||||
|
||||
public void SetCellSolid(Vector2I ADDRESS)
|
||||
@@ -120,24 +128,9 @@ public partial class Map : TileMapLayer
|
||||
public List<Vector2I> GetPath(Vector2I FROM, Vector2I TO, bool INCLUDE_FROM = false)
|
||||
{
|
||||
_astar.SetPointSolid(FROM, false);
|
||||
if (FROM == Vector2I.Zero)
|
||||
{
|
||||
// GD.Print(4,_astar.IsPointSolid(FROM));
|
||||
}
|
||||
if (TO == Vector2I.Zero)
|
||||
{
|
||||
// GD.Print(5,_astar.IsPointSolid(FROM));
|
||||
}
|
||||
|
||||
List<Vector2I> pathTaken = [.. _astar.GetIdPath(FROM, TO, true)];
|
||||
_astar.SetPointSolid(FROM, true);
|
||||
if (FROM == Vector2I.Zero)
|
||||
{
|
||||
// GD.Print(6,_astar.IsPointSolid(FROM));
|
||||
}
|
||||
if (TO == Vector2I.Zero)
|
||||
{
|
||||
// GD.Print(7,_astar.IsPointSolid(FROM));
|
||||
}
|
||||
|
||||
if (!INCLUDE_FROM)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user