Esempio n. 1
0
    void FireGrapplingHook()
    {
        hookTransform.parent        = firePoint;
        hookTransform.localPosition = Vector3.zero;
        hookTransform.localRotation = Quaternion.identity;
        hookTransform.position      = firePoint.position;
        hookTransform.rotation      = firePoint.rotation;
        hookTransform.parent        = null;

        Transform newFireParticles = Instantiate(fireParticles, firePoint.position, firePoint.rotation);

        Destroy(newFireParticles.gameObject, 5f);

        bHookOut     = true;
        bHitscanning = true;
        bHookRecover = false;
        bLatchedOn   = false;

        hookBullet.enabled = true;
        hookBullet.AddSpeedModifier(shotSpeed, transform, owner);
    }
Esempio n. 2
0
    public void RegisterHit(GameObject hitObj, Vector3 hitPosition)
    {
        if (!bLatchedOn)
        {
            hookBullet = hookTransform.GetComponent <Bullet>();
            hookBullet.AddSpeedModifier(0f, transform, owner);
            hookBullet.enabled = false;
            line.enabled       = true;

            if (impactParticles != null)
            {
                Transform impactEffect = Instantiate(impactParticles, hookTransform.position, Quaternion.identity);
                Destroy(impactEffect.gameObject, 2f);
            }

            hookTransform.parent   = hitObj.transform;
            hookTransform.position = hitPosition;

            reelLengthRemaining = Vector3.Distance(hookBullet.transform.position, playerRb.transform.position);

            bLatchedOn = true;
            player.SetGrappling(true, reelSpeed);
        }
    }
Esempio n. 3
0
    void FireBullet()
    {
        Transform bulletToFire = null;
        AudioClip sound        = null;

        // Primary / Alt fire
        if (bAlternateArmed)
        {
            bulletToFire = Instantiate(alternateFirePrefab, firePoint.position, firePoint.rotation);
            sound        = secondarySound;
        }
        else
        {
            bulletToFire = Instantiate(bulletPrefab, firePoint.position, firePoint.rotation);
            sound        = primarySound;
        }

        // Shoot it!
        if (bulletToFire != null)
        {
            Bullet newBullet = bulletToFire.GetComponent <Bullet>();
            if (newBullet != null)
            {
                newBullet.AddSpeedModifier(bulletSpeedModifier, transform, owningShooter);
            }

            AudioSource bulletSound = bulletToFire.gameObject.GetComponent <AudioSource>();
            if (bulletSound != null)
            {
                if (sound != null)
                {
                    bulletSound.PlayOneShot(sound);
                }
            }
        }
    }