void SpawnIssue(IssueType issueType) { TileController[] allTiles = tileManager.m_AllTiles; int iRandomNumber = Random.Range(0, allTiles.Length - 1); int iFailureCount = 0; while (allTiles[iRandomNumber].GetComponent <TileController>().m_bHasIssue) { iRandomNumber = Random.Range(0, allTiles.Length - 1); iFailureCount++; if (iFailureCount > 30) { return; } } allTiles[iRandomNumber].GetComponent <MeshRenderer>().material = m_BlueMaterial; allTiles[iRandomNumber].tag = "BuildingWithIssue"; Vector3 issueSpawnPoint = allTiles[iRandomNumber].transform.position + new Vector3(0.0f, 1.0f, 0.0f); IssueController newIssue = Instantiate(IssuePrefab, issueSpawnPoint, Quaternion.Euler(0.0f, 0.0f, 0.0f), SpawnedIssuesContainer); CurrentIssues.Add(newIssue); newIssue.NegativeObject = NegativePrefab; newIssue.SetEffectsObject(EffectsObject); newIssue.SetTileIndex(iRandomNumber); newIssue.myTile = allTiles[iRandomNumber]; newIssue.IssuesManager = this; newIssue.tileManager = tileManager; newIssue.SetSpeechBubble(UISpeechBubble); newIssue.CitySatisfaction = CitySatisfaction; allTiles[iRandomNumber].GetComponent <TileController>().SetHasIssue(newIssue); newIssue.SetIssueType(issueType); }