Beispiel #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Planet")
        {
            timeOfExplosion        = (int)timer.timeLeft;
            spriteRenderer.enabled = false;

            Vector3 explosionPosition = (collision.transform.position + transform.position) / 2;
            Instantiate(explosion, explosionPosition, Quaternion.identity, transform);

            if (soundManager != null)
            {
                soundManager.PlaySingle(collisionSound);
            }

            if (restartManager != null)
            {
                resetter.getCurrentIndex();
            }

            countDown            = true;
            collider.enabled     = false;
            controller.immovable = true;
        }

        if (collision.gameObject.tag == "Donut")
        {
            timeOfExplosion        = (int)timer.timeLeft;
            spriteRenderer.enabled = false;

            Instantiate(explosion, transform.position, Quaternion.identity, transform);

            if (soundManager != null)
            {
                soundManager.PlaySingle(collisionSound);
            }

            if (restartManager != null)
            {
                resetter.getCurrentIndex();
            }

            countDown            = true;
            collider.enabled     = false;
            controller.immovable = true;
        }
    }
Beispiel #2
0
    void Update()
    {
        timeLeft   -= Time.deltaTime;
        displayTime = (int)timeLeft;
        text.GetComponent <Text>().text = displayTime.ToString();

        if (timeLeft <= 0)
        {
            if (restartManager != null)
            {
                soundManager.PlaySingle(victory);
                restartManager.getCurrentIndex();
                SceneManager.LoadScene(2);
            }
        }
    }