示例#1
0
    void HandleShoot()
    {
        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3 shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
//            TODO: GET EULER ANGLE X (MAYBE Y OR Z IDK) FROM HERE
            ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }
    }
示例#2
0
    void HandleShoot()
    {
        int bulletsPerShotFinal = shootType == SpellShootType.Charge ? Mathf.CeilToInt(currentCharge * bulletsPerShot) : bulletsPerShot;

        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShotFinal; i++)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(SpellMuzzle);
            ProjectileBase newProjectile = Instantiate(projectilePrefab, SpellMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        m_LastTimeShot = Time.time;

        // Trigger attack animation if there is any
        if (SpellAnimator)
        {
            SpellAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
示例#3
0
    void HandleShoot(bool primaryFire)
    {
        ProjectileBase projectile;
        int            numBullets;

        if (primaryFire)
        {
            projectile     = projectilePrefab;
            m_LastTimeShot = Time.time;
            numBullets     = bulletsPerShot;
            // spawn all bullets with random direction
            for (int i = 0; i < numBullets; i++)
            {
                Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle, primaryFire);
                ProjectileBase newProjectile = Instantiate(projectile, m_LastMuzzlePosition, Quaternion.LookRotation(shotDirection));
                newProjectile.Shoot(gameObject);
            }
        }
        else
        {
            if (bulletsPerAltShot > 0 && missileSFX)
            {
                m_ShootAudioSource.PlayOneShot(missileSFX);
            }

            m_LastTimeAltShot = Time.time;
            m_AltShotsToFire  = bulletsPerAltShot;
        }


        // muzzle flash
        // if (muzzleFlashPrefab != null)
        // {
        //     GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
        //     // Unparent the muzzleFlashInstance
        //     if (unparentMuzzleFlash)
        //     {
        //         muzzleFlashInstance.transform.SetParent(null);
        //     }

        //     Destroy(muzzleFlashInstance, 2f);
        // }
        // play shoot SFX
        // if (shootSFX)
        // {
        //     m_ShootAudioSource.PlayOneShot(shootSFX);
        // }

        // Trigger attack animation if there is any
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
示例#4
0
        protected void HandleShoot()
        {
            //if rocket remove rocket
            if (disappearingRocket != null)
            {
                disappearingRocket.SetActive(false);
            }


            // spawn all bullets with random direction
            for (int i = 0; i < bulletsPerShot; i++)
            {
                Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
                ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
                newProjectile.Shoot(this);
            }

            // muzzle flash
            if (muzzleFlashPrefab != null)
            {
                GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
                // Unparent the muzzleFlashInstance
                if (unparentMuzzleFlash)
                {
                    muzzleFlashInstance.transform.SetParent(null);
                }

                Destroy(muzzleFlashInstance, 2f);
            }

            //cartridge vfx
            if (Cardridge && SpawnPositionCardridge != null)
            {
                GameObject cardiridgeInstance = Instantiate(Cardridge, SpawnPositionCardridge.position, SpawnPositionCardridge.rotation, SpawnPositionCardridge.transform);
                cardiridgeInstance.transform.localScale = cardridgeScale;
                Destroy(cardiridgeInstance, 2f);
            }

            m_LastTimeShot = Time.time;

            // play shoot SFX
            if (shootSFX)
            {
                m_ShootAudioSource.PlayOneShot(shootSFX);
            }

            // Trigger attack animation if there is any
            if (weaponAnimator)
            {
                weaponAnimator.SetTrigger(k_AnimAttackParameter);
            }

            // Callback on shoot
            if (onShoot != null)
            {
                onShoot();
            }
        }
示例#5
0
 public void OnHit(Vector3 currVelocity)
 {
     if (UnityEngine.Random.value < chanceToSpawnMissile)
     {
         Vector3        newDirection  = Vector3.RotateTowards(Vector3.up, -1 * currVelocity, 0.08f, 0.0f);
         ProjectileBase newProjectile = Instantiate(missile, transform.position, Quaternion.LookRotation(newDirection));
         newProjectile.Shoot(gameObject);
     }
 }
示例#6
0
    void HandleShoot()
    {
        // spawn all bullets with random direction
        //ランダムな方向ですべての弾丸をスポーンします
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
            ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        //マズルフラッシュ
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            // Unparent the muzzleFlashInstance
            //マズルフラッシュインスタンスのペアレント化を解除します
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        //発射SFXを再生します
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Trigger attack animation if there is any
        //攻撃アニメーションがある場合はトリガーします
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        //発射時のコールバック
        if (onShoot != null)
        {
            onShoot();
        }
    }
    void HandleShoot()
    {
        int bulletsPerShotFinal = shootType == WeaponShootType.Charge ? Mathf.CeilToInt(currentCharge * bulletsPerShot) : bulletsPerShot;

        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShotFinal; i++)
        {
            Vector3         shotDirection   = GetShotDirectionWithinSpread(weaponMuzzle);
            AnalyticsResult analyticsResult = Analytics.CustomEvent("Player_BulletShot");
            StaticStatTracker.sts_bulletsFiredByPlayer++;

            ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX && !useContinuousShootSound)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Trigger attack animation if there is any
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
示例#8
0
    void HandleShoot()
    {
        int bulletsPerShotFinal = shootType == WeaponShootType.Charge ? Mathf.CeilToInt(currentCharge * bulletsPerShot) : bulletsPerShot;

        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShotFinal; i++)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
            ProjectileBase newProjectile = PhotonNetwork.Instantiate(projectilePrefab.name, weaponMuzzle.position, Quaternion.LookRotation(shotDirection)).GetComponent <ProjectileBase>();
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = PhotonNetwork.Instantiate(muzzleFlashPrefab.name, weaponMuzzle.position, weaponMuzzle.rotation);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX && !useContinuousShootSound)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Trigger attack animation if there is any
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }

        OnShootProcessed?.Invoke();
    }
