public bool IsPathBlocked(List <Tile> tiles) { if (pathEnemy == null) { pathEnemy = pathEnemyObj.GetComponentInChildren <_Enemy>(); pathEnemy.Init(pC, null, null); } foreach (var t in tiles) { t.ToggleTempBlocking(true); } var x = QPath.QPath.FindPath <Tile>(pC, pathEnemy, spawnTiles1[0], targetTiles1[0]); var y = QPath.QPath.FindPath <Tile>(pC, pathEnemy, spawnTiles2[0], targetTiles2[0]); foreach (var t in tiles) { t.ToggleTempBlocking(false); } if (x.Length == 0 || y.Length == 0) { Debug.Log("Path blocked"); return(false); } return(true); }
private void SpawnEnemy(GameObject prefabToRender) { Tile spawnTile = pC.tileController.GetSpawnTile(WaveNumber); Tile targetTile = pC.tileController.GetTargetTile(WaveNumber); GameObject enemyObj = Instantiate( pC.prefabController.EnemyNormalPrefab, new Vector3(spawnTile.X, spawnTile.Y, 0), Quaternion.identity, pC.EnemyAnchorObj.transform ); _Enemy enemy = enemyObj.GetComponentInChildren <_Enemy>(); EnemiesList.Add(enemy); enemyToGoMap[enemy] = enemyObj; enemy.Init(pC, spawnTile, targetTile); }