public void FixedUpdate() { if (SpawnedBandits.Count == 0) { enabled = false; } mLookerCounter++; if (mLookerCounter > 2) { mLookerCounter = 0; if (SpawnedBandits.Count > 0) { Looker looker = null; if (SharedLooker == null) { CreateSharedLooker(); } if (!SharedLooker.IsInUse) { //if the looker is disabled that means it's done being used mUpdateBanditIndex = SpawnedBandits.NextIndex(mUpdateBanditIndex); if (SpawnedBandits [mUpdateBanditIndex] != null) { looker = SpawnedBandits [mUpdateBanditIndex].worlditem.GetOrAdd <Looker> (); //listener is passive but looker is active //it needs to be told to look for the player //we stagger this because it's an expensive operation looker.LookForStuff(SharedLooker); } } } } }
public void FixedUpdate() { if (Globals.MissionDevelopmentMode) { //we don't care about creatures in mission testing mode return; } if (SpawnedCreatures.Count == 0) { enabled = false; } //TODO look into making this a coroutine mLookerCounter++; if (mLookerCounter > 2) { mLookerCounter = 0; if (SpawnedCreatures.Count > 0) { Looker looker = null; if (SharedLooker == null) { CreateSharedLooker(); } if (!SharedLooker.IsInUse) { //if the looker is disabled that means it's done being used mUpdateCreatureIndex = SpawnedCreatures.NextIndex(mUpdateCreatureIndex); if (SpawnedCreatures[mUpdateCreatureIndex] != null && SpawnedCreatures[mUpdateCreatureIndex].worlditem.Is <Looker>(out looker)) { //listener is passive but looker is active //it needs to be told to look for the player //we stagger this because it's an expensive operation looker.LookForStuff(SharedLooker); } } } } mDenCounter++; if (mDenCounter > 3) { mDenCounter = 0; for (int i = 0; i < SpawnedCreatures.Count; i++) { if (SpawnedCreatures[i] != null) { if (Vector3.Distance(SpawnedCreatures[i].worlditem.tr.position, worlditem.tr.position) > Radius) { SpawnedCreatures[i].IsInDen = false; } else { SpawnedCreatures[i].IsInDen = true; } } } } mPlayerCounter++; if (mPlayerCounter > 4) { //only when script is enabled //only when player is in den if (PlayerIsInDen) { //go through each creature in our list //tell it to look for the player //now check if the player has entered the den inner radius float distanceToDen = Vector3.Distance(Player.Local.Position, worlditem.tr.position); if (mPlayerVisitingDenInnerRadius) { if (distanceToDen > InnerRadius) { //the player has exited the inner radius //tell each creature mPlayerVisitingDenInnerRadius = false; for (int i = SpawnedCreatures.LastIndex(); i >= 0; i--) { if (SpawnedCreatures[i] == null) { SpawnedCreatures.RemoveAt(i); } else { SpawnedCreatures[i].OnPlayerLeaveDenInnerRadius.SafeInvoke(); } } } } else { if (distanceToDen < InnerRadius) { //the player has entered the inner radius //tell each creature mPlayerVisitingDenInnerRadius = true; for (int i = SpawnedCreatures.LastIndex(); i >= 0; i--) { if (SpawnedCreatures[i] == null) { SpawnedCreatures.RemoveAt(i); } else { SpawnedCreatures[i].OnPlayerVisitDenInnerRadius.SafeInvoke(); } } } } } } }
public void FixedUpdate() { //TODO look into making this a coroutine mLookerCounter++; if (mLookerCounter > 2) { mLookerCounter = 0; if (SpawnedCharacters.Count > 0) { Looker looker = null; if (SharedLooker == null) { CreateSharedLooker(); } if (!SharedLooker.IsInUse) { //if the looker is disabled that means it's done being used mUpdateCharacterIndex = SpawnedCharacters.NextIndex(mUpdateCharacterIndex); if (SpawnedCharacters [mUpdateCharacterIndex] != null) { if (SpawnedCharacters [mUpdateCharacterIndex].worlditem.Is <Looker> (out looker)) { //listener is passive but looker is active //it needs to be told to look for the player //we stagger this because it's an expensive operation looker.LookForStuff(SharedLooker); } } else { SpawnedCharacters.RemoveAt(mUpdateCharacterIndex); } } } } if (SpawnedCharacters.Count == 0) { enabled = false; } if (CityAmbience == null) { return; } float distance = Vector3.Distance(Player.Local.Position, worlditem.Position); if (distance < worlditem.ActiveRadius) { //if we're in the city put the ambience right there CityAmbience.transform.position = Player.Local.Position; } else { //otherwise put it at the edge of the active radius CityAmbience.transform.position = Vector3.MoveTowards(worlditem.Position, Player.Local.Position, worlditem.ActiveRadius); } if (Player.Local.Surroundings.IsUnderground) { CityAmbience.volume = Mathf.Lerp(CityAmbience.volume, 0f, 0.1f); } else { float volume = distance / worlditem.ActiveRadius; if (Player.Local.Surroundings.IsInsideStructure) { //cut the city ambience down by half CityAmbience.volume = Mathf.Lerp(CityAmbience.volume, volume * 0.125f, 0.1f); } else { CityAmbience.volume = Mathf.Lerp(CityAmbience.volume, volume, 0.1f); } } }