Ejemplo n.º 1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.CompareTag(Tags.player))
        {
            // When the player finishes the game add a bonus proportional to the time between head and player
            float bonus = headController.time * factorPoints;
            GameController.instance.UpdatePoints(Mathf.FloorToInt(bonus));

            endPanel.SetActive(true);
            GameController.instance.doingSetup = true;
            headController.StopHead(3600f);

            if (GameController.instance.points >= GameController.instance.pointsToWin)
            {
                AudioSource.PlayClipAtPoint(audioWin, transform.position, volumeSounds);
                GameController.instance.audioSource.Stop();
                winText.text = string.Concat("¡Has ganado! \nLos puntos obtenidos han sido: ", GameController.instance.points.ToString(),
                                             "\nCon un tiempo: ", headController.time.ToString(), "\n\n  Escribe tu nombre (máx. 3 caracteres): ");
                nameIF.enabled = true;
            }
            else
            {
                AudioSource.PlayClipAtPoint(audioLose, transform.position, volumeSounds);
                GameController.instance.audioSource.Stop();
                winText.text = string.Concat("¡Oooh! No has coseguido los puntos necesarios \nLos puntos obtenidos han sido: ", GameController.instance.points.ToString(),
                                             "\nCon un tiempo: ", headController.time.ToString(), "\n\n  Suerte en el próximo intento");

                StartCoroutine(LoadMenu());
            }
        }
    }