Beispiel #1
0
    /// <summary>
    /// Play throwing grenade animation and invokes the method that instantiates the grenade.
    /// Parameters: How much time the player holds the grenade.
    /// </summary>
    private IEnumerator ThrowGrenade(float holdTime)
    {
        if (GetPullAnimTime() < holdTime) // If has finished the pull the pin animation.
        {
            //ThrowAnimation(); // Play throw animation.

            yield return(new WaitForSeconds(delayToThrow));

            InstantiateGrenade(holdTime);

            yield return(new WaitForSeconds(GeThrowAnimTime() - delayToThrow));

            weaponManager.SelectCurrentWeapon(); // Activate the current weapon after throwing the grenade.
            isThrowing = false;
        }
        else // Wait until finish the pull animation to play throw animation.
        {
            yield return(new WaitForSeconds(GetPullAnimTime() - holdTime));

            //ThrowAnimation(); // Play throw animation.

            yield return(new WaitForSeconds(delayToThrow));

            InstantiateGrenade(holdTime);

            yield return(new WaitForSeconds(GeThrowAnimTime() - delayToThrow));

            weaponManager.SelectCurrentWeapon(); // Activate the current weapon after throwing the grenade.
            isThrowing = false;
        }
    }