mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 16:03:11 +02:00
Soldier now knows their squad
This commit is contained in:
parent
fe056d660e
commit
72c3b3f5f8
@ -24,7 +24,7 @@ public class Pathfinding : MonoBehaviour
|
||||
public bool FindPath(Vector2Int startCoords, Vector2Int endCoords, out List<Vector2Int> path, int maxPathPointDistanceFromStart = int.MaxValue)
|
||||
{
|
||||
path = new List<Vector2Int>();
|
||||
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);
|
||||
}
|
||||
|
||||
@ -8,6 +8,7 @@ public class Soldier : Entity
|
||||
{
|
||||
private Queue<Action> actions = new Queue<Action>();
|
||||
private Queue<Action> interrupts = new Queue<Action>();
|
||||
public Squad MySquad = null;
|
||||
#region Action Queue Items
|
||||
abstract class Action // action "template"
|
||||
{
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user