Can now destroy buildings
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user