void GenerateTiles() { int mode = PlayerPrefs.GetInt("Mode"); for (int Y = 0; Y < y; Y++) { for (int X = 0; X < x; X++) { if (mode == 4) { AITile aiTile = Instantiate(aiTilePrefab, transform.position, Quaternion.identity, transform).GetComponent <AITile>(); aiTile.x = X; aiTile.y = Y; aiTiles[X, Y] = aiTile; continue; } GameTile tile = Instantiate(tilePrefab, transform.position, Quaternion.identity, transform).GetComponent <GameTile>(); tile.x = X; tile.y = Y; tiles[X, Y] = tile; } } if (mode == 4) { foreach (AITile tile in aiTiles) { tile.Begin(this); } } else { foreach (GameTile tile in tiles) { tile.Begin(this); } } if (mode == 4) { StartCoroutine(StartAI()); } }