Can now destroy buildings

This commit is contained in:
2026-04-13 13:28:45 +01:00
parent b481b27f8b
commit d8253bd275
9 changed files with 439 additions and 27 deletions

View File

@@ -18,7 +18,9 @@ namespace Fruitomation.Game
}
private bool[,] InhabitedCells { get; } = new bool[96, 49];
private List<BuildingInfo> Buildings { get; } = new();
private List<Building> Buildings { get; } = new();
public void RemoveBuilding(Building building) => Buildings.Remove(building);
public bool AddBuildingAt(Vector2Int position, GameObject prefab, bool isFlipped)
{
@@ -29,6 +31,8 @@ namespace Fruitomation.Game
go.GetComponent<Building>(),
go.GetComponent<RectTransform>()
);
info.Building.SetManager(this);
Vector2Int p0 = position * 40;
Vector2Int p1 = p0 + new Vector2Int(20, 100);
@@ -43,8 +47,6 @@ namespace Fruitomation.Game
info.Rect.transform.localScale = new Vector3(isFlipped ? -1f : 1f, 1f, 1f);
Debug.Log(g0);
//
for (int x = g0.x; x < g0.x + info.Building.SizeOnGrid.x; x++)
for (int y = g0.y; y < g0.y + info.Building.SizeOnGrid.y; y++)
@@ -63,7 +65,7 @@ namespace Fruitomation.Game
InhabitedCells[x, y] = true;
}
Buildings.Add(info);
Buildings.Add(info.Building);
return true;
}
}