/// <summary> /// Fills up our list of all the smartspawnscripts in the scene. /// Should be called whenever a new SmartSpawn script is added to the scene /// </summary> public void GetSmartSpawnReferences() { //System.Diagnostics.Stopwatch s = new System.Diagnostics.Stopwatch(); //s.Start(); allSpawnScripts.Clear(); allSpawnScripts.AddRange(SmartSpawnScript.FindObjectsOfType(typeof(SmartSpawnScript)) as SmartSpawnScript[]); //s.Stop(); //Debug.LogError("Elapsed time: " + s.Elapsed); }
void HandleOnWaveReset(SmartSpawnScript spawnerWithWaveReset, int waveNumber) { #if UNITY_EDITOR Debug.Log("Heard onWaveReset from " + spawnerWithWaveReset.name + " with wave " + waveNumber); #endif if (waveToPerformInfluenceOn == waveNumber || waveToPerformInfluenceOn == -1) { UpdateCurrentlyInfluencedSpawnScripts(); if (currentlyInfluencedSpawnScripts.ContainsKey(spawnerWithWaveReset)) { PerformInfluenceOnSmartSpawner(spawnerWithWaveReset); } } }
void EditorCheckIfWithinRangeOfAny() { allSpawnScripts = new List <SmartSpawnScript>(); allSpawnScripts.Clear(); allSpawnScripts.AddRange(SmartSpawnScript.FindObjectsOfType(typeof(SmartSpawnScript)) as SmartSpawnScript[]); int count = 0; foreach (SmartSpawnScript s in allSpawnScripts) { if (IsWithinRange(influenceRange, transform.position, s.transform.position) || influenceAllSmartSpawners) { count++; } } Debug.Log("Currently within range of: " + count + " SmartSpawners"); }
void PerformInfluenceOnSmartSpawner(SmartSpawnScript targetSS) { //If the smartspawnscript doesn't allow us to perform influence, then don't try if (targetSS.allowInfluence == false) { return; } //Once we've found the scripts we want to influence, then apply the change switch (currentInfluenceModifier) { case InfluenceModifiers.ADDITIVE: targetSS.InfluenceItemLists(influenceSpawnObject); //Apply spawn time multiplier if (spawnTimeMultiplier != 1f) { targetSS.timer += (spawnTimeMultiplier * targetSS.spawnCountdown); } //Apply wave time multiplier if (waveTimeMultiplier != 1f) { targetSS.waveTimer += (waveTimeMultiplier * targetSS.waveResetTime); } targetSS.waveTimer += waveTimeAddition; //Try spawn if we want to if (attemptSpawnOnInfluence) { targetSS.Spawn(); } //Debug.Log("Influencing spawner: " + targetSS.name); #if UNITY_EDITOR Debug.Log(transform.name + " Performed influence on " + targetSS.transform.name); #endif break; case InfluenceModifiers.OVERRIDE: targetSS.SetItemLists(influenceSpawnObject); //Apply spawn time multiplier if (spawnTimeMultiplier != 1f) { targetSS.timer += (spawnTimeMultiplier * targetSS.spawnCountdown); } targetSS.timer += spawnTimeAddition; //Apply wave time multiplier if (waveTimeMultiplier != 1f) { targetSS.waveTimer += (waveTimeMultiplier * targetSS.waveResetTime); } targetSS.waveTimer += waveTimeAddition; //Try spawn if we want to if (attemptSpawnOnInfluence) { targetSS.Spawn(); } //Debug.Log("Overriding spawner: " + targetSS.name); #if UNITY_EDITOR Debug.Log(transform.name + " Performed influence on " + targetSS.transform.name); #endif break; case InfluenceModifiers.SINGLE_INFLUENCE: //If the key is set to false, we haven't influenced it yet, so perform influence if (currentlyInfluencedSpawnScripts[targetSS] == false) { targetSS.InfluenceItemLists(influenceSpawnObject); currentlyInfluencedSpawnScripts[targetSS] = true; //Apply spawn time multiplier if (spawnTimeMultiplier != 1f) { targetSS.timer += (spawnTimeMultiplier * targetSS.spawnCountdown); } targetSS.timer += spawnTimeAddition; //Apply wave time multiplier if (waveTimeMultiplier != 1f) { targetSS.waveTimer += (waveTimeMultiplier * targetSS.waveResetTime); } targetSS.waveTimer += waveTimeAddition; //Try spawn if we want to if (attemptSpawnOnInfluence) { targetSS.Spawn(); } //Debug.Log("Single Influencing spawner: " + targetSS.name); #if UNITY_EDITOR Debug.Log(transform.name + " Performed influence on " + targetSS.transform.name); #endif } break; default: Debug.LogWarning("Shouldn't have gotten here - no correct influence modifier set"); break; } }
void Start() { smartSpawnScript = GameObject.FindGameObjectWithTag(TagManager.SPAWNER_TAG).GetComponent <SmartSpawn.SmartSpawnScript>(); }