mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-06 20:03:10 +02:00
Merge branch 'Development' into merloj-soldier_communication
This commit is contained in:
commit
ed8f316588
@ -24,7 +24,7 @@ public class Pathfinding : MonoBehaviour
|
|||||||
public bool FindPath(Vector2Int startCoords, Vector2Int endCoords, out List<Vector2Int> path, int maxPathPointDistanceFromStart = int.MaxValue)
|
public bool FindPath(Vector2Int startCoords, Vector2Int endCoords, out List<Vector2Int> path, int maxPathPointDistanceFromStart = int.MaxValue)
|
||||||
{
|
{
|
||||||
path = new List<Vector2Int>();
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ public class Pathfinding : MonoBehaviour
|
|||||||
|
|
||||||
private int GetTargetCost(int cost, Vector2Int targetCoords)
|
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)
|
if(targetState == TilemapManager.TileState.free)
|
||||||
{
|
{
|
||||||
return cost + EMPTY_TILE_COST;
|
return cost + EMPTY_TILE_COST;
|
||||||
@ -119,7 +119,7 @@ public class Pathfinding : MonoBehaviour
|
|||||||
neighbors.Add(coords + Vector2Int.right);
|
neighbors.Add(coords + Vector2Int.right);
|
||||||
foreach(Vector2Int neighbor in neighbors)
|
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);
|
final.Add(neighbor);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ public class Soldier : Entity
|
|||||||
{
|
{
|
||||||
private Queue<Action> actions = new Queue<Action>();
|
private Queue<Action> actions = new Queue<Action>();
|
||||||
private Queue<Action> interrupts = new Queue<Action>();
|
private Queue<Action> interrupts = new Queue<Action>();
|
||||||
|
public Squad MySquad = null;
|
||||||
#region Action Queue Items
|
#region Action Queue Items
|
||||||
abstract class Action // action "template"
|
abstract class Action // action "template"
|
||||||
{
|
{
|
||||||
|
|||||||
@ -54,12 +54,14 @@ public class Squad : MonoBehaviour
|
|||||||
public void AddSoldierToSquad(Entity soldier)
|
public void AddSoldierToSquad(Entity soldier)
|
||||||
{
|
{
|
||||||
soldiers.AddToList(soldier);
|
soldiers.AddToList(soldier);
|
||||||
|
((Soldier)soldier).MySquad = this;
|
||||||
soldier.OnDeath.AddListener(RemoveSoldierFromSquad);
|
soldier.OnDeath.AddListener(RemoveSoldierFromSquad);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RemoveSoldierFromSquad(Entity soldier)
|
public void RemoveSoldierFromSquad(Entity soldier)
|
||||||
{
|
{
|
||||||
soldiers.RemoveFromList(soldier);
|
soldiers.RemoveFromList(soldier);
|
||||||
|
((Soldier)soldier).MySquad = null;
|
||||||
soldier.OnDeath.RemoveListener(RemoveSoldierFromSquad);
|
soldier.OnDeath.RemoveListener(RemoveSoldierFromSquad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user