Example #1
0
    private IEnumerator MoveToCauldron()
    {
        /* Turn off animations, as this is a throwing potion */
        playAnimations = false;
        animator.Rebind();
        animator.enabled = false;
        /* Trigger a throw sound effect */
        AudioManager.Instance.PlayEffect(AudioManager.SoundEffects.PotionThrow);
        Vector2    destination = cauldron.gameObject.transform.position;
        Quaternion rotation    = Quaternion.Euler(new Vector3(0f, 0f, Random.Range(1f, 30f)));

        foreach (Vector2 position in CoolStuff.PositionOverParabola(startPosition, cauldron.GetPotionArcMidpoint(), destination, .5f))
        {
            transform.position = position;
            transform.Rotate(rotation.eulerAngles);
            yield return(null);
        }

        /* Trigger a bottle break sound effect */
        AudioManager.Instance.PlayEffect(AudioManager.SoundEffects.PotionBreak);
        /* The potion is now at the cauldron */
        cauldron.AddPotion(this);
        /* Destroy the duplicate potion */
        Destroy(this.gameObject);
    }