Ejemplo n.º 1
0
    IEnumerator RecallRoutine()
    {
        discCatchTrigger.enabled = false;

        // Stops the disc from moving
        Disc.ChangeState(DiscState.Recalled);
        yield return(new WaitForEndOfFrame());

        // Looks at the disc
        var target = Disc.transform.position - transform.position;

        target.y = transform.position.y;
        transform.LookAt(target);
        yield return(new WaitForEndOfFrame());

        // Play animations
        animator.SetTrigger("Recall");
        yield return(new WaitForEndOfFrame());

        if (IsPoweredOn)
        {
            AudioManager.instance.Play2DSound(recallClipInfo);
        }

        // Wait for the disc to arrive
        while (IsPoweredOn && Disc.State != DiscState.Attached)
        {
            yield return(new WaitForEndOfFrame());
        }

        if (IsPoweredOn)
        {
            TriggerCatchingRoutine();
        }
    }
Ejemplo n.º 2
0
    IEnumerator ThrowRoutine()
    {
        // Look at mouse direction
        var target = LookAtTarget.position;

        target.y = transform.position.y;
        transform.LookAt(target);
        yield return(new WaitForEndOfFrame());

        // Play Animation
        AudioManager.instance.Play2DSound(throwClipInfo);
        animator.SetTrigger("Throw");
        yield return(new WaitForSeconds(launchDiscDelay));

        // Throw Disc
        if (CurrentPower > 0f)
        {
            Disc.ChangeState(DiscState.Fired);
            yield return(new WaitForSeconds(throwingDiscDelay));
        }

        // Enable the trigger to catch it
        if (CurrentPower > 0f)
        {
            discCatchTrigger.enabled = true;
            ChangeState(PlayerState.PoweredOn);
        }
    }
Ejemplo n.º 3
0
    IEnumerator CatchingRoutine(bool lookAtDisc)
    {
        discCatchTrigger.enabled = false;

        if (lookAtDisc)
        {
            // Face disc direction
            var target = Disc.transform.position - transform.position;
            target.y = transform.position.y;
            transform.LookAt(target);
            yield return(new WaitForEndOfFrame());
        }

        // Wait for the hand to be extended before ensuring the disc is attached
        animator.SetTrigger("Catch");
        yield return(new WaitForEndOfFrame());

        // Ensures the disc attached
        if (Disc.State != DiscState.Attached)
        {
            Disc.ChangeState(DiscState.Attached);
            yield return(new WaitForEndOfFrame());
        }

        // Still has power so wait for the catch animation to complete
        if (IsPoweredOn)
        {
            AudioManager.instance.Play2DSound(catchClipInfo);
            yield return(new WaitForSeconds(cathingDelay));
        }

        if (IsPoweredOn)
        {
            ChangeState(PlayerState.PoweredOn);
        }
    }