/// <summary> /// Call this method to despawn a prefab using Pool Boss. All the Spawners and Killable use this method. /// </summary> /// <param name="transToDespawn">Transform to despawn</param> public static void Despawn(Transform transToDespawn) { if (!_isReady) { LevelSettings.LogIfNew(NotInitError); return; } // ReSharper disable once ConditionIsAlwaysTrueOrFalse // ReSharper disable HeuristicUnreachableCode if (transToDespawn == null) { LevelSettings.LogIfNew("No Transform passed to Despawn method."); return; } // ReSharper restore HeuristicUnreachableCode if (Instance == null) { // Scene changing, do nothing. return; } if (!SpawnUtility.IsActive(transToDespawn.gameObject)) { return; // already sent to despawn } var itemName = GetPrefabName(transToDespawn); if (!PoolItemsByName.ContainsKey(itemName)) { if (Instance.autoAddMissingPoolItems) { CreateMissingPoolItem(transToDespawn, itemName, false); } else { LevelSettings.LogIfNew("The Transform '" + itemName + "' passed to Despawn is not in Pool Boss. Not despawning."); return; } } transToDespawn.BroadcastMessage(DespawnedMessageName, SendMessageOptions.DontRequireReceiver); var cloneList = PoolItemsByName[itemName]; SetParent(transToDespawn, Trans); SpawnUtility.SetActive(transToDespawn.gameObject, false); Instance._changes++; if (Instance.logMessages || cloneList.LogMessages) { Debug.Log("Pool Boss despawned '" + itemName + "' at " + Time.time); } cloneList.SpawnedClones.Remove(transToDespawn); cloneList.DespawnedClones.Add(transToDespawn); }
public virtual void UpdateValue(int newValue) { _variableValue = newValue; var valFormatted = string.Format("{0}{1}", displayVariableName ? variableName + ": " : "", _variableValue.ToString("N0")); if (!useCommaFormatting) { valFormatted = valFormatted.Replace(",", ""); } if (_text == null || !SpawnUtility.IsActive(_text.gameObject)) { return; } _text.text = valFormatted; }
// ReSharper disable once UnusedMember.Local void FixedUpdate() { if (_isDisabled) { return; } if (_player == null || !SpawnUtility.IsActive(_player.gameObject)) { if (!_nextSpawnTime.HasValue) { _nextSpawnTime = Time.time + RespawnDelay; } else if (Time.time >= _nextSpawnTime.Value && !LevelSettings.IsGameOver) { SpawnPlayer(); _nextSpawnTime = null; } } else if (followPlayer) { UpdateSpawnPosition(_player.position); } }