Stopped accidental building

This commit is contained in:
2026-03-31 16:16:56 +01:00
parent dc68787e9f
commit 0b9f49e5ea
2 changed files with 4 additions and 2 deletions

View File

@@ -1,6 +1,5 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
namespace Fruitomation.Game
{

View File

@@ -32,6 +32,7 @@ namespace Fruitomation.UI
private readonly List<Collider2D> Colliders = new();
private float StartOfMouseClick;
private bool MouseOnGrid;
private void UpdatePosition()
{
@@ -54,6 +55,8 @@ namespace Fruitomation.UI
Math.Clamp(p4.x, 0, 95), // size.x - 1
Math.Clamp(p4.y, 0, 48) // size.y - 1
);
MouseOnGrid = GridPosition == p4;
}
private void Update()
@@ -159,7 +162,7 @@ namespace Fruitomation.UI
BuildingPreview.rectTransform.anchoredPosition = p4;
//
if (Input.GetMouseButtonDown(0))
if (Input.GetMouseButtonDown(0) && MouseOnGrid)
{
BuildingManager.AddBuildingAt(p1, BuildingPrefab);
}