void SpawnEnemiesIterativeMode() { int counterType = 0; int counterTotal = 0; while (counterTotal != _possibleEnemies.Count) { do { counterType = UnityEngine.Random.Range(0, _possibleEnemies.Count); } while (IsEnemyTypeUsed(counterType)); numEnemyTypes[counterTotal] = counterType; counterTotal++; EnemiesRoom enemy = _possibleEnemies[counterType]; if (_counterPoints == _maximumPoints) { break; } int numOfEnemyType = UnityEngine.Random.Range(0, enemy.maxEnemiesOfType + 1); for (int i = 1; i < numOfEnemyType; i++) { EnemyPos enemyPos = GetPositionToSpawnNotUsed(); if (enemyPos == null && _counterPoints + enemy.mydificultyPoints > _maximumPoints) { break; } GameObject go = Instantiate(enemy.myEnemy); go.transform.position = enemyPos._position; _enemiesInRoom.Add(new EnemiesRoom(enemy.myEnemyType, go, enemy.mydificultyPoints)); _counterPoints += enemy.mydificultyPoints; if (_counterPoints >= _maximumPoints) { break; } } if (_counterPoints >= _maximumPoints) { break; } } while (_enemiesInRoom.Count == 0) { ClearEnemyTypeArray(); SpawnEnemiesIterativeMode(); } _enemiesInRoomCount = _enemiesInRoom.Count; }
void DetectEnemyLives() { Blackboard bb; for (int i = 0; i < _enemiesInRoom.Count; i++) { if (_enemiesInRoom[i] == null) { continue; } EnemiesRoom enemiesRoom = _enemiesInRoom[i]; switch (enemiesRoom.myEnemyType) { case Enemy_type.MEELE_ENEMY: bb = enemiesRoom.myEnemy.GetComponent <Soldier_Blackboard>(); if (bb != null) { if (((Soldier_Blackboard)bb).life.myValue <= 0) { _enemiesInRoom.Remove(enemiesRoom); _enemiesDead++; } } break; case Enemy_type.CARTONACH_ENEMY: bb = enemiesRoom.myEnemy.GetComponent <Caorthannach_Blackboard>(); if (bb != null) { if (((Caorthannach_Blackboard)bb).life.myValue <= 0) { _enemiesInRoom.Remove(enemiesRoom); _enemiesDead++; } } break; case Enemy_type.KELPIE_ENEMY: bb = enemiesRoom.myEnemy.transform.GetChild(0).GetComponent <Kelpi_Blackboard>(); if (bb != null) { if (((Kelpi_Blackboard)bb).life.myValue <= 0) { _enemiesInRoom.Remove(enemiesRoom); _enemiesDead++; } } break; case Enemy_type.MACLIR_ENEMY: bb = enemiesRoom.myEnemy.transform.GetChild(0).GetComponent <MacLir_Blackboard>(); if (bb != null) { if (((MacLir_Blackboard)bb).life.myValue <= 0) { _enemiesInRoom.Remove(enemiesRoom); _enemiesDead++; } } break; case Enemy_type.DEARDUG_ENEMY: bb = enemiesRoom.myEnemy.GetComponent <DearDug_Blackboard>(); if (bb != null) { if (((DearDug_Blackboard)bb).life.myValue <= 0) { _enemiesInRoom.Remove(enemiesRoom); _enemiesDead++; } } break; case Enemy_type.BANSHEE_ENEMY: bb = enemiesRoom.myEnemy.GetComponent <Banshee_Blackboard>(); if (bb != null) { if (((Banshee_Blackboard)bb).life.myValue <= 0) { _enemiesInRoom.Remove(enemiesRoom); _enemiesDead++; } } break; } } }