コード例 #1
0
    void FireGunHandler()
    {
        GunObject gun = gunHandler.gun;

        HandleOnShootUp();

        gunHandler.OnDelayCall(fireDelayTimer);

        if (fireTimer > 0)
        {
            fireTimer -= Time.deltaTime;
        }
        else if (gunHandler)
        {
            if (!shootingGun)
            {
                if (autoReloadGun.Count > 0 && autoReloadGun.Contains(gunHandler.gunIndex))
                {
                    if (playerBlocking())
                    {
                        return;
                    }
                    if (!gunHandler.CanReload())
                    {
                        return;
                    }
                    if (gunHandler.status == GunHandler.GunStatus.reloading)
                    {
                        return;
                    }
                    if (ReloadSelectedGun())
                    {
                        autoReloadGun.Remove(gunHandler.gunIndex);
                    }
                    return;
                }

                if (fireDelayTimer < gunHandler.gun.fireDelay)
                {
                    if (!gun.canFireWhileDelayed)
                    {
                        return;
                    }
                }

                if (!gunCanShoot())
                {
                    return;
                }

                if (gun.shooting == GunObject.ShootType.auto && input.shooting)
                {
                    continuousShots++;
                    FireGun();
                }
                else
                {
                    bool fire = false;
                    if (gun.fireWhenPressedUp)
                    {
                        if (onShootUp)
                        {
                            fire = true;
                        }
                    }
                    else if (input.shooting)
                    {
                        fire = true;
                    }

                    if (fire)
                    {
                        continuousShots = 0;
                        FireGun();
                    }
                }
            }
        }
    }
コード例 #2
0
    void FireGunHandler()
    {
        if (!input.shooting && !inputUpped)
        {
            if (gunHandler.gun.shooting != GunObject.ShootType.auto)
            {
                fireDelayTimer = 0; //Restart the timer if semi or burst
            }
            inputUpped = true;
        }

        if (fireTimer > 0)
        {
            fireTimer -= Time.deltaTime;
        }
        else if (gunHandler)
        {
            gunHandler.OnDelayCall(fireDelayTimer);

            if (!shootingGun)
            {
                if (autoReloadGun.Count > 0 && autoReloadGun.Contains(gunHandler.gunIndex))
                {
                    if (playerBlocking())
                    {
                        return;
                    }
                    if (!gunHandler.CanReload())
                    {
                        return;
                    }
                    if (gunHandler.status == GunHandler.GunStatus.reloading)
                    {
                        return;
                    }
                    if (ReloadSelectedGun())
                    {
                        autoReloadGun.Remove(gunHandler.gunIndex);
                    }
                    return;
                }

                if (fireDelayTimer < gunHandler.gun.fireDelay)
                {
                    return;
                }

                if (!gunCanShoot())
                {
                    return;
                }

                if (gunHandler.gun.shooting == GunObject.ShootType.auto)
                {
                    continuousShots++;
                    FireGun();
                }
                else if (inputUpped)
                {
                    continuousShots = 0;
                    inputUpped      = false;
                    FireGun();
                }
            }
        }
    }