コード例 #1
0
    public void Shoot()
    {
        anim.SetTrigger("Shot");
        cameraShake.Shake(weaponStats.ShakeAmount, 0.03f);
        Bullet shotBullet = Instantiate(weaponStats.Bullet, firePoint.position, transform.rotation) as Bullet;

        shotBullet.gameObject.transform.Rotate(new Vector3(0f, 0f, 1f), Random.Range(-weaponStats.Spread, weaponStats.Spread));
        shotBullet.Initialize(weaponStats.MinDamage, weaponStats.MaxDamage, weaponStats.CriticalStrikeChance);
        AudioManager.instance.PlaySound(weaponStats.ShotSound);
        magazineManager.ChangeBulletsAmountByNumber(-1);
    }
コード例 #2
0
    IEnumerator SerialShot()
    {
        for (int i = 0; i < shotsAmount; i++)
        {
            anim.SetTrigger("Shot");
            cameraShake.Shake(weaponStats.ShakeAmount, 0.03f);
            Bullet bullet = Instantiate(weaponStats.Bullet, firePoint.position, transform.rotation) as Bullet;
            bullet.Initialize(weaponStats.MinDamage, weaponStats.MaxDamage, weaponStats.CriticalStrikeChance);
            AudioManager.instance.PlaySound(weaponStats.ShotSound);
            yield return(new WaitForSeconds(0.1f));

            magazineManager.ChangeBulletsAmountByNumber(-1);
        }
    }