public void Cleared() { //remove the spawner from the tracker UnitSpawnerTracker.RemoveSpawner(this); //inform the GameControl that the spawner has been cleared (which would in term check for objective) GameControl.UnitSpawnerCleared(this); }
void Awake() { instance = this; //QualitySettings.vSyncCount=1; //Application.targetFrameRate=60; //get the unit in game player = (UnitPlayer)FindObjectOfType(typeof(UnitPlayer)); //setup the collision rules Physics.IgnoreLayerCollision(TDS.GetLayerShootObject(), TDS.GetLayerShootObject(), !shootObject); Physics.IgnoreLayerCollision(TDS.GetLayerShootObject(), TDS.GetLayerCollectible(), !collectible); Physics.IgnoreLayerCollision(TDS.GetLayerShootObject(), TDS.GetLayerTerrain(), true); Physics.IgnoreLayerCollision(TDS.GetLayerShootObject(), TDS.GetLayerTrigger(), true); //clear all the spawner and tracker sicne it's a new game UnitTracker.Clear(); UnitSpawnerTracker.Clear(); //this is not required, each individual unit and spawner will register itself to the tracker //UnitTracker.ScanForUnit(); //UnitSpawnerTracker.ScanForSpawner(); }
void Start() { InitObjectPool(); //add this spawner to tracker UnitSpawnerTracker.AddSpawner(this); if (overrideHitPoint) { spawnHP = startingHitPoint; } //if spawnUponStart is enabled, start spawning if (spawnUponStart) { StartSpawn(); } }
void Start() { //make sure the none of the element in unitList is null for (int i = 0; i < unitList.Count; i++) { if (unitList[i] == null) { unitList.RemoveAt(i); i -= 1; } } //make sure the none of the element in spawnerList is null for (int i = 0; i < spawnerList.Count; i++) { if (spawnerList[i] == null) { spawnerList.RemoveAt(i); i -= 1; } } //get all unit spawner in current level if (clearAllSpawner) { spawnerList = UnitSpawnerTracker.GetAllSpawnerList(); } for (int i = 0; i < prefabList.Count; i++) { prefabKillCountList.Add(0); } for (int i = 0; i < triggerList.Count; i++) { triggerList[i].SetTriggerCallback(this.Triggered); } //GameControl.SetObjective(this); }
//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); } } }