/// <summary> /// Вернуть в пул использованный объект /// </summary> /// <param name="gameObject"></param> public void ReturnObject(GameObject returnGameObject) { ISpawned returnEnemy = returnGameObject.GetComponent <ISpawned>(); enemies.Add(returnEnemy); returnGameObject.SetActive(false); }
/// <summary> /// Add the entity to the spawned group and add the despawn radius /// </summary> private void ProcessSpawnedEntity(ISpawned entity, Spawner spawnType) { // I don't understand why the same // value is used for spawning and // despawning, but apparently it works // just fine entity.DespawnRadiusSqr = spawnType.SpawnRadiusSqr; entity.SpawnedNode.AddToGroup(Constants.SPAWNED_GROUP); }
public void Create() { if (enemies.Count != 0) { int rand = Random.Range(0, enemies.Count); ISpawned spawned = enemies[rand]; enemies.RemoveAt(rand); spawned.Spawn(); return; } GameObject gameObjectNew = MonoBehaviour.Instantiate(GameController.StaticObject.EnemyFactory.CreateEnemy()); gameObjectNew.transform.SetParent(ParentEnemyPool); gameObjectNew.GetComponent <ISpawned>().Spawn(); }
public IEnumerable <ISpawned> Spawn(Node worldNode, Vector3 location, MicrobeSpecies species, bool isWanderer) { // The true here is that this is AI controlled ISpawned first = Spawn(species, location, worldNode, microbeScene, true, cloudSystem, CurrentGame); yield return(first); if (species.IsBacteria && !isWanderer) { foreach (Microbe microbe in SpawnBacteriaColony(species, location, worldNode, microbeScene, cloudSystem, CurrentGame, random)) { yield return(microbe); } } }
void Start() { _thisEnemy = SpawnerBehaviour.AllSpawned[gameObject]; _dpsMeter = HUDBehaviour.Instance.DpsMeter; if (_thisEnemy is IFighter fighter) { fighter.DagameReceived += damage => _dpsMeter.CurrentFight.AddDamage(damage); } if (_thisEnemy is ISkilled skilled) { foreach (var skill in skilled.Skills) { skill.OnSuccessUsed += Skill_OnSuccessUsed; } } }
// Needs no params constructor for loading saves? /// <summary> /// Adds an externally spawned entity to be despawned /// </summary> public static void AddEntityToTrack(ISpawned entity, float radius = Constants.MICROBE_SPAWN_RADIUS) { entity.DespawnRadiusSqr = (int)(radius * radius); entity.SpawnedNode.AddToGroup(Constants.SPAWNED_GROUP); }
public static void AddSpawned(GameObject gameObject, ISpawned spawned) { _allSpawned.Add(gameObject, spawned); }
/// <summary> /// Add the entity to the spawned group and add the despawn radius /// </summary> private void ProcessSpawnedEntity(ISpawned entity) { entity.DespawnRadius = Constants.DESPAWN_ITEM_RADIUS; entity.SpawnedNode.AddToGroup(Constants.SPAWNED_GROUP); }
/// <summary> /// Sets Despawn radius and adds entity to SPAWNED_GROUP /// </summary> public static void AddEntityToTrack(ISpawned entity) { entity.DespawnRadius = Constants.DESPAWN_ITEM_RADIUS; entity.SpawnedNode.AddToGroup(Constants.SPAWNED_GROUP); }