Example #1
0
    public virtual void FromAnimShoot()
    {
        // Shoot for real now!

        // ALL CLIENTS!!!!

        // Place muzzle flash
        Quaternion rotation = GetBulletSpawn().rotation;
        GameObject GO       = MuzzleFlash.Place(GetBulletSpawn().position, GetBulletSpawn().rotation);

        if (!GetComponentInParent <PlayerDirection>().Right)
        {
            GO.transform.Rotate(0, 0, 180);
        }

        // Play audio
        PlayLocalShot();

        // Spwan shell, if enabled.
        if (Shells.SpawnOnShoot)
        {
            SpawnShell();
        }

        // Callback, all clients.
        if (gun.OnShoot != null)
        {
            gun.OnShoot.Invoke();
        }

        if (!hasAuthority)
        {
            return;
        }

        // LOCAL CLIENT ONLY!!!

        // Remove bullet from chamber...
        BulletInChamber = false;

        // Add one to shot count
        shotsFired++;

        // Shoot!
        this.ShootBullets();

        // Replace bullet if there is one available in magazine.
        if (CanChamber())
        {
            bulletsInMagazine -= Capacity.BulletsConsumed;
            BulletInChamber    = true;
        }
    }