void ContinuePurchase() { Vector2Int gridPos = SnapUnderCursor(); //Check if the player just removed their finger over a free tile and if they have enough money //Changes the tower material, displays an error message and/or places the tower, depending on the case if (GridManager.TileIsFree(gridPos)) { if (Input.GetMouseButtonUp(0) && IsOnGrid()) { if (GoldManager.CanAfford(tower.type.price)) { EndPurchase(); } else { UIManager.DisplayText(GameManager.Instance.insufficientGoldText); } } else { SetMaterial((GoldManager.CanAfford(tower.type.price)) ? transparent : transparentRed); } } else { SetMaterial(transparentRed); if (Input.GetMouseButtonUp(0)) { GridManager.TryBuildOnTile(gridPos); } } }