Exemplo n.º 1
0
 private void CollisionEnter()
 {
     if (this.EffectOnHitObject != null && this.hit.get_transform() != null)
     {
         Transform  transform           = this.hit.get_transform();
         Renderer   componentInChildren = transform.GetComponentInChildren <Renderer>();
         GameObject gameObject          = Object.Instantiate <GameObject>(this.EffectOnHitObject);
         gameObject.get_transform().set_parent(componentInChildren.get_transform());
         gameObject.get_transform().set_localPosition(Vector3.get_zero());
         gameObject.GetComponent <AddMaterialOnHit>().UpdateMaterial(this.hit);
     }
     if (this.AttachAfterCollision)
     {
         this.tRoot.set_parent(this.hit.get_transform());
     }
     if (this.SendCollisionMessage)
     {
         CollisionInfo e = new CollisionInfo
         {
             Hit = this.hit
         };
         this.effectSettings.OnCollisionHandler(e);
         if (this.hit.get_transform() != null)
         {
             ShieldCollisionBehaviour component = this.hit.get_transform().GetComponent <ShieldCollisionBehaviour>();
             if (component != null)
             {
                 component.ShieldCollisionEnter(e);
             }
         }
     }
     this.onCollision = true;
 }
 private void CollisionEnter()
 {
     if (Object.op_Inequality((Object)this.EffectOnHitObject, (Object)null) && Object.op_Inequality((Object)((RaycastHit) ref this.hit).get_transform(), (Object)null))
     {
         Renderer   componentInChildren = (Renderer)((Component)((RaycastHit) ref this.hit).get_transform()).GetComponentInChildren <Renderer>();
         GameObject gameObject          = (GameObject)Object.Instantiate <GameObject>((M0)this.EffectOnHitObject);
         gameObject.get_transform().set_parent(((Component)componentInChildren).get_transform());
         gameObject.get_transform().set_localPosition(Vector3.get_zero());
         ((AddMaterialOnHit)gameObject.GetComponent <AddMaterialOnHit>()).UpdateMaterial(this.hit);
     }
     if (this.AttachAfterCollision)
     {
         this.tRoot.set_parent(((RaycastHit) ref this.hit).get_transform());
     }
     if (this.SendCollisionMessage)
     {
         CollisionInfo e = new CollisionInfo()
         {
             Hit = this.hit
         };
         this.effectSettings.OnCollisionHandler(e);
         if (Object.op_Inequality((Object)((RaycastHit) ref this.hit).get_transform(), (Object)null))
         {
             ShieldCollisionBehaviour component = (ShieldCollisionBehaviour)((Component)((RaycastHit) ref this.hit).get_transform()).GetComponent <ShieldCollisionBehaviour>();
             if (Object.op_Inequality((Object)component, (Object)null))
             {
                 component.ShieldCollisionEnter(e);
             }
         }
     }
     this.onCollision = true;
 }
    private void InitializeDefault()
    {
        base.GetComponent <Renderer>().get_material().SetFloat(ShaderPIDManager._Chanel, (float)this.currentShaderIndex);
        this.currentShaderIndex++;
        if (this.currentShaderIndex == 3)
        {
            this.currentShaderIndex = 0;
        }
        this.line.SetPosition(0, this.tRoot.get_position());
        if (this.IsVertical)
        {
            if (Physics.Raycast(this.tRoot.get_position(), Vector3.get_down(), ref this.hit))
            {
                this.line.SetPosition(1, this.hit.get_point());
                if (this.StartGlow != null)
                {
                    this.StartGlow.get_transform().set_position(this.tRoot.get_position());
                }
                if (this.HitGlow != null)
                {
                    this.HitGlow.get_transform().set_position(this.hit.get_point());
                }
                if (this.GoLight != null)
                {
                    this.GoLight.get_transform().set_position(this.hit.get_point() + new Vector3(0f, this.LightHeightOffset, 0f));
                }
                if (this.Particles != null)
                {
                    this.Particles.get_transform().set_position(this.hit.get_point() + new Vector3(0f, this.ParticlesHeightOffset, 0f));
                }
                if (this.Explosion != null)
                {
                    this.Explosion.get_transform().set_position(this.hit.get_point() + new Vector3(0f, this.ParticlesHeightOffset, 0f));
                }
            }
        }
        else
        {
            this.tTarget = this.effectSettings.Target.get_transform();
            Vector3 normalized = (this.tTarget.get_position() - this.tRoot.get_position()).get_normalized();
            Vector3 vector     = this.tRoot.get_position() + normalized * this.effectSettings.MoveDistance;
            if (Physics.Raycast(this.tRoot.get_position(), normalized, ref this.hit, this.effectSettings.MoveDistance + 1f, this.effectSettings.LayerMask))
            {
                vector = (this.tRoot.get_position() + Vector3.Normalize(this.hit.get_point() - this.tRoot.get_position()) * (this.effectSettings.MoveDistance + 1f)).get_normalized();
            }
            this.line.SetPosition(1, this.hit.get_point() - this.effectSettings.ColliderRadius * vector);
            Vector3 position = this.hit.get_point() - vector * this.ParticlesHeightOffset;
            if (this.StartGlow != null)
            {
                this.StartGlow.get_transform().set_position(this.tRoot.get_position());
            }
            if (this.HitGlow != null)
            {
                this.HitGlow.get_transform().set_position(position);
            }
            if (this.GoLight != null)
            {
                this.GoLight.get_transform().set_position(this.hit.get_point() - vector * this.LightHeightOffset);
            }
            if (this.Particles != null)
            {
                this.Particles.get_transform().set_position(position);
            }
            if (this.Explosion != null)
            {
                this.Explosion.get_transform().set_position(position);
            }
        }
        CollisionInfo e = new CollisionInfo
        {
            Hit = this.hit
        };

        this.effectSettings.OnCollisionHandler(e);
        if (this.hit.get_transform() != null)
        {
            ShieldCollisionBehaviour component = this.hit.get_transform().GetComponent <ShieldCollisionBehaviour>();
            if (component != null)
            {
                component.ShieldCollisionEnter(e);
            }
        }
    }
