private void Explode() { Debug.Log("Boom!"); Instantiate(explosionEffect, transform.position, transform.rotation); Collider[] colliders = Physics.OverlapSphere(transform.position, blastRadius); foreach (Collider nearbyObject in colliders) { Rigidbody rb = nearbyObject.GetComponent <Rigidbody>(); if (rb != null) { rb.AddExplosionForce(force, transform.position, blastRadius); } Destructible dest = nearbyObject.GetComponent <Destructible>(); if (dest != null) { dest.Destruct(); } } if (inDanger == true && countdown <= 0) { Event.Invoke(); } Destroy(gameObject); }
private void OnTriggerEnter(Collider other) { Destructible destroyable = (Destructible)other.GetComponent <SlowBall>(); if (destroyable != null) { destroyable.Destruct(); } }
void Health_Check() { if (this.health <= 0d) { Destructible destructible = this.GetComponent <Destructible>(); if (destructible) { destructible.Destruct(); } } }
void Energy_Check() { if (null == this.myEnergizeable ? true : !this.myEnergizeable.hasEnergy) { Destructible destructible = this.GetComponent <Destructible>(); if (destructible) { destructible.Destruct(); } } }
private void OnCollisionEnter2D(Collision2D collision) { Health health = collision.collider.gameObject.GetComponent <Health>(); if (health != null) { health.Damage(damage); Rigidbody2D rb = collision.collider.GetComponent <Rigidbody2D>(); if (rb != null) { Vector2 difference = collision.collider.transform.position - transform.position; rb.AddForceAtPosition(difference.normalized * pushForce, transform.position, ForceMode2D.Impulse); } } destructible.Destruct(); }
// Update is called once per frame void Update() { m_audioSource.pitch = Mathf.Lerp(m_audioSource.pitch, Random.Range(0.85f, 1.15f), 3.0f * Time.deltaTime); if (transform.localScale.x < 0.95f) { Collider[] hitColliders = Physics.OverlapSphere(transform.position, transform.localScale.x + 0.1f, LayerMask.GetMask("Projectile")); for (int i = 0; i < hitColliders.Length; i++) { Destructible destroyable = (Destructible)hitColliders[i].gameObject.GetComponent <SlowBall>(); if (destroyable != null) { if (m_dashRegen) { m_playerController.SetAirDashes(m_playerController.GetAirDashes() + m_dashRegenFactor); } destroyable.Destruct(); } } } }
private void DestructRPC(Vector3 hitPosition, Vector3 hitNormal) { m_Destructible.Destruct(hitPosition, hitNormal); }