//function call to check all the objective has been completed public void CheckObjectiveComplete() { bool cleared = true; //objective status set to true by default, it will be set to false if any of the objective condition is not full-filled //cleared flag will then be use when calling GameControl.GameOver, indicate if player win/lose the level //if require to wait for timer but time is not up yet, dont proceed if (waitForTimer && !GameControl.TimesUp()) { return; } //if scoring criteria not full filled, set cleared to false if (enableScoring && !scored) { cleared = false; } if (colPrefabList.Count > 0) { for (int i = 0; i < colPrefabList.Count; i++) { if (colPrefabCountList[i] > colPrefabCollectedCountList[i]) { cleared = false; break; } } } //if(clearAllCol){ //if clear all collectible is required and not all collectible is collected, set clear to false // if(GetAllCollectibleCount>0) cleared=false; //} if (collectibleList.Count > 0) { cleared = false; //if not all require collectible required has been collectible } //if either of the prefab kill count is not adequate, set cleared to false if (prefabList.Count > 0) { for (int i = 0; i < prefabList.Count; i++) { if (prefabCountList[i] > prefabKillCountList[i]) { cleared = false; break; } } } if (clearAllHostile) //if clear all hostile is required and not all unit is destroyed, set clear to false { if (UnitTracker.GetUnitCount() > 0) { cleared = false; } } else //if not all the target unit has been destroyed, set clear to false { if (unitList.Count > 0) { cleared = false; } } if (clearAllSpawner) //if clear all spawner is required and not all spawner is cleared/destroyed, set clear to false { if (UnitSpawnerTracker.GetSpawnerCount() > 0) { cleared = false; } } else //if not all the spawner has been cleared/destroyed, set clear to false { if (spawnerList.Count > 0) { cleared = false; } } //if time is up, consider game is complete and call GameOver if (GameControl.TimesUp()) { isComplete = true; GameControl.GameOver(cleared); } //else if we dont need to wait for timer and the objective is cleared, call GameOver else if (!waitForTimer) { if (cleared) { isComplete = true; GameControl.GameOver(cleared); } } }