public void ShieldCollisionEnter(CollisionInfo e)
 {
     if (e.Hit.get_transform() != null)
     {
         if (this.IsWaterInstance)
         {
             GameObject gameObject = Object.Instantiate <GameObject>(this.ExplosionOnHit);
             Transform  transform  = gameObject.get_transform();
             transform.set_parent(base.get_transform());
             float num = base.get_transform().get_localScale().x *this.ScaleWave;
             transform.set_localScale(new Vector3(num, num, num));
             transform.set_localPosition(new Vector3(0f, 0.001f, 0f));
             transform.LookAt(e.Hit.get_point());
         }
         else
         {
             if (this.EffectOnHit != null)
             {
                 if (!this.CreateMechInstanceOnHit)
                 {
                     Transform  transform2          = e.Hit.get_transform();
                     Renderer   componentInChildren = transform2.GetComponentInChildren <Renderer>();
                     GameObject gameObject2         = Object.Instantiate <GameObject>(this.EffectOnHit);
                     gameObject2.get_transform().set_parent(componentInChildren.get_transform());
                     gameObject2.get_transform().set_localPosition(Vector3.get_zero());
                     AddMaterialOnHit component = gameObject2.GetComponent <AddMaterialOnHit>();
                     component.SetMaterialQueue(this.currentQueue);
                     component.UpdateMaterial(e.Hit);
                 }
                 else
                 {
                     GameObject gameObject3 = Object.Instantiate <GameObject>(this.EffectOnHit);
                     Transform  transform3  = gameObject3.get_transform();
                     transform3.set_parent(base.GetComponent <Renderer>().get_transform());
                     transform3.set_localPosition(Vector3.get_zero());
                     transform3.set_localScale(base.get_transform().get_localScale() * this.ScaleWave);
                     transform3.LookAt(e.Hit.get_point());
                     transform3.Rotate(this.AngleFix);
                     gameObject3.GetComponent <Renderer>().get_material().set_renderQueue(this.currentQueue - 1000);
                 }
             }
             if (this.currentQueue > 4000)
             {
                 this.currentQueue = 3001;
             }
             else
             {
                 this.currentQueue++;
             }
             if (this.ExplosionOnHit != null)
             {
                 GameObject gameObject4 = Object.Instantiate(this.ExplosionOnHit, e.Hit.get_point(), default(Quaternion)) as GameObject;
                 gameObject4.get_transform().set_parent(base.get_transform());
             }
         }
     }
 }
 // Token: 0x0600436D RID: 17261 RVA: 0x001638F0 File Offset: 0x00161CF0
 public void ShieldCollisionEnter(CollisionInfo e)
 {
     if (e.Hit.transform != null)
     {
         if (this.IsWaterInstance)
         {
             GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.ExplosionOnHit);
             Transform  transform  = gameObject.transform;
             transform.parent = base.transform;
             float num = base.transform.localScale.x * this.ScaleWave;
             transform.localScale    = new Vector3(num, num, num);
             transform.localPosition = new Vector3(0f, 0.001f, 0f);
             transform.LookAt(e.Hit.point);
         }
         else
         {
             if (this.EffectOnHit != null)
             {
                 if (!this.CreateMechInstanceOnHit)
                 {
                     Transform  transform2          = e.Hit.transform;
                     Renderer   componentInChildren = transform2.GetComponentInChildren <Renderer>();
                     GameObject gameObject2         = UnityEngine.Object.Instantiate <GameObject>(this.EffectOnHit);
                     gameObject2.transform.parent        = componentInChildren.transform;
                     gameObject2.transform.localPosition = Vector3.zero;
                     AddMaterialOnHit component = gameObject2.GetComponent <AddMaterialOnHit>();
                     component.SetMaterialQueue(this.currentQueue);
                     component.UpdateMaterial(e.Hit);
                 }
                 else
                 {
                     GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(this.EffectOnHit);
                     Transform  transform3  = gameObject3.transform;
                     transform3.parent        = base.GetComponent <Renderer>().transform;
                     transform3.localPosition = Vector3.zero;
                     transform3.localScale    = base.transform.localScale * this.ScaleWave;
                     transform3.LookAt(e.Hit.point);
                     transform3.Rotate(this.AngleFix);
                     gameObject3.GetComponent <Renderer>().material.renderQueue = this.currentQueue - 1000;
                 }
             }
             if (this.currentQueue > 4000)
             {
                 this.currentQueue = 3001;
             }
             else
             {
                 this.currentQueue++;
             }
             if (this.ExplosionOnHit != null)
             {
                 GameObject gameObject4 = UnityEngine.Object.Instantiate <GameObject>(this.ExplosionOnHit, e.Hit.point, default(Quaternion));
                 gameObject4.transform.parent = base.transform;
             }
         }
     }
 }
 public void ShieldCollisionEnter(CollisionInfo e)
 {
     if (!Object.op_Inequality((Object)((RaycastHit) ref e.Hit).get_transform(), (Object)null))
     {
         return;
     }
     if (this.IsWaterInstance)
     {
         Transform transform = ((GameObject)Object.Instantiate <GameObject>((M0)this.ExplosionOnHit)).get_transform();
         transform.set_parent(((Component)this).get_transform());
         float num = (float)((Component)this).get_transform().get_localScale().x *this.ScaleWave;
         transform.set_localScale(new Vector3(num, num, num));
         transform.set_localPosition(new Vector3(0.0f, 1f / 1000f, 0.0f));
         transform.LookAt(((RaycastHit) ref e.Hit).get_point());
     }
     else
     {
         if (Object.op_Inequality((Object)this.EffectOnHit, (Object)null))
         {
             if (!this.CreateMechInstanceOnHit)
             {
                 Renderer   componentInChildren = (Renderer)((Component)((RaycastHit) ref e.Hit).get_transform()).GetComponentInChildren <Renderer>();
                 GameObject gameObject          = (GameObject)Object.Instantiate <GameObject>((M0)this.EffectOnHit);
                 gameObject.get_transform().set_parent(((Component)componentInChildren).get_transform());
                 gameObject.get_transform().set_localPosition(Vector3.get_zero());
                 AddMaterialOnHit component = (AddMaterialOnHit)gameObject.GetComponent <AddMaterialOnHit>();
                 component.SetMaterialQueue(this.currentQueue);
                 component.UpdateMaterial(e.Hit);
             }
             else
             {
                 GameObject gameObject = (GameObject)Object.Instantiate <GameObject>((M0)this.EffectOnHit);
                 Transform  transform  = gameObject.get_transform();
                 transform.set_parent(((Component)((Component)this).GetComponent <Renderer>()).get_transform());
                 transform.set_localPosition(Vector3.get_zero());
                 transform.set_localScale(Vector3.op_Multiply(((Component)this).get_transform().get_localScale(), this.ScaleWave));
                 transform.LookAt(((RaycastHit) ref e.Hit).get_point());
                 transform.Rotate(this.AngleFix);
                 ((Renderer)gameObject.GetComponent <Renderer>()).get_material().set_renderQueue(this.currentQueue - 1000);
             }
         }
         if (this.currentQueue > 4000)
         {
             this.currentQueue = 3001;
         }
         else
         {
             ++this.currentQueue;
         }
         if (!Object.op_Inequality((Object)this.ExplosionOnHit, (Object)null))
         {
             return;
         }
         ((GameObject)Object.Instantiate <GameObject>((M0)this.ExplosionOnHit, ((RaycastHit) ref e.Hit).get_point(), (Quaternion)null)).get_transform().set_parent(((Component)this).get_transform());
     }
 }