Exemplo n.º 4
0
    private void InitializeDefault()
    {
        ((Renderer)((Component)this).GetComponent <Renderer>()).get_material().SetFloat("_Chanel", (float)this.currentShaderIndex);
        ++this.currentShaderIndex;
        if (this.currentShaderIndex == 3)
        {
            this.currentShaderIndex = 0;
        }
        this.line.SetPosition(0, this.tRoot.get_position());
        if (this.IsVertical)
        {
            if (Physics.Raycast(this.tRoot.get_position(), Vector3.get_down(), ref this.hit))
            {
                this.line.SetPosition(1, ((RaycastHit) ref this.hit).get_point());
                if (Object.op_Inequality((Object)this.StartGlow, (Object)null))
                {
                    this.StartGlow.get_transform().set_position(this.tRoot.get_position());
                }
                if (Object.op_Inequality((Object)this.HitGlow, (Object)null))
                {
                    this.HitGlow.get_transform().set_position(((RaycastHit) ref this.hit).get_point());
                }
                if (Object.op_Inequality((Object)this.GoLight, (Object)null))
                {
                    this.GoLight.get_transform().set_position(Vector3.op_Addition(((RaycastHit) ref this.hit).get_point(), new Vector3(0.0f, this.LightHeightOffset, 0.0f)));
                }
                if (Object.op_Inequality((Object)this.Particles, (Object)null))
                {
                    this.Particles.get_transform().set_position(Vector3.op_Addition(((RaycastHit) ref this.hit).get_point(), new Vector3(0.0f, this.ParticlesHeightOffset, 0.0f)));
                }
                if (Object.op_Inequality((Object)this.Explosion, (Object)null))
                {
                    this.Explosion.get_transform().set_position(Vector3.op_Addition(((RaycastHit) ref this.hit).get_point(), new Vector3(0.0f, this.ParticlesHeightOffset, 0.0f)));
                }
            }
        }
        else
        {
            if (Object.op_Inequality((Object)this.effectSettings.Target, (Object)null))
            {
                this.tTarget = this.effectSettings.Target.get_transform();
            }
            else if (!this.effectSettings.UseMoveVector)
            {
                Debug.Log((object)"You must setup the the target or the motion vector");
            }
            Vector3 vector3_1;
            if (!this.effectSettings.UseMoveVector)
            {
                Vector3 vector3_2 = Vector3.op_Subtraction(this.tTarget.get_position(), this.tRoot.get_position());
                vector3_1 = ((Vector3) ref vector3_2).get_normalized();
            }
            else
            {
                vector3_1 = Vector3.op_Addition(this.tRoot.get_position(), Vector3.op_Multiply(this.effectSettings.MoveVector, this.effectSettings.MoveDistance));
            }
            Vector3 vector3_3 = Vector3.op_Addition(this.tRoot.get_position(), Vector3.op_Multiply(vector3_1, this.effectSettings.MoveDistance));
            if (Physics.Raycast(this.tRoot.get_position(), vector3_1, ref this.hit, this.effectSettings.MoveDistance + 1f, LayerMask.op_Implicit(this.effectSettings.LayerMask)))
            {
                Vector3 vector3_2 = Vector3.op_Addition(this.tRoot.get_position(), Vector3.op_Multiply(Vector3.Normalize(Vector3.op_Subtraction(((RaycastHit) ref this.hit).get_point(), this.tRoot.get_position())), this.effectSettings.MoveDistance + 1f));
                vector3_3 = ((Vector3) ref vector3_2).get_normalized();
            }
            this.line.SetPosition(1, Vector3.op_Subtraction(((RaycastHit) ref this.hit).get_point(), Vector3.op_Multiply(this.effectSettings.ColliderRadius, vector3_3)));
            Vector3 vector3_4 = Vector3.op_Subtraction(((RaycastHit) ref this.hit).get_point(), Vector3.op_Multiply(vector3_3, this.ParticlesHeightOffset));
            if (Object.op_Inequality((Object)this.StartGlow, (Object)null))
            {
                this.StartGlow.get_transform().set_position(this.tRoot.get_position());
            }
            if (Object.op_Inequality((Object)this.HitGlow, (Object)null))
            {
                this.HitGlow.get_transform().set_position(vector3_4);
            }
            if (Object.op_Inequality((Object)this.GoLight, (Object)null))
            {
                this.GoLight.get_transform().set_position(Vector3.op_Subtraction(((RaycastHit) ref this.hit).get_point(), Vector3.op_Multiply(vector3_3, this.LightHeightOffset)));
            }
            if (Object.op_Inequality((Object)this.Particles, (Object)null))
            {
                this.Particles.get_transform().set_position(vector3_4);
            }
            if (Object.op_Inequality((Object)this.Explosion, (Object)null))
            {
                this.Explosion.get_transform().set_position(vector3_4);
                this.Explosion.get_transform().LookAt(Vector3.op_Addition(vector3_4, ((RaycastHit) ref this.hit).get_normal()));
            }
        }
        CollisionInfo e = new CollisionInfo()
        {
            Hit = this.hit
        };

        this.effectSettings.OnCollisionHandler(e);
        if (!Object.op_Inequality((Object)((RaycastHit) ref this.hit).get_transform(), (Object)null))
        {
            return;
        }
        ShieldCollisionBehaviour component = (ShieldCollisionBehaviour)((Component)((RaycastHit) ref this.hit).get_transform()).GetComponent <ShieldCollisionBehaviour>();

        if (!Object.op_Inequality((Object)component, (Object)null))
        {
            return;
        }
        component.ShieldCollisionEnter(e);
    }