示例#9
0
    void HandleShoot()
    {
        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
            ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Trigger attack animation if there is any
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
示例#10
0
    void Update()
    {
        UpdateAmmo();

        UpdateCharge();

        if (Time.deltaTime > 0)
        {
            muzzleWorldVelocity  = (weaponMuzzle.position - m_LastMuzzlePosition) / Time.deltaTime;
            m_LastMuzzlePosition = weaponMuzzle.position;
        }

        if (m_AltShotsToFire > 0 && Time.time - m_LastTimeAltLaunched >= delayBetweenAltLaunching)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle, false);
            ProjectileBase newProjectile = Instantiate(altProjectilePrefab, m_LastMuzzlePosition, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(gameObject);
            m_AltShotsToFire--;
            m_LastTimeAltLaunched = Time.time;
        }
    }
示例#11
0
    void HandleShoot()
    {
        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShot; i++)
        {
            Vector3 fromPosition = Character.Muzzle.transform.position;
            Vector3 toPosition   = Character.Target;
            Vector3 direction    = toPosition - fromPosition;

            ProjectileBase newProjectile = Instantiate(projectilePrefab, fromPosition, Quaternion.LookRotation(GetShotDirectionWithinSpread(direction)));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, Character.Muzzle.position, Character.Muzzle.rotation, Character.Muzzle.transform);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }
    }
示例#12
0
    void HandleShoot(bool new_click)
    {
        //Telemetry
        if (gameObject.name == "Weapon_EyeLazers" || gameObject.name == "Weapon_MachineGun")
        {
        }
        else if (reloading)
        {
            if (new_click)
            {
                clicksBeforeFired++;
                dryfire.Play();
            }
            reloading = false;
            TelemetryLogger.LogClicksBeforeCanShoot(clicksBeforeFired, gameObject.name, GameObject.Find("Player").transform.position);
            clicksBeforeFired = -1;
            TelemetryLogger.LogShotWhileCooling(m_CurrentAmmo / maxAmmo, gameObject.name, GameObject.Find("Player").transform.position);
        }
        if (gameObject.name == "Weapon_Blaster(Clone)")
        {
            GameObject.Find("GameManager").GetComponent <GameFlowManager>().pistolShotsFired++;
        }
        else if (gameObject.name == "Weapon_Launcher(Clone)")
        {
            GameObject.Find("GameManager").GetComponent <GameFlowManager>().discShotsFired++;
        }
        else if (gameObject.name == "Weapon_Shotgun(Clone)")
        {
            GameObject.Find("GameManager").GetComponent <GameFlowManager>().shotgunShotsFired++;
        }
        else if (gameObject.name == "Weapon_BurstRifle(Clone)")
        {
            GameObject.Find("GameManager").GetComponent <GameFlowManager>().shotgunShotsFired++;
        }

        int bulletsPerShotFinal = shootType == WeaponShootType.Charge ? Mathf.CeilToInt(currentCharge * bulletsPerShot) : bulletsPerShot;

        // spawn all bullets with random direction
        for (int i = 0; i < bulletsPerShotFinal; i++)
        {
            Vector3        shotDirection = GetShotDirectionWithinSpread(weaponMuzzle);
            ProjectileBase newProjectile = Instantiate(projectilePrefab, weaponMuzzle.position, Quaternion.LookRotation(shotDirection));
            newProjectile.Shoot(this);
        }

        // muzzle flash
        if (muzzleFlashPrefab != null)
        {
            GameObject muzzleFlashInstance = Instantiate(muzzleFlashPrefab, weaponMuzzle.position, weaponMuzzle.rotation, weaponMuzzle.transform);
            // Unparent the muzzleFlashInstance
            if (unparentMuzzleFlash)
            {
                muzzleFlashInstance.transform.SetParent(null);
            }

            Destroy(muzzleFlashInstance, 2f);
        }

        m_LastTimeShot = Time.time;

        // play shoot SFX
        if (shootSFX && !useContinuousShootSound)
        {
            m_ShootAudioSource.PlayOneShot(shootSFX);
        }

        // Trigger attack animation if there is any
        if (weaponAnimator)
        {
            weaponAnimator.SetTrigger(k_AnimAttackParameter);
        }

        // Callback on shoot
        if (onShoot != null)
        {
            onShoot();
        }

        OnShootProcessed?.Invoke();
    }