Made buildings unable to overlap
This commit is contained in:
@@ -12,6 +12,7 @@ GameObject:
|
|||||||
- component: {fileID: 3321531399837876958}
|
- component: {fileID: 3321531399837876958}
|
||||||
- component: {fileID: 512124502862012575}
|
- component: {fileID: 512124502862012575}
|
||||||
- component: {fileID: 2938597077917375806}
|
- component: {fileID: 2938597077917375806}
|
||||||
|
- component: {fileID: -6667291122109179156}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: FanBuilding
|
m_Name: FanBuilding
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -90,3 +91,48 @@ MonoBehaviour:
|
|||||||
m_FillOrigin: 0
|
m_FillOrigin: 0
|
||||||
m_UseSpriteMesh: 0
|
m_UseSpriteMesh: 0
|
||||||
m_PixelsPerUnitMultiplier: 1
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!61 &-6667291122109179156
|
||||||
|
BoxCollider2D:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 8624048914473773482}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_Density: 1
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_IncludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_ExcludeLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 0
|
||||||
|
m_LayerOverridePriority: 0
|
||||||
|
m_ForceSendLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ForceReceiveLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_ContactCaptureLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_CallbackLayers:
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Bits: 4294967295
|
||||||
|
m_IsTrigger: 0
|
||||||
|
m_UsedByEffector: 0
|
||||||
|
m_UsedByComposite: 0
|
||||||
|
m_Offset: {x: 0, y: 0}
|
||||||
|
m_SpriteTilingProperty:
|
||||||
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
pivot: {x: 0, y: 0}
|
||||||
|
oldSize: {x: 0, y: 0}
|
||||||
|
newSize: {x: 0, y: 0}
|
||||||
|
adaptiveTilingThreshold: 0
|
||||||
|
drawMode: 0
|
||||||
|
adaptiveTiling: 0
|
||||||
|
m_AutoTiling: 0
|
||||||
|
serializedVersion: 2
|
||||||
|
m_Size: {x: 40, y: 120}
|
||||||
|
m_EdgeRadius: 0
|
||||||
|
|||||||
@@ -1304,9 +1304,9 @@ RectTransform:
|
|||||||
- {fileID: 2112507919}
|
- {fileID: 2112507919}
|
||||||
- {fileID: 2026916298}
|
- {fileID: 2026916298}
|
||||||
- {fileID: 96288173}
|
- {fileID: 96288173}
|
||||||
|
- {fileID: 2005593404}
|
||||||
- {fileID: 1330313875}
|
- {fileID: 1330313875}
|
||||||
- {fileID: 1194686691}
|
- {fileID: 1194686691}
|
||||||
- {fileID: 2005593404}
|
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
@@ -1641,7 +1641,7 @@ MonoBehaviour:
|
|||||||
RectTransform: {fileID: 1330313875}
|
RectTransform: {fileID: 1330313875}
|
||||||
BuildingPreview: {fileID: 1194686692}
|
BuildingPreview: {fileID: 1194686692}
|
||||||
CursorImage: {fileID: 1330313876}
|
CursorImage: {fileID: 1330313876}
|
||||||
BuildingManager: {fileID: 0}
|
BuildingManager: {fileID: 2005593405}
|
||||||
BuildingPrefab: {fileID: 8624048914473773482, guid: 1b5c88b3f8d08674a9b15155d6ba9a36,
|
BuildingPrefab: {fileID: 8624048914473773482, guid: 1b5c88b3f8d08674a9b15155d6ba9a36,
|
||||||
type: 3}
|
type: 3}
|
||||||
CurrentMouseClickStrength: 0
|
CurrentMouseClickStrength: 0
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ namespace Fruitomation.Game
|
|||||||
|
|
||||||
public bool AddBuildingAt(Vector2Int position, GameObject prefab, bool updateCellMap = false)
|
public bool AddBuildingAt(Vector2Int position, GameObject prefab, bool updateCellMap = false)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
GameObject go = Instantiate(prefab, transform);
|
GameObject go = Instantiate(prefab, transform);
|
||||||
BuildingInfo info = new
|
BuildingInfo info = new
|
||||||
(
|
(
|
||||||
@@ -33,12 +34,34 @@ namespace Fruitomation.Game
|
|||||||
Vector2Int p0 = position * 40;
|
Vector2Int p0 = position * 40;
|
||||||
Vector2Int p1 = p0 + new Vector2Int(20, 100);
|
Vector2Int p1 = p0 + new Vector2Int(20, 100);
|
||||||
|
|
||||||
|
Vector2Int g0 = position + new Vector2Int(48, 24);
|
||||||
|
|
||||||
Vector2 off0 = info.Building.SizeOnGrid - Vector2.one;
|
Vector2 off0 = info.Building.SizeOnGrid - Vector2.one;
|
||||||
Vector2 off1 = off0 * 20;
|
Vector2 off1 = off0 * 20;
|
||||||
|
|
||||||
info.Rect.sizeDelta = info.Building.SizeOnGrid * 40;
|
info.Rect.sizeDelta = info.Building.SizeOnGrid * 40;
|
||||||
info.Rect.anchoredPosition = p1 + off1;
|
info.Rect.anchoredPosition = p1 + off1;
|
||||||
|
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
if (InhabitedCells[x, y])
|
||||||
|
{
|
||||||
|
DestroyImmediate(go);
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
InhabitedCells[x, y] = true;
|
||||||
|
}
|
||||||
|
|
||||||
Buildings.Add(info);
|
Buildings.Add(info);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user