Esempio n. 4
0
    private void CollisionEnter()
    {
        if (EffectOnHitObject != null && hit.transform != null)
        {
            var addMat = hit.transform.GetComponentInChildren <AddMaterialOnHit>();
            effectSettingsInstance = null;
            if (addMat != null)
            {
                effectSettingsInstance = addMat.gameObject.GetComponent <EffectSettings>();
                effectSettingsInstance.EffectDeactivated += (sender, e) =>
                {
                    addMat.RemoveNewMaterial();
                };
            }

            if (effectSettingsInstance != null)
            {
                effectSettingsInstance.IsVisible = true;
            }
            else
            {
                var hitGO    = hit.transform;
                var renderer = hitGO.GetComponentInChildren <Renderer>();
                var effect   = ObjectPoolManager.Spawn(EffectOnHitObject) as GameObject;
                effect.transform.parent        = renderer.transform;
                effect.transform.localPosition = Vector3.zero;
                AddMaterialOnHit addMaterialScript = effect.GetComponent <AddMaterialOnHit>();
                addMaterialScript.UpdateMaterial(hit);
                effectSettings.EffectDeactivated += (sender, e) =>
                {
                    addMaterialScript.RemoveNewMaterial();
                };
            }
        }
        effectSettings.OnCollisionHandler(new CollisionInfo {
            Hit = hit
        });
    }