private void CheckNumberOfTransportationHacks() { if (transportationNodeCount == 0) { Debug.Log("None spawned"); return; } else if (transportationNodeCount > 1) { Debug.Log("Many spawned"); return; } else { Debug.Log("One spawned"); MapSquare[] squares = FindObjectsOfType <MapSquare>(); List <MapSquare> potentialSpawns = new List <MapSquare>(); foreach (MapSquare square in squares) { if (square.IsActive() && !square.DoesSquareHaveTransportationNode()) { potentialSpawns.Add(square); } } Debug.Log("Found " + potentialSpawns.Count + " squares without transportation"); MapSquare squareToSpawnTransportation = potentialSpawns[Random.Range(0, potentialSpawns.Count)]; squareToSpawnTransportation.SpawnTransportationNode(); } }