Added building flipping
This commit is contained in:
@@ -20,7 +20,7 @@ namespace Fruitomation.Game
|
||||
private bool[,] InhabitedCells { get; } = new bool[96, 49];
|
||||
private List<BuildingInfo> Buildings { get; } = new();
|
||||
|
||||
public bool AddBuildingAt(Vector2Int position, GameObject prefab, bool updateCellMap = false)
|
||||
public bool AddBuildingAt(Vector2Int position, GameObject prefab, bool isFlipped)
|
||||
{
|
||||
//
|
||||
GameObject go = Instantiate(prefab, transform);
|
||||
@@ -32,17 +32,19 @@ namespace Fruitomation.Game
|
||||
|
||||
Vector2Int p0 = position * 40;
|
||||
Vector2Int p1 = p0 + new Vector2Int(20, 100);
|
||||
|
||||
|
||||
Vector2Int g0 = position + new Vector2Int(48, 24);
|
||||
|
||||
|
||||
Vector2 off0 = info.Building.SizeOnGrid - Vector2.one;
|
||||
Vector2 off1 = off0 * 20;
|
||||
|
||||
info.Rect.sizeDelta = info.Building.SizeOnGrid * 40;
|
||||
info.Rect.anchoredPosition = p1 + off1;
|
||||
|
||||
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++)
|
||||
@@ -53,7 +55,7 @@ namespace Fruitomation.Game
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
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++)
|
||||
|
||||
@@ -16,7 +16,8 @@ namespace Fruitomation.Game
|
||||
{
|
||||
if (other.transform.parent.TryGetComponent(out Rigidbody2D body))
|
||||
{
|
||||
body?.AddForce(-transform.right * Mathf.PI, ForceMode2D.Impulse);
|
||||
Vector3 force = new(-transform.localScale.x, 0f, 0f);
|
||||
body?.AddForce(force * Mathf.PI, ForceMode2D.Impulse);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user