diff --git a/theProject/Assets/Scripts/Algorithms/Pathfinding.cs b/theProject/Assets/Scripts/Algorithms/Pathfinding.cs index 3afb0b02..52b1c379 100644 --- a/theProject/Assets/Scripts/Algorithms/Pathfinding.cs +++ b/theProject/Assets/Scripts/Algorithms/Pathfinding.cs @@ -24,7 +24,7 @@ public class Pathfinding : MonoBehaviour public bool FindPath(Vector2Int startCoords, Vector2Int endCoords, out List path, int maxPathPointDistanceFromStart = int.MaxValue) { path = new List(); - if (TilemapManager.ins.GetTileState(endCoords.x, endCoords.y) == TilemapManager.TileState.outOfBounds) + if (TilemapManager.GetTileState(endCoords.x, endCoords.y) == TilemapManager.TileState.outOfBounds) { return false; } @@ -99,7 +99,7 @@ public class Pathfinding : MonoBehaviour private int GetTargetCost(int cost, Vector2Int targetCoords) { - TilemapManager.TileState targetState = TilemapManager.ins.GetTileState(targetCoords.x, targetCoords.y); + TilemapManager.TileState targetState = TilemapManager.GetTileState(targetCoords.x, targetCoords.y); if(targetState == TilemapManager.TileState.free) { return cost + EMPTY_TILE_COST; @@ -119,7 +119,7 @@ public class Pathfinding : MonoBehaviour neighbors.Add(coords + Vector2Int.right); foreach(Vector2Int neighbor in neighbors) { - if(TilemapManager.ins.GetTileState(neighbor.x, neighbor.y) != TilemapManager.TileState.outOfBounds) + if(TilemapManager.GetTileState(neighbor.x, neighbor.y) != TilemapManager.TileState.outOfBounds) { final.Add(neighbor); } diff --git a/theProject/Assets/Scripts/Entities/Soldier.cs b/theProject/Assets/Scripts/Entities/Soldier.cs index 158b6235..3c33c7b9 100644 --- a/theProject/Assets/Scripts/Entities/Soldier.cs +++ b/theProject/Assets/Scripts/Entities/Soldier.cs @@ -8,6 +8,7 @@ public class Soldier : Entity { private Queue actions = new Queue(); private Queue interrupts = new Queue(); + public Squad MySquad = null; #region Action Queue Items abstract class Action // action "template" { diff --git a/theProject/Assets/Scripts/Squad.cs b/theProject/Assets/Scripts/Squad.cs index c8ac6558..95cfe4a7 100644 --- a/theProject/Assets/Scripts/Squad.cs +++ b/theProject/Assets/Scripts/Squad.cs @@ -49,12 +49,14 @@ public class Squad : MonoBehaviour public void AddSoldierToSquad(Entity soldier) { soldiers.Add(soldier); + ((Soldier)soldier).MySquad = this; soldier.OnDeath.AddListener(RemoveSoldierFromSquad); } public void RemoveSoldierFromSquad(Entity soldier) { soldiers.Remove(soldier); + ((Soldier)soldier).MySquad = null; soldier.OnDeath.RemoveListener(RemoveSoldierFromSquad); }