diff --git a/Assets/Scripts/Grid/GridBuildingSystem.cs b/Assets/Scripts/Grid/GridBuildingSystem.cs index 909125c..20cb119 100644 --- a/Assets/Scripts/Grid/GridBuildingSystem.cs +++ b/Assets/Scripts/Grid/GridBuildingSystem.cs @@ -86,14 +86,26 @@ public class GridBuildingSystem : MonoBehaviour selectedGameObjectTransform.gameObject.GetComponent().color = Color.white; } - if (Input.GetMouseButtonDown(0)) + if(selectedPlacedObjectTypeSO.placedObjectType == PlacedObjectTypeSO.PlacedObjectType.WAY) { - PlaceBuilding(); + if (Input.GetMouseButton(0)) + { + PlaceBuilding(); + } } - else if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) + else + { + if (Input.GetMouseButtonDown(0)) + { + PlaceBuilding(); + } + } + + if (Input.GetMouseButtonDown(1) || Input.GetKeyDown(KeyCode.Escape)) { DeselectBuilding(); } + } } public void DemolishBuilding(Vector3 position) diff --git a/Assets/Scripts/Grid/PlacedObjectTypeSO.cs b/Assets/Scripts/Grid/PlacedObjectTypeSO.cs index 7ff3763..fbb2165 100644 --- a/Assets/Scripts/Grid/PlacedObjectTypeSO.cs +++ b/Assets/Scripts/Grid/PlacedObjectTypeSO.cs @@ -5,7 +5,11 @@ using UnityEngine; [CreateAssetMenu()] public class PlacedObjectTypeSO : ScriptableObject { - + public enum PlacedObjectType + { + WAY, + BULDING + } public string nameString; public Transform prefab; //public Transform visual; @@ -13,7 +17,7 @@ public class PlacedObjectTypeSO : ScriptableObject public int height; public bool isWalkable = false; public Sprite iconSprite; - + public PlacedObjectType placedObjectType = PlacedObjectType.BULDING; public List GetGridPositionList(Vector2Int offset) {