Exemplo n.º 1
0
    public virtual bool Fire(GetTarget targetFunc)
    {
        if (!reloading)
        {
            if (!OnCooldown)
            {
                if (Magazine > 0)
                {
                    for (int i = 0; i < ProjectilesPerShot; ++i)
                    {
                        Vector3 bulletEndPos = targetFunc();
                        bulletEndPos += ((isAimed) ? AimedSpread : Spread) * Random.insideUnitSphere;

                        BaseProjectile nProjectile = Instantiate <BaseProjectile>(Resources.Load <BaseProjectile>("Projectiles/" + BulletType.ToString()));
                        nProjectile.transform.position = Muzzle.position;
                        nProjectile.transform.LookAt(bulletEndPos);
                        nProjectile.SetUpProjectile(MuzzleVelocity, Damage);
                    }
                    FiredGun();
                    return(true);
                }
                else
                {
                    Reload();
                }
            }
        }
        return(false);
    }