Beispiel #1
0
    public override void SetupProjectile(CharacterMasterController charArg)
    {
        base.SetupProjectile(charArg);

        firingWeapon = charArg.GetEquippedWeapon();

        projectileSpeed = firingWeapon.weaponStats.projectileSpeed;
    }
Beispiel #2
0
    /// <summary>
    /// Fires a projectile based on the current weapon's fire method.
    /// </summary>
    private void FireProjectile()
    {
        // get the currently equipped weapon
        WeaponData equipWep = _characterMasterController.GetEquippedWeapon();

        // get the shot values based on the equipped weapon
        int   projPerShot       = equipWep.weaponStats.projectilesPerShot;
        float directionalSpread = GetDirectionSpreadFromShotSpreadStat(equipWep.weaponStats.shotSpread);

        // initialize these vars for upcoming loop
        Vector3 baseDir = GetStraightFiringDirection();
        Vector3 iterDir;

        // loop for as many projectiles are in a single firing
        for (int i = 0; i < projPerShot; i++)
        {
            // if first projectile in shot
            if (i == 0)
            {
                // get a straight direction
                iterDir = GetStraightFiringDirection();
            }
            // else this an additonal projectile in shot
            else
            {
                // get direction randomly offset by weapon spread
                iterDir = GeneralMethods.GetRandomRotationDirection(
                    baseDir, directionalSpread, true);
            }

            // check cases based on equipped weapon's firing method
            switch (_characterMasterController.GetEquippedWeapon().fireMethod)
            {
            case ProjectileFireMethodType.Raycast:
                FireProjectileRaycast(iterDir);
                break;

            case ProjectileFireMethodType.Object:
                SpawnProjectileObject();
                break;
            }
        }
    }