private IEnumerator ExplodeAndDie() { if (Linking.Count > 0) { for (int i = 0; i < Linking.Count; i++) { ExplosionManager.SpawnExplosion(Linking[i].Coordinates); yield return(new WaitForSeconds(0.07f)); } SetCurrentVertex(Linking.First()); } else { ExplosionManager.SpawnExplosion(transform.position); yield return(new WaitForSeconds(0.1f)); } if (CurrentLine != null) { Destroy(CurrentLine.gameObject); } CurrentLine = null; Linking.Clear(); _isDying = false; PlayerDied?.Invoke(); }
public void Die() { if (_isDead) { return; } _isDead = true; ExplosionManager.SpawnExplosion(transform.position); Destroy(gameObject); }
private IEnumerator ExplodeMap() { float stopTime = Time.timeSinceLevelLoad + 2.5f; while (Time.timeSinceLevelLoad < stopTime) { ExplosionManager.SpawnExplosion(_cells[Random.Range(0, CellColCount), Random.Range(0, CellRowCount)].Coordinates); yield return(new WaitForSeconds(0.1f)); } LevelNumberManager.GoToNextLevel(); SceneManager.LoadScene("Main"); }
// Create explosions on collision private void OnCollisionEnter(Collision c) { if (m_Exploded) { return; } //Determine the collision's normal, position, and which explosion definition to use based on how many bounces we have left. Vector3 explosionNormal = c.contacts.Length > 0 ? c.contacts[0].normal : Vector3.up; Vector3 explosionPosition = c.contacts.Length > 0 ? c.contacts[0].point : transform.position; ExplosionSettings settings = m_Bounces > 0 ? m_BounceExplosionSettings : m_ExplosionSettings; if (ExplosionManager.s_InstanceExists) { ExplosionManager em = ExplosionManager.s_Instance; if (settings != null) { em.SpawnExplosion(transform.position, explosionNormal, gameObject, m_OwningPlayerId, settings, false); } ExplosionManager.SpawnDebris(explosionPosition, explosionNormal, m_OwningPlayerId, c.collider, m_SpawnedDebris, m_RandSeed); } //If we're bouncing, reflect our movement direction, decay our force, reduce our number of bounces. if (m_Bounces > 0) { m_Bounces--; Vector3 refl = Vector3.Reflect(-c.relativeVelocity, explosionNormal); refl *= m_BounceForceDecay; refl += m_BounceAdditionalForce; // Push us back up m_CachedRigidBody.velocity = refl; // Temporarily ignore collisions with this object if (m_TempIgnoreCollider != null) { Physics.IgnoreCollision(GetComponent <Collider>(), m_TempIgnoreCollider, false); } m_TempIgnoreCollider = c.collider; m_TempIgnoreColliderTime = m_IgnoreColliderFixedFrames; } else { Destroy(gameObject); } m_Exploded = true; }