Esempio n. 1
0
    //=====================================================

    private IEnumerator Teleporting(Action onComplete)
    {
        Debug.Log("Teleporting from scene!");

        // Select location to teleport to (an available shield)
        var nextLocation = GetShield();

        // THere's no shields left - don't teleport - just start spawning and attacking again
        if (nextLocation == null)
        {
            Debug.LogWarning("No shields available");

            yield return(new WaitForSeconds(1.0f));

            // *** ... -> SUMMON_GEMS ***
            if (onComplete != null)
            {
                onComplete();
            }

            yield return(null);
        }

        _animator.SetTrigger(HashIDs.TeleportOut);

        yield return(new WaitForSeconds(4.0f));

        // Update player's camera
        if (TeleportEvent != null)
        {
            TeleportEvent(nextLocation.position);
        }

        // Set start point at centre position
        if (nextLocation != null)
        {
            _thisTransform.position = nextLocation.position;
            _thisTransform.rotation = nextLocation.rotation;
        }

        _animator.SetTrigger(HashIDs.TeleportIn);

        // Enable shield
        _shield.OnActivate(_thisTransform.position + Vector3.down, _thisTransform.rotation);

        yield return(new WaitForSeconds(2.0f));

        // *** Teleport -> SUMMON_GEMS ***
        if (onComplete != null)
        {
            onComplete();
        }
    }