mirror of
https://github.com/kuhyx/WUT_Computer_Science.git
synced 2026-07-04 15:43:16 +02:00
feat: detect edges in formation
This commit is contained in:
parent
635c7d2b0a
commit
6146d64dba
55
theProject/.vscode/settings.json
vendored
Normal file
55
theProject/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,55 @@
|
||||
{
|
||||
"files.exclude":
|
||||
{
|
||||
"**/.DS_Store":true,
|
||||
"**/.git":true,
|
||||
"**/.gitmodules":true,
|
||||
"**/*.booproj":true,
|
||||
"**/*.pidb":true,
|
||||
"**/*.suo":true,
|
||||
"**/*.user":true,
|
||||
"**/*.userprefs":true,
|
||||
"**/*.unityproj":true,
|
||||
"**/*.dll":true,
|
||||
"**/*.exe":true,
|
||||
"**/*.pdf":true,
|
||||
"**/*.mid":true,
|
||||
"**/*.midi":true,
|
||||
"**/*.wav":true,
|
||||
"**/*.gif":true,
|
||||
"**/*.ico":true,
|
||||
"**/*.jpg":true,
|
||||
"**/*.jpeg":true,
|
||||
"**/*.png":true,
|
||||
"**/*.psd":true,
|
||||
"**/*.tga":true,
|
||||
"**/*.tif":true,
|
||||
"**/*.tiff":true,
|
||||
"**/*.3ds":true,
|
||||
"**/*.3DS":true,
|
||||
"**/*.fbx":true,
|
||||
"**/*.FBX":true,
|
||||
"**/*.lxo":true,
|
||||
"**/*.LXO":true,
|
||||
"**/*.ma":true,
|
||||
"**/*.MA":true,
|
||||
"**/*.obj":true,
|
||||
"**/*.OBJ":true,
|
||||
"**/*.asset":true,
|
||||
"**/*.cubemap":true,
|
||||
"**/*.flare":true,
|
||||
"**/*.mat":true,
|
||||
"**/*.meta":true,
|
||||
"**/*.prefab":true,
|
||||
"**/*.unity":true,
|
||||
"build/":true,
|
||||
"Build/":true,
|
||||
"Library/":true,
|
||||
"library/":true,
|
||||
"obj/":true,
|
||||
"Obj/":true,
|
||||
"ProjectSettings/":true,
|
||||
"temp/":true,
|
||||
"Temp/":true
|
||||
}
|
||||
}
|
||||
@ -5,7 +5,7 @@ using UnityEngine;
|
||||
|
||||
public class Formation : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Squad squad;
|
||||
[SerializeField] Squad squad;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -29,9 +29,21 @@ public class Formation : MonoBehaviour
|
||||
// https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/in-parameter-modifier
|
||||
private Vector2Int CalculateSoldierCoordinates(in int soldierNumber, in Vector2Int coordinates)
|
||||
{
|
||||
// Horizontal line we change x
|
||||
Vector2Int soldierCoordinates = new Vector2Int(coordinates.x + soldierNumber, coordinates.y);
|
||||
return soldierCoordinates;
|
||||
// Horizontal line we change x
|
||||
TilemapManager.TileState tileState = TilemapManager.GetTileState(coordinates.x + soldierNumber, coordinates.y);
|
||||
if ( tileState == TilemapManager.TileState.free)
|
||||
{
|
||||
Vector2Int soldierCoordinates = new Vector2Int(coordinates.x + soldierNumber, coordinates.y);
|
||||
return soldierCoordinates;
|
||||
} else if (tileState == TilemapManager.TileState.taken)
|
||||
{
|
||||
Vector2Int soldierCoordinates = new Vector2Int(coordinates.x, coordinates.y);
|
||||
return soldierCoordinates;
|
||||
} else
|
||||
{
|
||||
Vector2Int soldierCoordinates = new Vector2Int(coordinates.x, coordinates.y);
|
||||
return soldierCoordinates;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -174,12 +174,12 @@ public class TilemapManager : MonoBehaviour
|
||||
|
||||
// ---------- private methods
|
||||
|
||||
private TileState GetTileState(int x, int y)
|
||||
public static TileState GetTileState(int x, int y)
|
||||
{
|
||||
if (x < 0 || y < 0 || x >= mapSize.x || y >= mapSize.y)
|
||||
if (x < 0 || y < 0 || x >= ins.mapSize.x || y >= ins.mapSize.y)
|
||||
return TileState.outOfBounds;
|
||||
|
||||
if (tiles[x, y].standingEntity == null)
|
||||
if (ins.tiles[x, y].standingEntity == null)
|
||||
return TileState.free;
|
||||
|
||||
return TileState.taken;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user