Пример #1
0
    // Update is called once per frame
    //void FixedUpdate ()
    //   {
    //       if(RL_Bullet == enabled)
    //       {
    //           Invoke("Explosion", 1);
    //       }
    //}

    public void Explosion()
    {
        Vector3 explosionPosition = RL_Bullet.transform.position;

        Collider[] colliders = Physics.OverlapSphere(explosionPosition, radius);
        foreach (Collider hit in colliders)
        {
            Rigidbody   rigidbody = hit.GetComponent <Rigidbody>();
            ILiveEntity target    = rigidbody.gameObject.GetComponent <ILiveEntity>();

            if (rigidbody != null)
            {
                rigidbody.AddExplosionForce(power, explosionPosition, radius, upforce, ForceMode.Impulse);
            }

            if (target != null && !hit.GetComponent <Rigidbody>())
            {
                rigidbody.gameObject.GetComponent <NavMeshAgent>().enabled  = false;
                rigidbody.gameObject.GetComponent <Rigidbody>().isKinematic = false;
                target.TakeDamage(GlobalDamage.g_RocketAOEDamage, GlobalDamage.DamageTypes.DAMAGE_AOE_ROCKET_DAMAGE);
                this.gameObject.SetActive(false);
            }

            if (rigidbody.gameObject.tag == "Player")
            {
                Physics.IgnoreCollision(rigidbody.GetComponent <Collider>(), this.gameObject.GetComponent <Collider>());
            }
        }
    }
Пример #2
0
    void OnCollisionEnter(Collision _other)
    {
        ILiveEntity target = _other.gameObject.GetComponent <ILiveEntity> ();

        if (target != null)
        {
            target.TakeDamage(GlobalDamage.g_HMGDamage, GlobalDamage.DamageTypes.DAMAGE_BALLISTIC_SMALL);
            this.gameObject.SetActive(false);
        }

        if (_other.gameObject.tag == "Player")
        {
            Physics.IgnoreCollision(_other.collider, this.gameObject.GetComponent <Collider>());
        }
    }
Пример #3
0
    void OnCollisionEnter(Collision col)
    {
        ILiveEntity target = col.gameObject.GetComponent <ILiveEntity>();

        if (target != null)
        {
            target.TakeDamage(GlobalDamage.g_RocketDirectDamage, GlobalDamage.DamageTypes.DAMAGE_ROCKET);
            //this.gameObject.SetActive(false);
        }

        if (col.gameObject.tag == "Player")
        {
            Physics.IgnoreCollision(col.collider, this.gameObject.GetComponent <Collider>());
        }

        //TODO: fix rocket detonating on flamethrowers
        ObjectPooler.Instance.SpawnFromPool("RL_Explosion", transform.position, gameObject.transform.rotation);
        var explosionScript = this.gameObject.GetComponent <RL_Explosion>();

        explosionScript.Explosion();
        this.gameObject.SetActive(false);
    }