// Use this for initialization void Start() { spawnerTransform = gameObject.transform; obstacleTimer = 0; despawnerScr = Despawner.GetComponent <Despawner>(); //partTimer = 0; }
public IEnumerator RespawnObject() { yield return(new WaitForSeconds(respawnTime)); currentObject = Instantiate(objectPrefab, transform.position, transform.rotation); despawner = currentObject.GetComponent <Despawner>(); despawner.SetSpawner(this); }
// Use this for initialization void Start() { rb = gameObject.GetComponent <Rigidbody2D>(); userTransform = gameObject.transform; cameraTransform = cameraMain.transform; birdParticle = hitParticleSys.GetComponent <ParticleSystem>(); anim = GetComponent <Animator>(); despawnScr = despawner.GetComponent <Despawner>(); }
public void Init(int channelId, List <Note> data, Spawner spawner, Despawner despawner, System.Action onMiss) { this.data = data; this.SpawnNote = spawner; this.DespawnNote = despawner; this.onMiss = onMiss; this.cid = channelId; transform.localScale = Vector3.one; gameObject.SetActive(true); }
// Use this for initialization void Start() { end = GameObject.FindGameObjectWithTag("SwordfishDespawn").GetComponent <Despawner>(); Spawn = GameObject.FindGameObjectWithTag("FishSpawn").GetComponent <SwordFishSpawner>(); transform.position = new Vector3(transform.position.x, Random.Range(-4f, 4f), 0); camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PlatformGenerator>(); Ispawn = true; start = false; track = true; indicatorSound = true; swooshSound = true; }
IEnumerator DespawnAnimation() { yield return(new WaitForSeconds(despawn_animation_time)); foreach (Collider collider in GetComponents <Collider>()) { collider.enabled = true; } SpawnPool pool = PoolManager.Pools[CurrentLevel.GetCurrentLevelPoolName()]; Despawner.Despawn(pool, gameObject); }
/* Displays respawn timer and respawns the player at its completion. */ protected IEnumerator RespawnPlayer(Actor player) { List <Item> items = player.DiscardAllItems(); if (player.droppedLoot != null) { items.AddRange(player.droppedLoot); } foreach (Item item in items) { if (item != null && item.gameObject != null) { Despawner d = item.gameObject.AddComponent(typeof(Despawner)) as Despawner; d.Despawn(60f); } } HUDMenu playerHUD = null; if (player.playerNumber > 0 && player.playerNumber < 5) { MenuManager playerMenu = player.menu; playerMenu.Change("HUD"); if (playerMenu) { playerHUD = (HUDMenu)playerMenu.active; } } if (respawns) { yield return(RespawnTimer(player, playerHUD)); Data dat = player.GetData(); int id = player.id; Destroy(player.gameObject); if (time > 0) { SpawnPlayer(dat.prefabName, id, player.stats.faction); } } else { if (playerHUD != null) { playerHUD.message = "You are dead."; } players.Remove(player); player.SetMenuOpen(true); } yield return(new WaitForSeconds(0f)); }
IEnumerator Despawn() { yield return(new WaitForSeconds(life_time)); if (pool_name == "Current Level") { if (despawn_time > 0) { foreach (Collider collider in GetComponents <Collider>()) { collider.enabled = false; } Transform[] allChildren = GetComponentsInChildren <Transform>(); foreach (Transform child in allChildren) { if (child.GetComponent <ParticleSystem>() != null) { child.GetComponent <ParticleSystem>().Stop(); } } yield return(new WaitForSeconds(despawn_time)); foreach (Collider collider in GetComponents <Collider>()) { collider.enabled = true; } SpawnPool pool = PoolManager.Pools[CurrentLevel.GetCurrentLevelPoolName()]; Despawner.Despawn(pool, gameObject); } else { SpawnPool pool = PoolManager.Pools[CurrentLevel.GetCurrentLevelPoolName()]; Despawner.Despawn(pool, gameObject); if (explosion != null) { pool.Spawn(explosion, transform.position, transform.rotation); } } } else { SpawnPool pool = PoolManager.Pools[pool_name]; Despawner.Despawn(pool, gameObject); } }
// Use this for initialization void Start() { camera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <PlatformGenerator>(); end = GameObject.FindGameObjectWithTag("Despawn").GetComponent <Despawner>(); Spawn = GameObject.FindGameObjectWithTag("BirdSpawner").GetComponent <BirdSpawner>(); //transform.position = new Vector3(transform.position.x - Random.Range(0, 4), transform.position.y, 0); location = Random.Range(0.0f, 7.0f); mid = false; updatedPosition = new Vector2(transform.position.x - 2, Random.Range(0.0f, -2.6f)); Ispawn = true; start = false; track = true; indicatorSound = true; diveSound = true; }
private void OnTriggerEnter2D(Collider2D hitInfo) { explosionSound.Play(); PlayerManager PlayerManager = hitInfo.GetComponent <PlayerManager>(); if (PlayerManager != null) { PlayerManager.TakeDamage(damage); Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation); Destroy(gameObject); } Despawner Despawner = hitInfo.GetComponent <Despawner>(); if (Despawner != null) { // Despawner.TakeDamage(damage); Instantiate(explosion, gameObject.transform.position, gameObject.transform.rotation); Destroy(gameObject); } }
void Start() { currentObject = Instantiate(objectPrefab, transform.position, transform.rotation); despawner = currentObject.GetComponent <Despawner>(); despawner.SetSpawner(this); }
public virtual T UnpoolItem <T>() where T : Component { T item = null; List <GameObject> available = null; // Make logic checks simpler in the future. if (prefab == null) { prefab = new List <GameObject>(); } if (pooled == null) { pooled = new List <GameObject>(); } // Here we filter our prefab list to contain only items of type T.. List <GameObject> filteredPrefabs = prefab.FindAll(d => d.GetComponent <T>() != null); // ..and get a random sample from the filtered list. GameObject chosenPrefab = filteredPrefabs.Count <= 0 ? null : filteredPrefabs[Random.Range(0, filteredPrefabs.Count)]; // If we are manitaining the prefab distribution, we need to grab // only the pooled items that match our random sample. if (maintainPrefabDistribution) { available = pooled.FindAll((d) => { return(d.tag == chosenPrefab.tag && d.GetComponent <T>() != null); }); } // Otherwise, we'll just grab all of the pooled items with matching componenets. else { available = pooled.FindAll(d => d.GetComponent <T>() != null); } // If there are any pooled items available, // we'll grab one and remove it from the pool. if (available.Count > 0) { var obj = available[Random.Range(0, available.Count)]; if (obj != null) { item = obj.GetComponent <T>(); pooled.Remove(obj); } } // If up to this point, we have no item, we'll need to instantiate one. if (item == null && chosenPrefab != null) { item = Instantiate(chosenPrefab).GetComponent <T>(); item.transform.SetParent(transform); } if (item == null) { Debug.LogWarning( string.Format( "GenericGameObjectPool => No prefab containing a component of type \"{0}\".", (typeof(T)).FullName ), this ); return(null); } if (active == null) { active = new List <GameObject>(1); } active.Add(item.gameObject); if (updateDespawner) { Despawner _d = item.GetComponent <Despawner>(); if (_d) { _d.pool = this; } } if (activateItems) { item.gameObject.SetActive(true); } if (setAsLast) { item.transform.SetAsLastSibling(); } return(item); }
// Use this for initialization void Start() { roostMenu.enabled = false; despawnScr = despawner.GetComponent <Despawner>(); }
private void NextMovePoint() { if (move_point_index < coordinates_list.Count - 1) { move_point_index++; if ((trigger_on_collision) && (move_point_index == coordinates_list.Count - 1) && (move_type == MoveType.continuous)) { starting_wait_time = end_wait_time; } if ((trigger_on_collision) && (move_type == MoveType.teleport)) { reached_coordinates_list.Add(coordinates_list[move_point_index - 1]); } } else { if (move_type == MoveType.stop) { if (despawn_animation_time > 0) { foreach (Collider collider in GetComponents <Collider>()) { collider.enabled = false; } Transform[] allChildren = GetComponentsInChildren <Transform>(); foreach (Transform child in allChildren) { if (child.GetComponent <ParticleSystem>() != null) { child.GetComponent <ParticleSystem>().Stop(); } } StartCoroutine(DespawnAnimation()); } else { SpawnPool pool = PoolManager.Pools[CurrentLevel.GetCurrentLevelPoolName()]; Despawner.Despawn(pool, gameObject); } } else if (move_type == MoveType.continuous) { move_point_index = 0; if (trigger_on_collision) { starting_wait_time = time_elapsed; if (stop_after_chain_of_commands) { triggered = false; stop_after_chain_of_commands = false; } } } else if (move_type == MoveType.patrol) { coordinates_list.Reverse(); move_point_index = 1; if (trigger_on_collision) { if (patrol_coming_back) { starting_wait_time = time_elapsed; patrol_coming_back = false; if (stop_after_chain_of_commands) { triggered = false; stop_after_chain_of_commands = false; } } else { starting_wait_time = end_wait_time; patrol_coming_back = true; } } } if (move_type == MoveType.teleport) { if (!trigger_on_collision) { transform.position = coordinates_list[0]; move_point_index = 1; } else if (teleport_is_moving_back) { coordinates_list = new List <Vector3>(coordinates_list_backup); reached_coordinates_list.Clear(); teleport_is_moving_back = false; move_point_index = 0; starting_wait_time = time_elapsed; if (stop_after_chain_of_commands) { triggered = false; stop_after_chain_of_commands = false; } } } } }
void Start() { despawner = GetComponent <Despawner>(); }