mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-11-20 01:14:27 +01:00
feat: formation in middle
soldiers allign on the left and right of where we clicked
This commit is contained in:
parent
6146d64dba
commit
4cdc53a377
@ -18,18 +18,21 @@ public class Formation : MonoBehaviour
|
|||||||
List<Entity> soldiers = squad.GetSoldiers();
|
List<Entity> soldiers = squad.GetSoldiers();
|
||||||
Dictionary<Entity, Vector2Int> soldiersNewCoordinates = new Dictionary<Entity, Vector2Int>();
|
Dictionary<Entity, Vector2Int> soldiersNewCoordinates = new Dictionary<Entity, Vector2Int>();
|
||||||
int soldierNumber = 0;
|
int soldierNumber = 0;
|
||||||
|
int add = 1;
|
||||||
foreach (Entity Entity in soldiers)
|
foreach (Entity Entity in soldiers)
|
||||||
{
|
{
|
||||||
soldiersNewCoordinates.Add(Entity, CalculateSoldierCoordinates(soldierNumber, coordinates));
|
soldiersNewCoordinates.Add(Entity, CalculateSoldierCoordinates(soldierNumber, coordinates, add));
|
||||||
soldierNumber++;
|
soldierNumber++;
|
||||||
|
add *= -1;
|
||||||
}
|
}
|
||||||
return soldiersNewCoordinates;
|
return soldiersNewCoordinates;
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/in-parameter-modifier
|
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/in-parameter-modifier
|
||||||
private Vector2Int CalculateSoldierCoordinates(in int soldierNumber, in Vector2Int coordinates)
|
private Vector2Int CalculateSoldierCoordinates(int soldierNumber, in Vector2Int coordinates,in int add)
|
||||||
{
|
{
|
||||||
// Horizontal line we change x
|
// Horizontal line we change x
|
||||||
|
soldierNumber = add * soldierNumber;
|
||||||
TilemapManager.TileState tileState = TilemapManager.GetTileState(coordinates.x + soldierNumber, coordinates.y);
|
TilemapManager.TileState tileState = TilemapManager.GetTileState(coordinates.x + soldierNumber, coordinates.y);
|
||||||
if ( tileState == TilemapManager.TileState.free)
|
if ( tileState == TilemapManager.TileState.free)
|
||||||
{
|
{
|
||||||
@ -47,4 +50,5 @@ public class Formation : MonoBehaviour
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user