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); }
private void InstantiatePrefab() { SpawnPool level_pool = PoolManager.Pools[CurrentLevel.GetCurrentLevelPoolName()]; Transform unit_entity = level_pool.Spawn(unit, transform.position, transform.rotation); if (!Equals(unit_entity.gameObject.GetComponent <BoltEntity>(), null)) { BoltNetwork.Attach(unit_entity.gameObject); } if (!no_movements) { MoveTo move_to = unit_entity.GetComponent <MoveTo>(); move_to.SetCoordinates(coordinates_list); move_to.move_type = move_type; move_to.movement_speed = movement_speed; move_to.rotation_speed = rotation_speed; move_to.wait_time_between_moves = wait_time_between_moves; move_to.no_rotation = no_rotation; move_to.despawn_animation_time = despawn_animation_time; } if (life_time > 0) { LifeTime life = unit_entity.GetComponent <LifeTime>(); life.life_time = life_time; life.despawn_time = despawn_animation_time; if (!life.automatically_start) { life.StartLifeTime(); } } Transform[] allChildren = unit_entity.GetComponentsInChildren <Transform>(); foreach (Transform child in allChildren) { if (child.GetComponent <ParticleSystem>() != null) { child.GetComponent <ParticleSystem>().Play(); } } if (spawn_animation_time > 0) { foreach (Collider collider in GetComponents <Collider>()) { collider.enabled = false; } StartCoroutine(SpawnAnimation()); } }
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); } }
void OnTriggerEnter(Collider collider) { if (CurrentLevel.LevelInitialized()) { if ((collider.tag == "Snow") || (collider.tag == "Ice") || (collider.tag == "Reverse") || (collider.tag == "Straight")) { SpawnPool pool; if (pool_name == "Current Level") { pool = PoolManager.Pools[CurrentLevel.GetCurrentLevelPoolName()]; } else { pool = PoolManager.Pools[CurrentLevel.GetGeneralPoolName()]; } Quaternion rotation = collider.transform.rotation * Quaternion.Euler(rotation_angle_x, rotation_angle_y, rotation_angle_z); pool.Spawn(effect, transform.position, rotation); } } }
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; } } } } }