public void DestroyObject(Vector3 force)
    {
        if (!m_completeObject.activeSelf)
        {
            return;
        }

        GetComponent <Collider>().enabled = false;
        m_completeObject.SetActive(false);
        m_destrucedObject.SetActive(true);
        GetComponent <NoiseSource>().Play();

        var dTransform = m_destrucedObject.transform;

        for (int i = 0; i < dTransform.childCount; ++i)
        {
            var rb = dTransform.GetChild(i).GetComponent <Rigidbody>();
            //rb.AddForce(force);
            rb.AddExplosionForce(100.0f, transform.position, 3.0f);
        }

        if (OnDestruction != null)
        {
            OnDestruction.Invoke(new DestructionEventData(this.gameObject));
        }
    }
Exemple #2
0
    private void OnDestroy()
    {
        if (OnDestruction != null)
        {
            OnDestruction.Invoke(EntityDestructionContext.DESTROYED_BY_OTHER);
        }

        Destruct();
    }
Exemple #3
0
    protected virtual void DestructionByDamage()
    {
        if (OnDestruction != null)
        {
            OnDestruction.Invoke(EntityDestructionContext.DESTROYED_BY_DAMAGE);
        }

        Destruct();
    }
Exemple #4
0
    protected virtual void SelfDestruction()
    {
        if (OnDestruction != null)
        {
            OnDestruction.Invoke(EntityDestructionContext.SELF_DESTROYED);
        }

        Destruct();
    }
Exemple #5
0
 private void Destroy()
 {
     StopAllCoroutines();
     OnDestruction?.Invoke(gameObject);
 }
Exemple #6
0
 private void WarnsAdvice()
 {
     StopAllCoroutines();
     OnDestruction?.Invoke(gameObject);
 }