Пример #1
0
    public void CreateExplosion(Vector2 pos, float force, float range, float upwards)
    {
        var targets = GetRigidbodiesInRange(pos, range);

        foreach (Rigidbody2D r in targets)
        {
            Debug.Log(r);

            if (!r.gameObject.Equals(gameObject))
            {
                if (r.gameObject.GetComponent <Explosive>() != null)
                {
                    Debug.Log("Shit should work!");
                    Explosive explode = r.gameObject.GetComponent <Explosive>();
                    if (!explode.isDone() && explode.isActive())
                    {
                        explode.Explode();
                    }
                }
                else
                {
                    r.AddExplosionForce(force, pos, range, upwards);
                }
            }
        }
    }