コード例 #1
0
ファイル: LazerShot.cs プロジェクト: Hugoruberte/OUTERSNAKE
    private void Bounce(ref LazerHit hit, Collider[] colliders)
    {
        Vector3 impactDirection = -direction;

        // Basic bounce
        if (this.bounceCount < this.lazerData.maxBounceCount - 1)
        {
            this.direction = this.ComputeReflectDirection(this.headRigidbody.position, this.direction, hit.bounceNormal, colliders);
            this.headRigidbody.velocity = this.direction * this.lazerData.speed;

            // Calculate mid impact between in and out bounce (this.direction has changed)
            impactDirection += this.direction;
        }
        // Last bounce
        else
        {
            // Physics
            foreach (Collider c in colliders)
            {
                this.ignoredCollider.Add(c);
                Physics.IgnoreCollision(this.headCollider, c);
            }

            if (this.lazerData.lastBounceMode == LastBounceMode.Curve)
            {
                this.StartCoroutine(this.LastBounceCurveCoroutine(this.direction));
            }
            else if (this.lazerData.lastBounceMode == LastBounceMode.Up)
            {
                this.LastBounceUp(this.direction);
            }
            else
            {
                if (Random.Range(0, 2) == 0)
                {
                    this.StartCoroutine(this.LastBounceCurveCoroutine(this.direction));
                }
                else
                {
                    this.LastBounceUp(this.direction);
                }
            }
        }

        // Effect
        InstantParticleEffect impact = PoolingManager.instance.Get <InstantParticleEffect>(this.lazerData.lazerImpactPrefab);

        if (impact != null)
        {
            impact.SetOrientation(this.headRigidbody.position, impactDirection);
            impact.SetColor(Color.red);
            impact.Launch();
        }

        this.bounceCount++;
        this.hiting = false;
    }
コード例 #2
0
    private void VoidImpact(Vector3 pos)
    {
        PoolingManager.instance.Stow(this);

        InstantParticleEffect impact = PoolingManager.instance.Get <InstantParticleEffect>(this.voidImpactPrefab);

        if (impact == null)
        {
            return;
        }

        impact.SetPosition(pos);
        impact.SetColor(Color.red);

        impact.Launch();
    }