Exemplo n.º 5
0
    // Token: 0x06004378 RID: 17272 RVA: 0x00163FA4 File Offset: 0x001623A4
    private void InitializeDefault()
    {
        base.GetComponent <Renderer>().material.SetFloat("_Chanel", (float)this.currentShaderIndex);
        this.currentShaderIndex++;
        if (this.currentShaderIndex == 3)
        {
            this.currentShaderIndex = 0;
        }
        this.line.SetPosition(0, this.tRoot.position);
        if (this.IsVertical)
        {
            if (Physics.Raycast(this.tRoot.position, Vector3.down, out this.hit))
            {
                this.line.SetPosition(1, this.hit.point);
                if (this.StartGlow != null)
                {
                    this.StartGlow.transform.position = this.tRoot.position;
                }
                if (this.HitGlow != null)
                {
                    this.HitGlow.transform.position = this.hit.point;
                }
                if (this.GoLight != null)
                {
                    this.GoLight.transform.position = this.hit.point + new Vector3(0f, this.LightHeightOffset, 0f);
                }
                if (this.Particles != null)
                {
                    this.Particles.transform.position = this.hit.point + new Vector3(0f, this.ParticlesHeightOffset, 0f);
                }
                if (this.Explosion != null)
                {
                    this.Explosion.transform.position = this.hit.point + new Vector3(0f, this.ParticlesHeightOffset, 0f);
                }
            }
        }
        else
        {
            if (this.effectSettings.Target != null)
            {
                this.tTarget = this.effectSettings.Target.transform;
            }
            else if (!this.effectSettings.UseMoveVector)
            {
                Debug.Log("You must setup the the target or the motion vector");
            }
            Vector3 vector;
            if (!this.effectSettings.UseMoveVector)
            {
                vector = (this.tTarget.position - this.tRoot.position).normalized;
            }
            else
            {
                vector = this.tRoot.position + this.effectSettings.MoveVector * this.effectSettings.MoveDistance;
            }
            Vector3 a = this.tRoot.position + vector * this.effectSettings.MoveDistance;
            if (Physics.Raycast(this.tRoot.position, vector, out this.hit, this.effectSettings.MoveDistance + 1f, this.effectSettings.LayerMask))
            {
                a = (this.tRoot.position + Vector3.Normalize(this.hit.point - this.tRoot.position) * (this.effectSettings.MoveDistance + 1f)).normalized;
            }
            this.line.SetPosition(1, this.hit.point - this.effectSettings.ColliderRadius * a);
            Vector3 vector2 = this.hit.point - a * this.ParticlesHeightOffset;
            if (this.StartGlow != null)
            {
                this.StartGlow.transform.position = this.tRoot.position;
            }
            if (this.HitGlow != null)
            {
                this.HitGlow.transform.position = vector2;
            }
            if (this.GoLight != null)
            {
                this.GoLight.transform.position = this.hit.point - a * this.LightHeightOffset;
            }
            if (this.Particles != null)
            {
                this.Particles.transform.position = vector2;
            }
            if (this.Explosion != null)
            {
                this.Explosion.transform.position = vector2;
                this.Explosion.transform.LookAt(vector2 + this.hit.normal);
            }
        }
        CollisionInfo e = new CollisionInfo
        {
            Hit = this.hit
        };

        this.effectSettings.OnCollisionHandler(e);
        if (this.hit.transform != null)
        {
            ShieldCollisionBehaviour component = this.hit.transform.GetComponent <ShieldCollisionBehaviour>();
            if (component != null)
            {
                component.ShieldCollisionEnter(e);
            }
        }
    }