mousedown if way

This commit is contained in:
j.mei7
2022-03-17 19:08:16 +01:00
parent e3d888f757
commit 462caf5cf1
2 changed files with 21 additions and 5 deletions

View File

@@ -86,14 +86,26 @@ public class GridBuildingSystem : MonoBehaviour
selectedGameObjectTransform.gameObject.GetComponent<SpriteRenderer>().color = Color.white; selectedGameObjectTransform.gameObject.GetComponent<SpriteRenderer>().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(); DeselectBuilding();
} }
} }
} }
public void DemolishBuilding(Vector3 position) public void DemolishBuilding(Vector3 position)

View File

@@ -5,7 +5,11 @@ using UnityEngine;
[CreateAssetMenu()] [CreateAssetMenu()]
public class PlacedObjectTypeSO : ScriptableObject public class PlacedObjectTypeSO : ScriptableObject
{ {
public enum PlacedObjectType
{
WAY,
BULDING
}
public string nameString; public string nameString;
public Transform prefab; public Transform prefab;
//public Transform visual; //public Transform visual;
@@ -13,7 +17,7 @@ public class PlacedObjectTypeSO : ScriptableObject
public int height; public int height;
public bool isWalkable = false; public bool isWalkable = false;
public Sprite iconSprite; public Sprite iconSprite;
public PlacedObjectType placedObjectType = PlacedObjectType.BULDING;
public List<Vector2Int> GetGridPositionList(Vector2Int offset) public List<Vector2Int> GetGridPositionList(Vector2Int offset)
{ {