Beispiel #1
0
    void FreezeTime()
    {
        bool    playerIsColliding = false;
        Vector3 hitLocation       = player.position + Vector3.up;

        Collider[] hits = Physics.OverlapSphere(hitLocation, 0.25f);

        foreach (Collider hit in hits)
        {
            if (hit.transform != player.transform && hit.gameObject.tag != "Goal")
            {
                playerIsColliding = true;
            }
        }

        if (playerIsColliding)
        {
            respawn.PlaySound(respawn.respawnSound, 0.5f);
        }

        if (!preventFreeze && !playerIsColliding)
        {
            freezeAudioSource.pitch = Random.Range(0.9f, 1f);
            freezeAudioSource.Play();
            if (Time.timeScale == 0)
            {
                Time.timeScale = 1;
                playIcon.SetActive(true);
                pauseIcon.SetActive(false);
                if (levelIndex == 1)
                {
                    Tutorial(1);
                }
                isFrozen = false;
            }
            else
            {
                Time.timeScale = 0;
                playIcon.SetActive(false);
                pauseIcon.SetActive(true);
                if (levelIndex == 1)
                {
                    Tutorial(2);
                }
                isFrozen = true;
            }
        }
    }